Skip to content
SupplierPrice.aspx.cs 3.77 KiB
Newer Older
Jack Dan's avatar
Jack Dan committed
using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Text;

public partial class SupplierPrice : MyPage
{
    protected void Page_Load(object sender, EventArgs e)
    {

        this.UCBeginDate.SelectDateTime = DateTime.Now.AddDays(1);
        this.UCEndTime.SelectDateTime = DateTime.Now.AddDays(10);

        MySession.CheckSession();
        CheckPermission(PermissionHelper.PermissionCode.Offer);

        hfSupplierID.Value = MySession.UserSupplierGroup.ToString();

        DataRow drLast = Sdbo.ExecuteDataRow("SELECT TOP 1 A.PostTime,B.NickName FROM Supplier.PriceSheet A INNER JOIN Permission.UserInfo B ON A.CreateBy=B.UserID WHERE A.SupplierID='{0}' ORDER BY A.PostTime DESC", MySession.UserSupplierGroup);
        if (drLast == null)
        {
            //lblLastPriceDate.Text = "无";
        }
        else
        {
            //lblLastPriceDate.Text = String.Format("{0} 提交于 {1}", drLast["NickName"], ((DateTime)drLast["PostTime"]).ToString("yyyy-MM-dd HH:mm:ss"));
        }

        //先看看临时表中有无该供应商的报价信息
        DataTable dt = Sdbo.ExecuteDataTableProc("msp_GetSupplierPriceList", MySession.UserSupplierGroup);
        DataRow drls = Sdbo.ExecuteDataRow("select * from Supplier.PriceSheetLS where SupplierID='{0}'", MySession.UserSupplierGroup);
        
        
        StringBuilder sb = new StringBuilder();
        if (drls == null)
        {
            foreach (DataRow dr in dt.Rows)
            {
                sb.Append("<tr>");
                sb.Append(String.Format("<td>{0}</td>", dr["GoodsName"]));
                sb.Append(String.Format("<td>{0}</td>", dr["Unit"]));
                sb.Append(String.Format("<td>{0}</td>", dr["Price"]));
                sb.Append(String.Format("<td goodsID='{0}' price='{1}'></td>", dr["GoodsID"], dr["Price"]));
                sb.Append("<td class='center'></td>");
                sb.Append("</tr>");
            }
        }
        else
        {
            this.lbTSXX.Text = "提示:此次新报价为暂存数据,请进行提交";
            //获取临时表的数据
            DataTable dtLS = Sdbo.ExecuteDataTableProc("msp_GetSupplierPriceListLS", MySession.UserSupplierGroup);
            
            foreach (DataRow dr in dt.Rows)
            {

                string nowprice = "0.00";
                DataRow[] drsLast = dtLS.Select(String.Format("GoodsID='{0}'", dr["GoodsID"]));//获得临时表中的报价
                if (drsLast != null)
                {
                    nowprice = drsLast[0]["Price"].ToString();
                }
                sb.Append("<tr>");
                sb.Append(String.Format("<td>{0}</td>", dr["GoodsName"]));
                sb.Append(String.Format("<td>{0}</td>", dr["Unit"]));
                sb.Append(String.Format("<td>{0}</td>", dr["Price"]));
                sb.Append(String.Format("<td goodsID='{0}' price='{1}'></td>", dr["GoodsID"], nowprice));
                sb.Append("<td class='center'></td>");
                sb.Append("</tr>");
            }
        }
        lblData.Text = sb.ToString();

        BindHistory();
    }

    private void BindHistory()
    {
        string sql = @" select top 5 BeginTime,EndTime from Supplier.PriceSheet where BeginTime is not null and SupplierID='" + MySession.UserSupplierGroup + "' order by PostTime desc ";
        DataTable dt = Sdbo.ExecuteDataTable(sql);
        this.ddlHistoryTime.Items.Clear();
        for (int i = 0; i < dt.Rows.Count; i++)
        {
            ddlHistoryTime.Items.Add(new ListItem(Convert.ToDateTime(dt.Rows[i]["BeginTime"]).AddDays(1).ToString("yyyy-MM-dd") + "到" + Convert.ToDateTime(dt.Rows[i]["EndTime"]).AddDays(1).ToString("yyyy-MM-dd"), ""));    
        }

    }

    

}