Exemplo n.º 1
0
        //0.ChanTransNo,1.CreateID,2.CreateDate
        //Datatable 欄位 0.item,1.period
        public bool CreateTransIn(string ChanTransNo,string PurchaseNo, string CreateID, string CreateDate, DataTable dtTransIn, DbTransaction RootDBT,out DataTable dtItem,out DataTable dtGift)
        {
            dtItem = null;
            dtGift = null;
            bool IsRootTranscation = false;
            int PID = -1;
            string TranNum = "";
            ArrayList ParameterList = new ArrayList();
                            //取得並UPDATE DATATABLE的內容
                dtItem = MaterDetl();
                dtGift = GIftDetl();

            try
            {
                DBO.MaintainAcceptDBO dbo = new DBO.MaintainAcceptDBO(ref USEDB);
                DBO.MaintainAccept bco = new DBO.MaintainAccept(strConn);

                //判斷是否有傳入Root Transcation 
                IsRootTranscation = (RootDBT == null) ? true : false;

                #region 啟動交易或指定RootTranscation

                if (IsRootTranscation)
                {
                    //獨立呼叫啟動Transcation
                    Conn = USEDB.CreateConnection();
                    Conn.Open();
                    DBT = Conn.BeginTransaction();
                }
                else
                {
                    DBT = RootDBT;
                }

                #endregion

                //寫入LOG檔
                //LOG 主檔
                ParameterList.Clear();
                ParameterList.Add(ChanTransNo);
                ParameterList.Add(dtTransIn.Rows[0][0].ToString());
                ParameterList.Add(dtTransIn.Rows[0][1].ToString());
                ParameterList.Add(CreateID);
                ParameterList.Add(CreateDate);
                ParameterList.Add(dtTransIn.Rows.Count);
                ParameterList.Add(dtTransIn.Rows[0][2].ToString());
                dbo.CreateDataTransMain(ParameterList, DBT, out PID, out TranNum);

                for (int i = 0; i < dtTransIn.Rows.Count; i++)
                {
                    ParameterList.Clear();
                    ParameterList.Add(PID);
                    ParameterList.Add(ChanTransNo);
                    ParameterList.Add(dtTransIn.Rows[i][0].ToString());
                    ParameterList.Add(dtTransIn.Rows[i][1].ToString());
                    ParameterList.Add(CreateID);
                    ParameterList.Add(CreateDate);
                    ParameterList.Add(dtTransIn.Rows[i][2].ToString());
                    dbo.CreateDataTransDetl(ParameterList, DBT);
                }


                ParameterList.Clear();
                ParameterList.Add(ChanTransNo);
                ParameterList.Add(CreateID);
                DataTable dtTemp = dbo.GetTempSourceData(ParameterList);

                for (int i = 0; i < dtTemp.Rows.Count; i++)
                {
                    bool haveData = false;

                    for (int j = 0; j < dtTransIn.Rows.Count; j++)
                    {
                        string InItem = dtTransIn.Rows[j][0].ToString();
                        string InPeriod = dtTransIn.Rows[j][1].ToString();
                        string InChanSourceNo = dtTransIn.Rows[j][2].ToString();

                        if (InItem == dtTemp.Rows[i]["item"].ToString() && InPeriod == dtTemp.Rows[i]["period"].ToString() && InChanSourceNo == dtTemp.Rows[i]["chan_source_no"].ToString())
                        {
                            haveData = true;
                        }
                    }

                    if (haveData == true)
                    {
                        string BarCode = dtTemp.Rows[i]["barcode"].ToString();
                        string ItemCode = dtTemp.Rows[i]["ItemCode"].ToString();
                        string PeriodCode = dtTemp.Rows[i]["PeriodCode"].ToString();
                        string Item = dtTemp.Rows[i]["item"].ToString();
                        string period = dtTemp.Rows[i]["period"].ToString();
                        string Acc_Qty = dtTemp.Rows[i]["trans_qty"].ToString();
                        string ItemName = dtTemp.Rows[i]["ItemName"].ToString();
                        string package_unit = dtTemp.Rows[i]["package_unit"].ToString();
                        string s_Weight = dtTemp.Rows[i]["s_Weight"].ToString();
                        string s_length = dtTemp.Rows[i]["s_length"].ToString();
                        string s_width = dtTemp.Rows[i]["s_width"].ToString();
                        string s_height = dtTemp.Rows[i]["s_height"].ToString();
                        string p_weight = dtTemp.Rows[i]["p_weight"].ToString();
                        string p_length = dtTemp.Rows[i]["p_length"].ToString();
                        string p_width = dtTemp.Rows[i]["p_width"].ToString();
                        string p_height = dtTemp.Rows[i]["p_height"].ToString();
                        string Product_Source = dtTemp.Rows[i]["Product_Source"].ToString();
                        string Produce_Date = dtTemp.Rows[i]["Produce_Date"].ToString();
                        string Reserved_Period = dtTemp.Rows[i]["Reserved_Period"].ToString();
                        string Valid_Date = dtTemp.Rows[i]["Valid_Date"].ToString();
                        string AllowAccept_Date = dtTemp.Rows[i]["AllowAccept_Date"].ToString();

                        string Pitem = "";
                        string Pperiod = "";

                        string Cost = "";
                        string Price = "";
                        string TaxType = "";
                        string PurchaseQty = "";
                        string PlantAcceptDate = "";
                        string AcceptyQty = "";
                        string Qty = "";
                        string DisQty = "";

                        //if (BarCode.Length == 8 || BarCode.Length == 13)
                        //{
                        //    ItemCode = BarCode;
                        //    PeriodCode = "0000000000000";
                        //}
                        //else if (BarCode.Length == 15)
                        //{
                        //    ItemCode = BarCode.Substring(0, 13);
                        //    PeriodCode = BarCode.Substring(13, 2);
                        //}
                        //else if (BarCode.Length == 18)
                        //{
                        //    ItemCode = BarCode.Substring(0, 13);
                        //    PeriodCode = BarCode.Substring(13, 5);
                        //}

                        bco.QueryItemData(ItemCode, PeriodCode, PurchaseNo, out Pitem, out Pperiod, out Cost, out Price, out TaxType, out PurchaseQty, out PlantAcceptDate, out AcceptyQty, out Qty, out DisQty);

                        DataRow drItem = dtItem.NewRow();
                        drItem["barcode"] = BarCode;
                        drItem["ItemCode"] = ItemCode;
                        drItem["PeriodCode"] = PeriodCode; //2
                        drItem["item"] = Item; //品號
                        drItem["period"] = period; //期別
                        drItem["ItemName"] = ItemName; //5
                        drItem["purchase_Qty"] = PurchaseQty; //採購數量
                        drItem["In_Date"] = PlantAcceptDate; //預進日期
                        drItem["TAcc_Qty"] = Qty; //總驗收數
                        drItem["Acc_Qty"] = Acc_Qty; //驗收數量
                        drItem["Cost"] = Cost; //成本價
                        drItem["Price"] = Price; //零售價
                        drItem["TaxType"] = TaxType; //12 稅別
                        drItem["Package_Unit"] = package_unit; //1包裝數
                        drItem["S_Weight"] = s_Weight; //單品重量
                        drItem["S_Length"] = s_length; //單品長度
                        drItem["S_Width"] = s_width; //單品寬度
                        drItem["S_Height"] = s_height; //單品高度
                        drItem["P_Weight"] = p_weight; //包裝重量
                        drItem["P_Length"] = p_length; //包裝長度
                        drItem["P_Width"] = p_width; //包裝寬度
                        drItem["P_Height"] = p_height; //包裝高度
                        drItem["Product_Source"] = Product_Source; //商品來源
                        drItem["Produce_Date"] = Produce_Date; //製造日期
                        drItem["Reserved_Period"] = Reserved_Period; //保存期限
                        drItem["Valid_Date"] = Valid_Date; //有效日期
                        drItem["AllowAccept_Date"] = AllowAccept_Date; //允收日期
                        dtItem.Rows.Add(drItem);

                        DataTable dtGiftTemp = bco.QueryGift(Item, period, PurchaseNo);

                        for (int x = 0; x < dtGiftTemp.Rows.Count; x++)
                        {
                            DataRow drGift = dtGift.NewRow();
                            drGift["GiftName"] = dtGiftTemp.Rows[x]["GiftName"].ToString();
                            drGift["Barcode"] = BarCode; //0商品條碼
                            drGift["Item"] = Item; //1.品號
                            drGift["Period"] = period; //2.期別
                            drGift["Virtual_Code"] = dtGiftTemp.Rows[x]["VIRTUAL_CODE"].ToString(); //3.虛擬品號
                            drGift["purchase_Qty"] = dtGiftTemp.Rows[x]["PURCHASE_QTY"].ToString(); //4.採購數量
                            drGift["TAcc_Qty"] = dtGiftTemp.Rows[x]["accept_accqty"].ToString(); //X總驗收數
                            drGift["Accept_Qty"] = "0"; //5.驗收數量
                            drGift["Package_Unit"] = "0"; //6.1包裝數
                            drGift["S_Weight"] = "0"; //7.單品重量
                            drGift["S_Length"] = "0"; //8.單品長度
                            drGift["S_Width"] = "0";//9.單品寬度
                            drGift["S_Height"] = "0";//10.單品高度
                            drGift["P_Weight"] = "0"; //11.包裝重量
                            drGift["P_Length"] = "0"; //12.包裝長度
                            drGift["P_Width"] = "0";//13.包裝寬度
                            drGift["P_Height"] = "0"; //14.包裝高度
                        }
                    }
                }

                //刪除暫存資料
                ParameterList.Clear();
                ParameterList.Add(ChanTransNo);
                ParameterList.Add(CreateID);
                dbo.DeleteDataTransTemp(ParameterList, DBT);

                #region 交易成功

                if (IsRootTranscation)
                {
                    //獨立呼叫Transcation成立
                    DBT.Commit();
                }

                #endregion

                return true;

            }
            catch (Exception ex)
            {
                #region 交易失敗

                if (IsRootTranscation)
                {
                    //獨立呼叫Transcation失敗
                    DBT.Rollback();
                }

                #endregion

                throw ex;
            }
            finally
            {
                #region 判斷是否關閉交易連線

                if (IsRootTranscation)
                {
                    //獨立呼叫Transcation,關閉連線
                    if (Conn.State == ConnectionState.Connecting)
                    {
                        Conn.Close();
                    }
                }

                #endregion
            }
        }
Exemplo n.º 2
0
    private bool IsSamePurchaseNo(string PurchaseNo, string Item, string Period)
    {
        VGIModel.MaintainAccept dbo = new VGIModel.MaintainAccept(ConntionDB);

        ParameterList.Clear();
        ParameterList.Add(PurchaseNo);
        ParameterList.Add(Item);
        ParameterList.Add(Period);

        DataTable dt = dbo.QuerySamePur(ParameterList);

        if (dt.Rows.Count == 0)
        {
            return false;
        }

        return true;
    }
Exemplo n.º 3
0
    protected void btnDateCheck_Click(object sender, EventArgs e)
    {
        bool IsOK = false;
        string ReceiveDate = "";

        try
        {
            ErrorMsgLabel.Text = "";

            VGIModel.MaintainAccept dbo = new VGIModel.MaintainAccept(ConntionDB);

            //判斷類型
            if (SLP_MadeDate.Text != "" && SLP_Days.Text != "")
            {
                DateTime EndDate = DateTime.Parse(SLP_MadeDate.Text).AddDays(int.Parse(SLP_Days.Text) - 1);
                SLP_EndDate.Text = EndDate.ToString("yyyy/MM/dd");
            }

            if (SLP_Days.Text != "" && SLP_EndDate.Text != "")
            {
                DateTime MadeDate = DateTime.Parse(SLP_EndDate.Text).AddDays(int.Parse(SLP_Days.Text) * -1 + 1);
                SLP_MadeDate.Text = MadeDate.ToString("yyyy/MM/dd");
            }

            if (SLP_MadeDate.Text != "" && SLP_EndDate.Text != "")
            {
                DateTime dtStart = DateTime.ParseExact(SLP_MadeDate.Text, "yyyy/MM/dd", null);
                DateTime dtEnd = DateTime.ParseExact(SLP_EndDate.Text, "yyyy/MM/dd", null);
                // 計算差異天數
                TimeSpan tsDay = dtEnd - dtStart;
                int dayCount = (int)tsDay.TotalDays + 1;
                SLP_Days.Text = dayCount.ToString();
            }

            DateTime endDate = DateTime.ParseExact(SLP_EndDate.Text, "yyyy/MM/dd", null);

            RadioButtonList rbtReceive = (RadioButtonList)SLP_Receive.FindControl("R1");

            if (endDate < DateTime.Now)
            {
                rbtReceive.SelectedIndex = 1;
                ErrorMsgLabel.Text = "有效日期小於系統日,無法驗收";
                return;
            }
            else
            {
                rbtReceive.SelectedIndex = 0;
            }

            if (rbtSource.SelectedIndex == -1)
            {
                ErrorMsgLabel.Text = "請輸入[商品來源]";
                this.SLP_Days.Text = "0";
                return;
            }

            IsOK = dbo.QueryAcceptSituation(SLP_MadeDate.Text, SLP_Days.Text, SLP_EndDate.Text, rbtSource.SelectedValue, out ReceiveDate);

            if (IsOK == true)
            {
                rbtReceive.SelectedIndex = 0;
                SLP_ReceiveDate.Text = ReceiveDate;
            }
            else
            {
                rbtReceive.SelectedIndex = 1;
                SLP_ReceiveDate.Text = "";
                ErrorMsgLabel.Text = "查無允收天數資料,請重新確認";
                return;
            }

            DateTime DTReceive = DateTime.ParseExact(ReceiveDate, "yyyy/MM/dd", null);

            if (DTReceive < DateTime.Now)
            {
                rbtReceive.SelectedIndex = 1;
                ErrorMsgLabel.Text = "允收日期小於系統日,無法驗收";
            }

        }
        catch (Exception ex)
        {
            ErrorMsgLabel.Text = ex.Message;
        }
    }
Exemplo n.º 4
0
    private void GetDetlData(object sender)
    {
        try
        {
            VGIModel.MaintainAccept dbo = new VGIModel.MaintainAccept(ConntionDB);
            LinkButton lbtnEdit = (LinkButton)sender;
            Label lblBarcode = (Label)lbtnEdit.Parent.FindControl("lblBarcode");

            string ItemCode = string.Empty;
            string PeriodCode = string.Empty;
            string Item = string.Empty;
            string Period = string.Empty;
            string Cost = string.Empty;
            string Price = string.Empty;
            string TaxType = string.Empty;
            string PURCHASE_QTY = string.Empty;
            string PLAN_ACCEPT_DATE = string.Empty;
            string accept_qty = string.Empty;
            string Qty = string.Empty;
            string DIS_Qty = string.Empty;

            #region 根據不同BARCODE長度,取得ITEMCODE

            switch (lblBarcode.Text.Length)
            {
                case 8:
                    ItemCode = lblBarcode.Text;
                    break;
                case 13:
                    ItemCode = lblBarcode.Text;
                    break;
                case 15:
                    ItemCode = lblBarcode.Text.Substring(0, 13);
                    break;
                case 18:
                    ItemCode = lblBarcode.Text.Substring(0, 13);
                    break;
                case 10:
                    ItemCode = lblBarcode.Text.Substring(0, 8);
                    break;
                case 12:
                    ItemCode = lblBarcode.Text;
                    break;
                case 26:
                    ItemCode = lblBarcode.Text.Substring(0, 13);
                    break;
            }

            #endregion

            PeriodCode = GetPeriodCode(lblBarcode.Text);

            DataTable dt = null;
            DataTable dtGift = null;

            if (Session["MasterOLDData_" + PageTimeStamp.Value] != null)
            {
                dt = (DataTable)Session["MasterOLDData_" + PageTimeStamp.Value];
            }

            if (Session["GiftOLDData_" + PageTimeStamp.Value] != null)
            {
                dtGift = (DataTable)Session["GiftOLDData_" + PageTimeStamp.Value];
            }
            else
            {
                dtGift = GIftDetl();
            }

            Session["GiftOLDData_" + PageTimeStamp.Value] = dtGift;

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                if (dt.Rows[i]["barcode"].ToString() == lblBarcode.Text)
                {
                    this.txtBarCode.Text = lblBarcode.Text;
                    this.txtItemCode.Text = ItemCode;
                    this.txtPeriodCode.Text = dt.Rows[i]["PeriodCode"].ToString();
                    this.SLP_SKU.Text = dt.Rows[i]["Item"].ToString();
                    this.txtPeriod.Text = dt.Rows[i]["Period"].ToString();
                    this.txtPurQty.Text = dt.Rows[i]["purchase_qty"].ToString();
                    if (dt.Rows[i]["In_Date"] == "NULL")
                        this.SLP_InDate.Text = "";
                    else
                        this.SLP_InDate.Text = dt.Rows[i]["In_Date"].ToString();
                    this.txtSellPrice.Text = dt.Rows[i]["price"].ToString();
                    this.SLPAcceNum.Text = dt.Rows[i]["Acc_Qty"].ToString();
                    this.AcceNum_Old.Value = dt.Rows[i]["Acc_Qty"].ToString();

                    this.SLP_SWeight.Text = dt.Rows[i]["s_weight"].ToString();
                    this.SLP_SLength.Text = dt.Rows[i]["s_length"].ToString();
                    this.SLP_SWidth.Text = dt.Rows[i]["s_width"].ToString();
                    this.SLP_SHeigh.Text = dt.Rows[i]["s_height"].ToString();

                    this.SLP_PackNum.Text = dt.Rows[i]["package_unit"].ToString();

                    this.SLP_PWeight.Text = dt.Rows[i]["p_weight"].ToString();
                    this.SLP_PLength.Text = dt.Rows[i]["p_length"].ToString();
                    this.SLP_PWidth.Text = dt.Rows[i]["p_width"].ToString();
                    this.SLP_PHeigh.Text = dt.Rows[i]["p_height"].ToString();
                    if (dt.Rows[i]["product_source"].ToString() != "")
                    {
                        this.rbtSource.SelectedValue = dt.Rows[i]["product_source"].ToString();
                    }
                    RadioButtonList rbtReceive = (RadioButtonList)SLP_Receive.FindControl("R1");
                    rbtReceive.SelectedIndex = 0;
                    this.SLP_ReceiveDate.Text = dt.Rows[i]["allowaccept_date"].ToString();
                    this.SLP_MadeDate.Text = dt.Rows[i]["produce_date"].ToString();
                    this.SLP_Days.Text = dt.Rows[i]["reserved_period"].ToString();
                    this.SLP_EndDate.Text = dt.Rows[i]["valid_date"].ToString();

                    dbo.QueryItemData(this.txtItemCode.Text, this.txtPeriodCode.Text, this.txtPurNo.Text, out Item, out Period, out Cost,
                         out Price, out TaxType, out PURCHASE_QTY, out PLAN_ACCEPT_DATE, out accept_qty,
                         out Qty, out DIS_Qty);

                    //取得累積總驗收數和
                    if (accept_qty == "")
                    {
                        accept_qty = "0";
                    }

                    if (Qty == "")
                    {
                        Qty = "0";
                    }

                    if (DIS_Qty == "")
                    {
                        DIS_Qty = "0";
                    }
                    this.hid_TaxType.Value = TaxType;
                    if (Cost == "")
                    {
                        Cost = "0";
                    }
                    this.hid_Cost.Value = Cost;
                    this.txtTAccQty.Text = accept_qty;
                    this.txtTQty.Text = Qty;
                    this.txtDisQty.Text = DIS_Qty;
                    if (txtPurQty.Text == "")
                    {
                        txtPurQty.Text = "0";
                    }
                    this.txtTSQty.Text = (int.Parse(txtPurQty.Text) - int.Parse(txtTAccQty.Text)).ToString();

                    if (txtDisQty.Text == "")
                    {
                        txtDisQty.Text = "0";
                    }
                    this.txtLessQty.Text = (int.Parse(txtTQty.Text) - int.Parse(txtDisQty.Text)).ToString();
                }
            }

            string expression = "Item ='" + Item + "' AND period='" + Period + "'";
            DataTable dtTemp = dtGift.Clone();
            DataRow[] drs = dtGift.Select(expression);

            for (int i = 0; i < drs.Length; i++)
            {
                DataRow drtemp = dtTemp.NewRow();
                for (int j = 0; j < drs[i].ItemArray.Length; j++)
                {
                    drtemp[j] = drs[i][j];
                }
                dtTemp.Rows.Add(drtemp);
            }

            dtTemp.DefaultView.Sort = "VIRTUAL_CODE asc";
            dlGift.DataSource = dtTemp.DefaultView;
            dlGift.DataBind();

            for (int i = 0; i < dlGift.Items.Count; i++)
            {
                Label lblItem = (Label)dlGift.Items[i].FindControl("lblItem");
                Label lblPeriod = (Label)dlGift.Items[i].FindControl("lblPeriod");
                Label lblVirtualCode = (Label)dlGift.Items[i].FindControl("lblVirtualCode");
                Label lblGiftAccQty = (Label)dlGift.Items[i].FindControl("lblGiftAccQty");
                Label lblPurchase_Qty = (Label)dlGift.Items[i].FindControl("lblPurchase_Qty");
                Label lblGiftSQty = (Label)dlGift.Items[i].FindControl("lblGiftSQty");
                TextBox txtAccQty = (TextBox)dlGift.Items[i].FindControl("SLP_GiftAccQty").FindControl("TextBoxCode");
                TextBox txtPackUnit = (TextBox)dlGift.Items[i].FindControl("txt_GiftPack");

                Button btnS = (Button)dlGift.Items[i].FindControl("btnGiftS");
                TextBox txtSWe = (TextBox)dlGift.Items[i].FindControl("txt_GiftSWe");
                TextBox txtSL = (TextBox)dlGift.Items[i].FindControl("txt_GiftSL");
                TextBox txtSWi = (TextBox)dlGift.Items[i].FindControl("txt_GiftSWi");
                TextBox txtSH = (TextBox)dlGift.Items[i].FindControl("txt_GiftSH");

                Button btnP = (Button)dlGift.Items[i].FindControl("btnGiftP");
                TextBox txtPWe = (TextBox)dlGift.Items[i].FindControl("txt_GiftPWe");
                TextBox txtPL = (TextBox)dlGift.Items[i].FindControl("txt_GiftPL");
                TextBox txtPWi = (TextBox)dlGift.Items[i].FindControl("txt_GiftPWi");
                TextBox txtPH = (TextBox)dlGift.Items[i].FindControl("txt_GiftPH");

                #region 取得贈品總驗收量

                ParameterList.Clear();
                ParameterList.Add(lblItem.Text);
                ParameterList.Add(lblPeriod.Text);
                ParameterList.Add(lblVirtualCode.Text);
                ParameterList.Add(txtPurNo.Text);
                DataTable Dt_temp = dbo.GetTotalGiftPurQty(ParameterList);
                lblGiftAccQty.Text = Dt_temp.Rows[0]["accept_qty"].ToString();

                #endregion

                #region 取得贈品短缺數

                lblGiftSQty.Text = Convert.ToString(int.Parse(lblPurchase_Qty.Text) - int.Parse(lblGiftAccQty.Text));

                #endregion

                for (int j = 0; j < dtTemp.Rows.Count; j++)
                {
                    if (lblVirtualCode.Text == dtTemp.Rows[j]["VIRTUAL_CODE"].ToString())
                    {
                        txtAccQty.Text = dtTemp.Rows[j]["accept_qty"].ToString();
                        ((HiddenField)dlGift.Items[i].FindControl("GiftAccQty_Old")).Value = dtTemp.Rows[j]["Old_Qty"].ToString();
                        txtPackUnit.Text = dtTemp.Rows[j]["package_unit"].ToString();

                        txtSWe.Text = dtTemp.Rows[j]["s_weight"].ToString();
                        txtSL.Text = dtTemp.Rows[j]["s_length"].ToString();
                        txtSWi.Text = dtTemp.Rows[j]["s_width"].ToString();
                        txtSH.Text = dtTemp.Rows[j]["s_height"].ToString();

                        txtPWe.Text = dtTemp.Rows[j]["p_weight"].ToString();
                        txtPL.Text = dtTemp.Rows[j]["p_length"].ToString();
                        txtPWi.Text = dtTemp.Rows[j]["p_width"].ToString();
                        txtPH.Text = dtTemp.Rows[j]["p_height"].ToString();
                    }
                }

                if (PageMode == "0")
                {
                    txtAccQty.ReadOnly = true;
                    txtAccQty.CssClass = "readtxtbox";
                    txtPackUnit.ReadOnly = true;
                    txtPackUnit.CssClass = "readtxtbox";

                    txtSWe.ReadOnly = true;
                    txtSWe.CssClass = "readtxtbox";
                    txtSL.ReadOnly = true;
                    txtSL.CssClass = "readtxtbox";
                    txtSWi.ReadOnly = true;
                    txtSWi.CssClass = "readtxtbox";
                    txtSH.ReadOnly = true;
                    txtSH.CssClass = "readtxtbox";

                    txtPWe.ReadOnly = true;
                    txtPWe.CssClass = "readtxtbox";
                    txtPL.ReadOnly = true;
                    txtPL.CssClass = "readtxtbox";
                    txtPWi.ReadOnly = true;
                    txtPWi.CssClass = "readtxtbox";
                    txtPH.ReadOnly = true;
                    txtPH.CssClass = "readtxtbox";
                }

                string strAcceptDate = SLP_AccDate.Text.Substring(0, 4) + SLP_AccDate.Text.Substring(5, 2) + SLP_AccDate.Text.Substring(8, 2);
                string strNow = DateTime.Now.ToString("yyyyMMdd");

                if (int.Parse(strNow) > int.Parse(strAcceptDate))
                {
                    txtAccQty.ReadOnly = true;
                    txtAccQty.CssClass = "readtxtbox";

                    //btnS.Enabled = false;
                    //btnP.Enabled = false;
                }
                else
                {
                    //btnS.Enabled = true;
                    //btnP.Enabled = true;
                }
            }
        }
        catch (Exception ex)
        {
            ErrorMsgLabel.Text = ex.Message;
        }
    }
Exemplo n.º 5
0
    //確認條碼資料
    protected void btnCheck_Click(object sender, EventArgs e)
    {
        ErrorMsgLabel.Text = "";
        string PurchaseNo = string.Empty;
        string Vendor = string.Empty;
        string Item = string.Empty;
        string Period = string.Empty;
        string Cost = string.Empty;
        string Price = string.Empty;
        string TaxType = string.Empty;
        string PURCHASE_QTY = string.Empty;
        string PLAN_ACCEPT_DATE = string.Empty;
        string accept_qty = string.Empty;
        string Qty = string.Empty;
        string DIS_Qty = string.Empty;

        this.SLP_SKU.Text = string.Empty;
        this.txtPeriod.Text = string.Empty;
        this.txtPurQty.Text = string.Empty;
        this.hid_Cost.Value = string.Empty;
        this.hid_TaxType.Value = string.Empty;
        this.SLP_InDate.Text = string.Empty;
        this.txtSellPrice.Text = string.Empty;
        this.txtTAccQty.Text = string.Empty;
        this.txtTQty.Text = string.Empty;
        this.txtDisQty.Text = string.Empty;
        this.txtTSQty.Text = string.Empty;
        this.txtLessQty.Text = string.Empty;

        bool ISOK = false;

        try
        {
            VGIModel.MaintainAccept dbo = new VGIModel.MaintainAccept(ConntionDB);

            ISOK = dbo.QueryPurchaseMaster(Request[txtItemCode.UniqueID], Request[txtPeriodCode.UniqueID], out PurchaseNo, out Vendor);

            if (this.txtPurNo.Text == string.Empty && this.SLP_Vendor.Text == string.Empty)
            {
                if (ISOK == false)
                {
                    this.ErrorMsgLabel.Text = "驗收品項資料未開立採購單";
                    this.hid_Bill_Ini.Value = "0";
                    SetClinetFocus(txtBarCode.ClientID);
                    return;
                }
                else
                {
                    this.txtPurNo.Text = PurchaseNo;
                    this.SLP_Vendor.Text = Vendor;
                }
            }
            else
            {
                if (ISOK == false)
                {
                    this.ErrorMsgLabel.Text = "驗收品項資料未開立採購單";
                    this.hid_Bill_Ini.Value = "0";
                    SetClinetFocus(txtBarCode.ClientID);
                    return;
                }
                else
                {
                    if (IsSamePurchaseNo(PurchaseNo, txtItemCode.Text, txtPeriodCode.Text) == false)
                    {
                        this.ErrorMsgLabel.Text = "驗收品項的採購單號不同,請另開驗收單進行驗收";
                        return;
                    }
                }
            }

            ISOK = dbo.QueryItemData(this.txtItemCode.Text, this.txtPeriodCode.Text, this.txtPurNo.Text, out Item, out Period, out Cost,
                                     out Price, out TaxType, out PURCHASE_QTY, out PLAN_ACCEPT_DATE, out accept_qty,
                                     out Qty, out DIS_Qty);

            if (ISOK == false)
            {
                ErrorMsgLabel.Text = "驗收品項資料未開立採購單";
                this.hid_Bill_Ini.Value = "0";
                SetClinetFocus(txtBarCode.ClientID);
                return;
            }

            string Flag = dbo.CheckItemApprove(Item, Period);

            if (Flag != "0")
            {
                if (Flag == "1")
                {
                    ErrorMsgLabel.Text = "品號" + Item + "主檔資料未審核,請先審核再進行驗收作業";
                }
                else
                {
                    ErrorMsgLabel.Text = "品號" + Item + "已過期別結束日,不可進行驗收作業";
                }

                hid_Bill_Ini.Value = "0";
                SetClinetFocus(txtBarCode.ClientID);
                return;
            }

            hid_Bill_Ini.Value = "1";
            this.SLP_SKU.Text = Item;
            this.txtPeriod.Text = Period;
            this.txtPurQty.Text = PURCHASE_QTY;
            this.hid_Cost.Value = Cost;
            this.hid_TaxType.Value = TaxType;
            this.SLP_InDate.Text = PLAN_ACCEPT_DATE;
            this.txtSellPrice.Text = Price;
            this.txtTAccQty.Text = accept_qty;
            this.txtTQty.Text = Qty;
            this.txtDisQty.Text = DIS_Qty;

            if (accept_qty == "")
            {
                txtTAccQty.Text = "0";
            }

            if (Qty == "")
            {
                txtTQty.Text = "0";
            }

            if (DIS_Qty == "")
            {
                txtDisQty.Text = "0";
            }

            this.txtTSQty.Text = (int.Parse(txtPurQty.Text) - int.Parse(txtTAccQty.Text)).ToString();
            this.txtLessQty.Text = (int.Parse(txtTQty.Text) - int.Parse(txtDisQty.Text)).ToString();

            SLP_PackNum.Text = "1";

            ParameterList.Clear();
            ParameterList.Add(Item);
            ParameterList.Add(Period);
            ParameterList.Add(DateTime.Now.ToString("yyyy/MM/dd"));
            DataTable Dt_Item = dbo.GetItemDetail(ParameterList);

            if (Dt_Item.Rows.Count > 0)
            {
                SLP_SWeight.Text = Dt_Item.Rows[0]["s_weight"].ToString();
                SLP_SLength.Text = Dt_Item.Rows[0]["s_length"].ToString();
                SLP_SWidth.Text = Dt_Item.Rows[0]["s_width"].ToString();
                SLP_SHeigh.Text = Dt_Item.Rows[0]["s_height"].ToString();
                SLP_PackNum.Text = Dt_Item.Rows[0]["package_unit"].ToString();
                SLP_PWeight.Text = Dt_Item.Rows[0]["p_weight"].ToString();
                SLP_PLength.Text = Dt_Item.Rows[0]["p_length"].ToString();
                SLP_PWidth.Text = Dt_Item.Rows[0]["p_Width"].ToString();
                SLP_PHeigh.Text = Dt_Item.Rows[0]["p_height"].ToString();
            }
            else
            {
                SLP_SWeight.Text = "0";
                SLP_SLength.Text = "0";
                SLP_SWidth.Text = "0";
                SLP_SHeigh.Text = "0";
                SLP_PackNum.Text = "0";
                SLP_PWeight.Text = "0";
                SLP_PLength.Text = "0";
                SLP_PWidth.Text = "0";
                SLP_PHeigh.Text = "0";
            }

            GiftBind();

            SetClinetFocus(SLPAcceNum.FindControl("TextBoxCode").ClientID);
        }
        catch (Exception ex)
        {
            ErrorMsgLabel.Text = ex.Message;
        }

    }
Exemplo n.º 6
0
    private void ImportData()
    {
        try
        {
            VGIModel.MaintainAccept dbo = new VGIModel.MaintainAccept(ConntionDB);
            string PurchaseNo = string.Empty;
            string Vendor = string.Empty;

            if (Session["VGI014Detl"] != null)
            {
                DataTable dtItem = (DataTable)Session["VGI014Detl"];

                Session["MasterOLDData_" + PageTimeStamp.Value] = dtItem;
                GridView1.DataSource = dtItem;
                GridView1.DataBind();
                Session["VGI014Detl"] = null;
                Session["VGI012Detl"] = dtItem;

                if (dtItem.Rows.Count > 0)
                {
                    dbo.QueryPurchaseMaster(dtItem.Rows[0]["ItemCode"].ToString(), dtItem.Rows[0]["PeriodCode"].ToString(), out PurchaseNo, out Vendor);
                    txtPurNo.Text = PurchaseNo;
                    SLP_Vendor.Text = Vendor;
                }

            }

            if (Session["VGI104Gift"] != null)
            {
                DataTable dtGift = (DataTable)Session["VGI104Gift"];

                Session["GiftOLDData_" + PageTimeStamp.Value] = dtGift;
                Session["VGI104Gift"] = null;
            }
        }
        catch (Exception ex)
        {
            ErrorMsgLabel.Text = ex.Message;
        }
    }
Exemplo n.º 7
0
    private void GetPageDefault()
    {
        try
        {
            if (PageMode == "0")//檢視
            {

                #region ToolBar狀態

                GMToolbar1.GMToolbarStatus = WUI_GMToolbarV.GMToolbarStatusEnum.ViewOne;

                //GMToolbar1.ButtonEnableControl(WUI_GMToolbarV.ButtonType.New,
                //                                true,
                //                                "VGI012.aspx?Code=VGI01&PageMOde=1",
                //                                null,
                //                                WUI_GMToolbarV.ClickAction.LinkURL);

                GMToolbar1.ButtonEnableControl(WUI_GMToolbarV.ButtonType.New, true, "", btnNew, WUI_GMToolbarV.ClickAction.ButtonClick);

                GMToolbar1.ButtonEnableControl(WUI_GMToolbarV.ButtonType.Edit,
                                                false,
                                                "",
                                                null,
                                                WUI_GMToolbarV.ClickAction.LinkURL);

                GMToolbar1.ButtonEnableControl(WUI_GMToolbarV.ButtonType.Find,
                                                true,
                                                "VGI011.aspx?Code=VGI01",
                                                null,
                                                WUI_GMToolbarV.ClickAction.LinkURL);

                #endregion

                if (Session["VGI01QueryID"] != null)
                {
                    AcceptNoList = (ArrayList)Session["VGI01QueryID"];
                }

                //BindData
                //表頭
                this.hid_Bill_Ini.Value = "1";

                VGIModel.MaintainAccept dbo = new VGIModel.MaintainAccept(ConntionDB);
                ParameterList.Clear();
                ParameterList.Add(AcceptNo);
                DataTable dtResult = dbo.QueryAcceptMain(ParameterList);

                if (dtResult.Rows.Count == 0)
                {
                    ErrorMsgLabel.Text = "查無驗收單資料";
                }
                else
                {
                    Session["MainData_" + PageTimeStamp.Value] = dtResult;

                    this.txtAccNo.Text = AcceptNo;
                    this.SLP_AccDate.Text = dtResult.Rows[0]["accept_date"].ToString();
                    this.txtAccTime.Text = dtResult.Rows[0]["accept_time"].ToString();

                    this.txtPurNo.Text = dtResult.Rows[0]["purchase_no"].ToString();
                    this.txtShipNo.Text = dtResult.Rows[0]["waybill_no"].ToString();
                    this.txtInvoiceNo.Text = dtResult.Rows[0]["invoice_no"].ToString();
                    this.SLP_Vendor.Text = dtResult.Rows[0]["vendor"].ToString();

                    DataTable dtResult2 = new DataTable();
                    dtResult2 = dbo.QueryAcceptDetls(ParameterList);

                    GridView1.DataSource = dtResult2;
                    GridView1.DataBind();

                    Session["MasterOLDData_" + PageTimeStamp.Value] = dtResult2;

                    DataTable dtGifts = new DataTable();
                    dtGifts = dbo.QueryAcceptGifts(ParameterList);

                    Session["GiftOLDData_" + PageTimeStamp.Value] = dtGifts;

                    #region 設定控制項狀態

                    //設定ENABLE或READONLY 屬性值
                    this.txtAccNo.ReadOnly = true;
                    this.txtAccNo.CssClass = "readtxtbox";
                    this.SLP_AccDate.ReadOnly = true;
                    this.txtAccTime.ReadOnly = true;
                    this.txtAccTime.CssClass = "readtxtbox";
                    this.txtPurNo.ReadOnly = true;
                    this.txtPurNo.CssClass = "readtxtbox";
                    this.txtInvoiceNo.ReadOnly = true;
                    this.txtInvoiceNo.CssClass = "readtxtbox";
                    this.txtShipNo.ReadOnly = true;
                    this.txtShipNo.CssClass = "readtxtbox";
                    this.SLP_Vendor.ReadOnly = true;

                    //主表單按鈕
                    string strAcceptDate = SLP_AccDate.Text.Substring(0, 4) + SLP_AccDate.Text.Substring(5, 2) + SLP_AccDate.Text.Substring(8, 2);
                    string strNow = DateTime.Now.ToString("yyyyMMdd");

                    if (AcceptNoList.Count != 0)
                    {
                        if (AcceptNoList.Count == 1)
                        {
                            GMToolbar1.ButtonEnableControl(WUI_GMToolbarV.ButtonType.NavigateBarJustOneRecord,
                                                            false,
                                                            "",
                                                            null,
                                                            WUI_GMToolbarV.ClickAction.LinkURL);
                        }
                        else
                        {
                            string strAcceptNo = Request.QueryString["AcceptNo"].ToString();

                            if (strAcceptNo == AcceptNoList[0].ToString())
                            {
                                GMToolbar1.ButtonEnableControl(WUI_GMToolbarV.ButtonType.NavigateBarFirstRecord,
                                                        false,
                                                        "",
                                                        null,
                                                        WUI_GMToolbarV.ClickAction.LinkURL);
                            }

                            if (strAcceptNo == AcceptNoList[AcceptNoList.Count - 1].ToString())
                            {
                                GMToolbar1.ButtonEnableControl(WUI_GMToolbarV.ButtonType.NavigateBarLastRecord,
                                                        false,
                                                        "",
                                                        null,
                                                        WUI_GMToolbarV.ClickAction.LinkURL);
                            }
                        }

                    }
                    else
                    {
                        GMToolbar1.ButtonEnableControl(WUI_GMToolbarV.ButtonType.NavigateBarJustOneRecord, false, "", null, WUI_GMToolbarV.ClickAction.ButtonClick);
                    }

                    DateTime dtAccDate;
                    DateTime.TryParse(SLP_AccDate.Text, out dtAccDate);

                    //當驗收日期小於系統日時,應將[編輯]鈕 disable //20130304顏筱盈:後來說要讓使用者可以修改重、長、寬、高,所以將此段註解。
                    //if (DateTime.Today > dtAccDate)
                    //{
                    //    btnEdit.Visible = false;
                    //    GMToolbar1.ButtonEnableControl(WUI_GMToolbarV.ButtonType.Edit, false, "", null, WUI_GMToolbarV.ClickAction.LinkURL);
                    //}
                    //else
                    //{
                    //    btnEdit.Visible = true;
                    //    GMToolbar1.ButtonEnableControl(WUI_GMToolbarV.ButtonType.Edit, true, "", btnEdit, WUI_GMToolbarV.ClickAction.ButtonClick);
                    //}


                    this.btnSave.Visible = false;
                    this.btnIn.Enabled = true;
                    this.btnDetlPrint.Enabled = true;
                    this.btnRecPrint.Enabled = true;
                    this.btnQCPrint.Enabled = true;
                    this.btnAccePrint.Enabled = true;

                    //主表
                    this.txtBarCode.ReadOnly = true;
                    this.txtBarCode.CssClass = "readtxtbox";
                    this.txtItemCode.ReadOnly = true;
                    this.txtItemCode.CssClass = "readtxtbox";
                    this.txtPeriodCode.ReadOnly = true;
                    this.txtPeriodCode.CssClass = "readtxtbox";
                    this.SLP_SKU.ReadOnly = true;
                    this.txtPeriod.ReadOnly = true;
                    this.txtPeriod.CssClass = "readtxtbox";
                    this.txtPurQty.ReadOnly = true;
                    this.txtPurQty.CssClass = "readtxtbox";
                    this.SLP_InDate.ReadOnly = true;
                    this.txtSellPrice.ReadOnly = true;
                    this.txtSellPrice.CssClass = "readtxtbox";
                    this.txtTAccQty.ReadOnly = true;
                    this.txtTAccQty.CssClass = "readtxtbox";
                    this.txtTSQty.ReadOnly = true;
                    this.txtTSQty.CssClass = "readtxtbox";
                    this.txtTQty.ReadOnly = true;
                    this.txtTQty.CssClass = "readtxtbox";
                    this.txtDisQty.ReadOnly = true;
                    this.txtDisQty.CssClass = "readtxtbox";
                    this.txtLessQty.ReadOnly = true;
                    this.txtLessQty.CssClass = "readtxtbox";
                    this.SLP_Receive.ReadOnly = true;
                    this.SLP_ReceiveDate.ReadOnly = true;
                    this.SLPAcceNum.ReadOnly = true;
                    this.SLP_PackNum.ReadOnly = true;
                    this.SLP_SWeight.ReadOnly = true;
                    this.SLP_SLength.ReadOnly = true;
                    this.SLP_SWidth.ReadOnly = true;
                    this.SLP_SHeigh.ReadOnly = true;
                    this.BtnS.Enabled = false;
                    this.SLP_PWeight.ReadOnly = true;
                    this.SLP_PLength.ReadOnly = true;
                    this.SLP_PWidth.ReadOnly = true;
                    this.SLP_PHeigh.ReadOnly = true;
                    this.btnP.Enabled = false;
                    this.SLP_MadeDate.ReadOnly = true;
                    this.SLP_Days.ReadOnly = true;
                    this.rbtSource.Enabled = false;
                    this.SLP_ReceiveDate.ReadOnly = true;
                    this.SLP_EndDate.ReadOnly = true;

                    this.btnUpdate.Visible = false;
                    this.btnInsert.Visible = false;
                    this.btnCancel.Visible = false;

                    this.btnGiftQuery.Visible = false;

                    #endregion
                }

                GridView1.Columns[9].Visible = true;
                GridView1.Columns[10].Visible = false;
                GridView1.Columns[11].Visible = false;

                #region 設定GridView中的控制項狀態

                for (int i = 0; i < dlGift.Items.Count; i++)
                {
                    Button btnGiftS = (Button)dlGift.Items[i].FindControl("btnGiftS");
                    Button btnGiftP = (Button)dlGift.Items[i].FindControl("btnGiftP");
                    TextBox txtGiftAccQty = (TextBox)dlGift.Items[i].FindControl("SLP_GiftAccQty").FindControl("TextBoxCode");

                    TextBox txtSWe = (TextBox)dlGift.Items[i].FindControl("txt_GiftSWe");
                    TextBox txtSL = (TextBox)dlGift.Items[i].FindControl("txt_GiftSL");
                    TextBox txtSWi = (TextBox)dlGift.Items[i].FindControl("txt_GiftSWi");
                    TextBox txtSH = (TextBox)dlGift.Items[i].FindControl("txt_GiftSH");

                    TextBox txtGiftPack = (TextBox)dlGift.Items[i].FindControl("txt_GiftPack");

                    TextBox txtPWe = (TextBox)dlGift.Items[i].FindControl("txt_GiftSWe");
                    TextBox txtPL = (TextBox)dlGift.Items[i].FindControl("txt_GiftSL");
                    TextBox txtPWi = (TextBox)dlGift.Items[i].FindControl("txt_GiftSWi");
                    TextBox txtPH = (TextBox)dlGift.Items[i].FindControl("txt_GiftSH");

                    btnGiftS.Enabled = false;
                    btnGiftP.Enabled = false;

                    txtGiftAccQty.ReadOnly = true;
                    txtGiftAccQty.CssClass = "readtxtbox";

                    txtSWe.ReadOnly = true;
                    txtSWe.CssClass = "readtxtbox";
                    txtSL.ReadOnly = true;
                    txtSL.CssClass = "readtxtbox";
                    txtSWi.ReadOnly = true;
                    txtSWi.CssClass = "readtxtbox";
                    txtSH.ReadOnly = true;
                    txtSH.CssClass = "readtxtbox";

                    txtGiftPack.Enabled = false;
                }

                #endregion

                string strAccDate = DateTime.Parse(SLP_AccDate.Text).ToString("yyyyMMdd");

                btnDetlPrint.Attributes.Add("onclick", "AddIFrameTab('驗收單明細表列印','../VGI/VGI071.aspx?Code=VGI07&AccDate=" + strAccDate + "&AccNo=" + txtAccNo.Text + "');return false;");
                btnRecPrint.Attributes.Add("onclick", "AddIFrameTab('到貨驗收紀錄查詢','../VGI/VGI041.aspx?Code=VGI04&AccDate=" + strAccDate + "');return false;");
                btnQCPrint.Attributes.Add("onclick", "AddIFrameTab('驗收品質明細列印','../VGI/VGI091.aspx?Code=VGI09&AccDate=" + strAccDate + "');return false;");
                btnAccePrint.Attributes.Add("onclick", "AddIFrameTab('驗收單明細表列印','../VGI/VGI061.aspx?Code=VGI06&AccDate=" + strAccDate + "&AccNo=" + txtAccNo.Text + "');return false;");
            }
            else if (PageMode == "1" || PageMode == "") //新增模式
            {
                if (CheckDayClose())
                {
                    //ErrorMsgLabel.Text = "供應商帳務已完成日結,不可新增驗收單";
                    Response.Redirect("VGI011.aspx?Code=VGI01&FromPage=VGI012");
                }

                #region ToolBar狀態

                GMToolbar1.GMToolbarStatus = WUI_GMToolbarV.GMToolbarStatusEnum.NewEdit;

                GMToolbar1.ButtonEnableControl(WUI_GMToolbarV.ButtonType.New,
                                false,
                                "",
                                this.btnSave,
                                WUI_GMToolbarV.ClickAction.ButtonClick);


                GMToolbar1.ButtonEnableControl(WUI_GMToolbarV.ButtonType.Find,
                                                true,
                                                "VGI011.aspx?Code=VGI01",
                                                null,
                                                WUI_GMToolbarV.ClickAction.LinkURL);

                GMToolbar1.ButtonEnableControl(WUI_GMToolbarV.ButtonType.Save, true, "", btnSave, WUI_GMToolbarV.ClickAction.ButtonClick);

                #endregion

                #region 設定控制項狀態

                //表頭
                this.txtAccNo.ReadOnly = true;
                this.txtAccNo.CssClass = "readtxtbox";
                this.SLP_AccDate.Text = DateTime.Now.ToString("yyyy/MM/dd");
                this.SLP_AccDate.ReadOnly = true;
                this.txtAccTime.Text = DateTime.Now.ToString("HH:mm");
                this.txtAccTime.ReadOnly = true;
                this.txtAccTime.CssClass = "readtxtbox";
                this.txtPurNo.ReadOnly = true;
                this.txtPurNo.CssClass = "readtxtbox";
                this.btnIn.Enabled = false;
                this.btnEdit.Visible = false;
                this.btnDetlPrint.Enabled = false;
                this.btnRecPrint.Enabled = false;
                this.btnQCPrint.Enabled = false;
                this.btnAccePrint.Enabled = false;

                //主表
                this.btnSave.Visible = true;
                this.btnUpdate.Visible = false;
                this.btnInsert.Visible = true;
                this.btnCancel.Visible = true;

                //this.txtItemCode.Enabled = false;
                this.txtItemCode.ReadOnly = true;
                this.txtItemCode.CssClass = "readtxtbox";
                //this.txtPeriodCode.Enabled = false;
                this.txtPeriodCode.ReadOnly = true;
                this.txtPeriodCode.CssClass = "readtxtbox";
                this.SLP_SKU.ReadOnly = true;
                //this.txtPeriod.Enabled = false;
                this.txtPeriod.ReadOnly = true;
                this.txtPeriod.CssClass = "readtxtbox";
                //this.txtPurQty.Enabled = false;
                this.txtPurQty.ReadOnly = true;
                this.txtPurQty.CssClass = "readtxtbox";
                this.SLP_InDate.ReadOnly = true;
                this.txtSellPrice.ReadOnly = true;
                this.txtSellPrice.CssClass = "readtxtbox";
                //this.txtTAccQty.Enabled = false;
                this.txtTAccQty.ReadOnly = true;
                this.txtTAccQty.CssClass = "readtxtbox";
                //this.txtTSQty.Enabled = false;
                this.txtTSQty.ReadOnly = true;
                this.txtTSQty.CssClass = "readtxtbox";
                //this.txtTQty.Enabled = false;
                this.txtTQty.ReadOnly = true;
                this.txtTQty.CssClass = "readtxtbox";
                //this.txtDisQty.Enabled = false;
                this.txtDisQty.ReadOnly = true;
                this.txtDisQty.CssClass = "readtxtbox";
                //this.txtLessQty.Enabled = false;
                this.txtLessQty.ReadOnly = true;
                this.txtLessQty.CssClass = "readtxtbox";
                this.SLP_Receive.Enabled = false;
                this.SLP_ReceiveDate.ReadOnly = true;

                this.btnGiftQuery.Visible = true;

                #endregion

                GridView1.Columns[9].Visible = false;
                GridView1.Columns[10].Visible = true;
                GridView1.Columns[11].Visible = true;

                if (Session["VGI014Detl"] != null)
                {
                    ImportData();
                }

            }
            else if (PageMode == "2") //編輯模式
            {

                #region ToolBar狀態

                GMToolbar1.GMToolbarStatus = WUI_GMToolbarV.GMToolbarStatusEnum.NewEdit;

                GMToolbar1.ButtonEnableControl(WUI_GMToolbarV.ButtonType.New,
                                false,
                                "",
                                this.btnSave,
                                WUI_GMToolbarV.ClickAction.ButtonClick);


                GMToolbar1.ButtonEnableControl(WUI_GMToolbarV.ButtonType.Find,
                                                false,
                                                "",
                                                null,
                                                WUI_GMToolbarV.ClickAction.LinkURL);

                GMToolbar1.ButtonEnableControl(WUI_GMToolbarV.ButtonType.Save, true, "", btnSave, WUI_GMToolbarV.ClickAction.ButtonClick);

                #endregion

                //BindData
                //表頭
                this.hid_Bill_Ini.Value = "1";

                VGIModel.MaintainAccept dbo = new VGIModel.MaintainAccept(ConntionDB);
                ParameterList.Clear();
                ParameterList.Add(AcceptNo);
                DataTable dtResult = dbo.QueryAcceptMain(ParameterList);

                if (dtResult.Rows.Count == 0)
                {
                    ErrorMsgLabel.Text = "查無驗收單資料";
                }
                else
                {
                    Session["MainData_" + PageTimeStamp.Value] = dtResult;

                    this.txtAccNo.Text = AcceptNo;
                    this.SLP_AccDate.Text = dtResult.Rows[0]["accept_date"].ToString();
                    this.txtAccTime.Text = dtResult.Rows[0]["accept_time"].ToString();
                    this.txtPurNo.Text = dtResult.Rows[0]["purchase_no"].ToString();
                    this.txtShipNo.Text = dtResult.Rows[0]["waybill_no"].ToString();
                    this.txtInvoiceNo.Text = dtResult.Rows[0]["invoice_no"].ToString();
                    this.SLP_Vendor.Text = dtResult.Rows[0]["vendor"].ToString();

                    DataTable dtResult2 = new DataTable();
                    dtResult2 = dbo.QueryAcceptDetls(ParameterList);

                    GridView1.DataSource = dtResult2;
                    GridView1.DataBind();

                    Session["MasterOLDData_" + PageTimeStamp.Value] = dtResult2;

                    DataTable dtGifts = new DataTable();
                    dtGifts = dbo.QueryAcceptGifts(ParameterList);

                    Session["GiftOLDData_" + PageTimeStamp.Value] = dtGifts;

                    #region 設定控制項狀態

                    //設定ENABLE或READONLY 屬性值
                    this.txtAccNo.ReadOnly = true;
                    this.txtAccNo.CssClass = "readtxtbox";
                    this.SLP_AccDate.ReadOnly = true;
                    this.txtAccTime.ReadOnly = true;
                    this.txtAccTime.CssClass = "readtxtbox";
                    this.txtPurNo.ReadOnly = true;
                    this.txtPurNo.CssClass = "readtxtbox";

                    string strAcceptDate = SLP_AccDate.Text.Substring(0, 4) + SLP_AccDate.Text.Substring(5, 2) + SLP_AccDate.Text.Substring(8, 2);
                    string strNow = DateTime.Now.ToString("yyyyMMdd");

                    if (int.Parse(strNow) > int.Parse(strAcceptDate))
                    {
                        this.txtInvoiceNo.ReadOnly = true;
                        this.txtInvoiceNo.CssClass = "readtxtbox";
                        this.txtShipNo.ReadOnly = true;
                        this.txtShipNo.CssClass = "readtxtbox";
                    }
                    else
                    {
                        this.txtInvoiceNo.ReadOnly = false;
                        this.txtInvoiceNo.CssClass = "";
                        this.txtShipNo.ReadOnly = false;
                        this.txtShipNo.CssClass = "";
                    }
                    
                    this.SLP_Vendor.ReadOnly = true;
                    
                    //主表單按鈕
                    if (int.Parse(strNow) > int.Parse(strAcceptDate))
                    {
                        btnEdit.Visible = true;
                        GMToolbar1.ButtonEnableControl(WUI_GMToolbarV.ButtonType.Edit,
                                true,
                                "",
                                btnEdit,
                                WUI_GMToolbarV.ClickAction.ButtonClick);
                    }

                    this.btnSave.Visible = true;
                    this.btnEdit.Visible = false;
                    this.btnUpdate.Visible = true;
                    this.btnInsert.Visible = false;
                    this.btnCancel.Visible = true;

                    if (int.Parse(strNow) > int.Parse(strAcceptDate))
                    {
                        this.btnIn.Enabled = false;
                        this.btnDetlPrint.Enabled = false;
                        this.btnRecPrint.Enabled = false;
                        this.btnQCPrint.Enabled = false;
                        this.btnAccePrint.Enabled = false;
                    }
                    else
                    {
                        this.btnIn.Enabled = true;
                        this.btnDetlPrint.Enabled = true;
                        this.btnRecPrint.Enabled = true;
                        this.btnQCPrint.Enabled = true;
                        this.btnAccePrint.Enabled = true;
                    }

                    //主表
                    this.txtBarCode.ReadOnly = true;
                    this.txtBarCode.CssClass = "readtxtbox";
                    this.txtItemCode.ReadOnly = true;
                    this.txtItemCode.CssClass = "readtxtbox";
                    this.txtPeriodCode.ReadOnly = true;
                    this.txtPeriodCode.CssClass = "readtxtbox";
                    this.SLP_SKU.ReadOnly = true;
                    this.txtPeriod.ReadOnly = true;
                    this.txtPeriod.CssClass = "readtxtbox";
                    this.txtPurQty.ReadOnly = true;
                    this.txtPurQty.CssClass = "readtxtbox";
                    this.SLP_InDate.ReadOnly = true;
                    this.txtSellPrice.ReadOnly = true;
                    this.txtSellPrice.CssClass = "readtxtbox";
                    this.txtTAccQty.ReadOnly = true;
                    this.txtTAccQty.CssClass = "readtxtbox";
                    this.txtTSQty.ReadOnly = true;
                    this.txtTSQty.CssClass = "readtxtbox";
                    this.txtTQty.ReadOnly = true;
                    this.txtTQty.CssClass = "readtxtbox";
                    this.txtDisQty.ReadOnly = true;
                    this.txtDisQty.CssClass = "readtxtbox";
                    this.txtLessQty.ReadOnly = true;
                    this.txtLessQty.CssClass = "readtxtbox";
                    this.SLP_Receive.ReadOnly = true;
                    this.SLP_ReceiveDate.ReadOnly = true;

                    if (int.Parse(strNow) > int.Parse(strAcceptDate))
                    {
                        this.SLPAcceNum.ReadOnly = true;
                        GridView1.Columns[12].Visible = false;
                    }
                    else
                    {
                        
                        this.SLPAcceNum.ReadOnly = false;
                        GridView1.Columns[12].Visible = true;
                    }

                    this.rbtSource.Enabled = true;
                    this.SLP_PackNum.ReadOnly = false;
                    this.SLP_SWeight.ReadOnly = false;
                    this.SLP_SLength.ReadOnly = false;
                    this.SLP_SWidth.ReadOnly = false;
                    this.SLP_SHeigh.ReadOnly = false;
                    this.BtnS.Enabled = true;
                    this.SLP_PWeight.ReadOnly = false;
                    this.SLP_PLength.ReadOnly = false;
                    this.SLP_PWidth.ReadOnly = false;
                    this.SLP_PHeigh.ReadOnly = false;
                    this.btnP.Enabled = true;
                    this.SLP_MadeDate.ReadOnly = false;
                    this.SLP_Days.ReadOnly = false;
                    this.SLP_EndDate.ReadOnly = false;
                    this.SLP_ReceiveDate.ReadOnly = false;

                    #endregion
                }

                this.btnGiftQuery.Visible = true;

                GridView1.Columns[9].Visible = false;
                GridView1.Columns[10].Visible = true;
                GridView1.Columns[11].Visible = false;
            }
        }
        catch (Exception ex)
        {
            ErrorMsgLabel.Text = ex.Message;
        }
    }
Exemplo n.º 8
0
    private void GiftBind()
    {
        try
        {
            ErrorMsgLabel.Text = "";
            VGIModel.MaintainAccept dbo = new VGIModel.MaintainAccept(ConntionDB);
            DataTable dtTemp = dbo.QueryGift(SLP_SKU.Text, txtPeriod.Text, txtPurNo.Text);
            DataTable dtResult;

            //新增模式時,如果採購數量為零時不顯示
            if (PageMode == "1" || PageMode == "")
            {
                dtResult = dtTemp.Clone();

                DataRow[] Dr_Array = dtTemp.Select("PURCHASE_QTY <> 0 ");

                foreach (DataRow DrOld in Dr_Array)
                {
                    dtResult.ImportRow(DrOld);
                }
            }
            else
            {
                dtResult = dtTemp;
            }

            dtResult.DefaultView.Sort = "VIRTUAL_CODE asc";
            dlGift.DataSource = dtResult.DefaultView;
            dlGift.DataBind();

            string strItem = SLP_SKU.Text;
            string strPeriod = txtPeriod.Text;

            DataTable dtGift;

            if (Session["GiftOLDData_" + PageTimeStamp.Value] != null)
            {
                dtGift = (DataTable)Session["GiftOLDData_" + PageTimeStamp.Value];

                for (int i = 0; i < dtGift.Rows.Count; i++)
                {
                    for (int j = 0; j < dlGift.Items.Count; j++)
                    {
                        if (dtGift.Rows[i]["VIRTUAL_CODE"].ToString() == ((Label)dlGift.Items[j].FindControl("lblVirtualCode")).Text && dtGift.Rows[i]["ITEM"].ToString() == strItem && dtGift.Rows[i]["PERIOD"].ToString() == strPeriod)
                        {
                            ((PIC.VDS2G.WebUI.SLP.SLPNumber)dlGift.Items[j].FindControl("SLP_GiftAccQty")).Text = dtGift.Rows[i]["Accept_Qty"].ToString();
                            ((TextBox)dlGift.Items[j].FindControl("txt_GiftPack")).Text = dtGift.Rows[i]["Package_Unit"].ToString();
                            ((TextBox)dlGift.Items[j].FindControl("txt_GiftSWe")).Text = dtGift.Rows[i]["S_Weight"].ToString();
                            ((TextBox)dlGift.Items[j].FindControl("txt_GiftSL")).Text = dtGift.Rows[i]["S_Length"].ToString();
                            ((TextBox)dlGift.Items[j].FindControl("txt_GiftSWi")).Text = dtGift.Rows[i]["S_Width"].ToString();
                            ((TextBox)dlGift.Items[j].FindControl("txt_GiftSH")).Text = dtGift.Rows[i]["S_Height"].ToString();
                            ((TextBox)dlGift.Items[j].FindControl("txt_GiftPWe")).Text = dtGift.Rows[i]["P_Weight"].ToString();
                            ((TextBox)dlGift.Items[j].FindControl("txt_GiftPL")).Text = dtGift.Rows[i]["P_Length"].ToString();
                            ((TextBox)dlGift.Items[j].FindControl("txt_GiftPWi")).Text = dtGift.Rows[i]["P_Width"].ToString();
                            ((TextBox)dlGift.Items[j].FindControl("txt_GiftPH")).Text = dtGift.Rows[i]["P_Height"].ToString();
                            ((HiddenField)dlGift.Items[j].FindControl("GiftAccQty_Old")).Value = dtGift.Rows[i]["Old_Qty"].ToString();
                        }
                        else
                        {
                            ((TextBox)dlGift.Items[j].FindControl("txt_GiftPack")).Text = SLP_PackNum.Text;
                            ((TextBox)dlGift.Items[j].FindControl("txt_GiftSWe")).Text = SLP_SWeight.Text;
                            ((TextBox)dlGift.Items[j].FindControl("txt_GiftSL")).Text = SLP_SLength.Text;
                            ((TextBox)dlGift.Items[j].FindControl("txt_GiftSWi")).Text = SLP_SWidth.Text;
                            ((TextBox)dlGift.Items[j].FindControl("txt_GiftSH")).Text = SLP_SHeigh.Text;
                            ((TextBox)dlGift.Items[j].FindControl("txt_GiftPWe")).Text = SLP_PWeight.Text;
                            ((TextBox)dlGift.Items[j].FindControl("txt_GiftPL")).Text = SLP_PLength.Text;
                            ((TextBox)dlGift.Items[j].FindControl("txt_GiftPWi")).Text = SLP_PWidth.Text;
                            ((TextBox)dlGift.Items[j].FindControl("txt_GiftPH")).Text = SLP_PHeigh.Text;
                        }
                    }
                }
            }
            else
            {
                for (int x = 0; x < dlGift.Items.Count; x++)
                {
                    string strGiftItem = strItem;
                    string strGiftPeriod = strPeriod;
                    string strGiftVirCode = ((Label)dlGift.Items[x].FindControl("lblVirtualCode")).Text;

                    ParameterList.Clear();
                    ParameterList.Add(strGiftItem);
                    ParameterList.Add(strGiftPeriod);
                    ParameterList.Add(strGiftVirCode);
                    ParameterList.Add(DateTime.Now.ToString("yyyy/MM/dd"));
                    DataTable Dt_Temp = dbo.GetGiftDetail(ParameterList);

                    if (Dt_Temp.Rows.Count > 0)
                    {
                        ((TextBox)dlGift.Items[x].FindControl("txt_GiftPack")).Text = Dt_Temp.Rows[0]["package_unit"].ToString();
                        ((TextBox)dlGift.Items[x].FindControl("txt_GiftSWe")).Text = Dt_Temp.Rows[0]["s_weight"].ToString();
                        ((TextBox)dlGift.Items[x].FindControl("txt_GiftSL")).Text = Dt_Temp.Rows[0]["s_length"].ToString();
                        ((TextBox)dlGift.Items[x].FindControl("txt_GiftSWi")).Text = Dt_Temp.Rows[0]["s_width"].ToString();
                        ((TextBox)dlGift.Items[x].FindControl("txt_GiftSH")).Text = Dt_Temp.Rows[0]["s_height"].ToString();
                        ((TextBox)dlGift.Items[x].FindControl("txt_GiftPWe")).Text = Dt_Temp.Rows[0]["p_weight"].ToString();
                        ((TextBox)dlGift.Items[x].FindControl("txt_GiftPL")).Text = Dt_Temp.Rows[0]["p_length"].ToString();
                        ((TextBox)dlGift.Items[x].FindControl("txt_GiftPWi")).Text = Dt_Temp.Rows[0]["p_Width"].ToString();
                        ((TextBox)dlGift.Items[x].FindControl("txt_GiftPH")).Text = Dt_Temp.Rows[0]["p_height"].ToString();
                    }
                    else
                    {
                        ((TextBox)dlGift.Items[x].FindControl("txt_GiftPack")).Text = SLP_PackNum.Text;
                        ((TextBox)dlGift.Items[x].FindControl("txt_GiftSWe")).Text = SLP_SWeight.Text;
                        ((TextBox)dlGift.Items[x].FindControl("txt_GiftSL")).Text = SLP_SLength.Text;
                        ((TextBox)dlGift.Items[x].FindControl("txt_GiftSWi")).Text = SLP_SWidth.Text;
                        ((TextBox)dlGift.Items[x].FindControl("txt_GiftSH")).Text = SLP_SHeigh.Text;
                        ((TextBox)dlGift.Items[x].FindControl("txt_GiftPWe")).Text = SLP_PWeight.Text;
                        ((TextBox)dlGift.Items[x].FindControl("txt_GiftPL")).Text = SLP_PLength.Text;
                        ((TextBox)dlGift.Items[x].FindControl("txt_GiftPWi")).Text = SLP_PWidth.Text;
                        ((TextBox)dlGift.Items[x].FindControl("txt_GiftPH")).Text = SLP_PHeigh.Text;
                    }
                }
            }


        }
        catch (Exception ex)
        {
            ErrorMsgLabel.Text = ex.Message;
        }
    }
Exemplo n.º 9
0
    //刪除,PageMode不一樣處理方式不同
    protected void lbtnDel_Click(object sender, EventArgs e)
    {
        try
        {
            VGIModel.MaintainAccept dbo = new VGIModel.MaintainAccept(ConntionDB);
            LinkButton lbtnDel = (LinkButton)sender;
            Label lblItem = (Label)lbtnDel.Parent.FindControl("lblItem");
            Label lblPeriod = (Label)lbtnDel.Parent.FindControl("lblPeriod");

            DataTable dt = null;
            DataTable dtGift = null;

            if (Session["MasterOLDData_" + PageTimeStamp.Value] != null)
            {
                dt = (DataTable)Session["MasterOLDData_" + PageTimeStamp.Value];
            }

            if (Session["GiftOLDData_" + PageTimeStamp.Value] != null)
            {
                dtGift = (DataTable)Session["GiftOLDData_" + PageTimeStamp.Value];
            }
            else
            {
                dtGift = GIftDetl();
            }

            int DelID = -1;

            if (PageMode == "1" || PageMode == "")
            {
                //PageMode =="1"的情況直接刪除DataTable及贈品資料
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    if (lblItem.Text == dt.Rows[i]["Item"].ToString() && lblPeriod.Text == dt.Rows[i]["Period"].ToString())
                    {
                        DelID = i;
                    }
                }

                if (DelID != -1)
                {
                    dt.Rows.RemoveAt(DelID);
                }

                if (dt.Rows.Count > 0)
                {
                    Session["MasterOLDData_" + PageTimeStamp.Value] = dt;
                }
                else
                {
                    Session["MasterOLDData_" + PageTimeStamp.Value] = null;

                    txtPurNo.Text = "";
                    SLP_Vendor.Text = "";
                }

                GridView1.DataSource = dt;
                GridView1.DataBind();

                for (int i = dtGift.Rows.Count - 1; i >= 0; i--)
                {
                    if (lblItem.Text == dtGift.Rows[i]["Item"].ToString() && lblPeriod.Text == dtGift.Rows[i]["Period"].ToString())
                    {
                        dtGift.Rows.RemoveAt(i);
                    }
                }
                Session["GiftOLDData_" + PageTimeStamp.Value] = dtGift;
            }
            else if (PageMode == "2")
            {
                //PageMode =="2"的情況上FLAG,UpdateFlag="N"
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    if (lblItem.Text == dt.Rows[i]["Item"].ToString() && lblPeriod.Text == dt.Rows[i]["Period"].ToString())
                    {
                        dt.Rows[i]["RowState"] = "N";
                    }
                }

                Session["MasterOLDData_" + PageTimeStamp.Value] = dt;

                for (int i = 0; i < dtGift.Rows.Count; i++)
                {
                    if (lblItem.Text == dtGift.Rows[i]["Item"].ToString() && lblPeriod.Text == dtGift.Rows[i]["Period"].ToString())
                    {
                        dtGift.Rows[i]["RowState"] = "N";
                    }
                }
                Session["GiftOLDData_" + PageTimeStamp.Value] = dtGift;

                GridView1.DataSource = dt.Select("RowState <> 'N'");

                GridView1.DataBind();
            }
        }
        catch (Exception ex)
        {
            ErrorMsgLabel.Text = ex.Message;
        }

    }
Exemplo n.º 10
0
    //存檔
    protected void btnSave_Click(object sender, EventArgs e)
    {
        string ErrorMsg = "";

        try
        {
            for (int i = 0; i < GridView1.Rows.Count; i++)
            {
                Label BarCode = ((Label)GridView1.Rows[i].Cells[0].Controls[1].FindControl("lblBarcode"));
                if (BarCode.Text.Length > 28)
                {
                    throw new Exception("驗收條碼需小於或等於28碼,請重新輸入");
                }
            }

            int intInv = CheckInvoice();
            if (intInv != 0)
            {
                switch (intInv)
                {
                    case 1:
                        throw new Exception("發票號碼長度不符原則,請重新輸入");
                    case 2:
                        throw new Exception("發票前二碼需為英文字母");
                    case 3:
                        throw new Exception("發票後八碼需為數字");
                }
            }

            string UserID = Session["UID"].ToString();
            string CreateDate = DateTime.Now.ToString("yyyyMMddHHmmss");

            string AcceptNo = "";
            string Statue = "";
            string ErrorItem = "";

            VGIModel.MaintainAccept dbo = new VGIModel.MaintainAccept(ConntionDB);

            //檢查是否輸入主檔資料
            DataTable dt = null;
            DataTable dtGift = null;

            if (Session["MasterOLDData_" + PageTimeStamp.Value] != null)
            {
                dt = (DataTable)Session["MasterOLDData_" + PageTimeStamp.Value];
            }
            else
            {
                ErrorMsgLabel.Text = "請輸入明細資料";
                return;
            }

            DataTable dtMain = (DataTable)Session["MainData_" + PageTimeStamp.Value];

            if (Session["GiftOLDData_" + PageTimeStamp.Value] != null)
            {
                dtGift = (DataTable)Session["GiftOLDData_" + PageTimeStamp.Value];
            }
            else
            {
                dtGift = GIftDetl();
            }


            #region 把dtGift贈品數量等欄位以0代替空白

            foreach (DataRow dr in dtGift.Rows)
            {
                if (dr["Accept_Qty"].ToString() == string.Empty)
                {
                    dr["Accept_Qty"] = 0;
                }
                if (dr["Package_Unit"].ToString() == string.Empty)
                {
                    dr["Package_Unit"] = 0;
                }
                if (dr["S_Weight"].ToString() == string.Empty)
                {
                    dr["S_Weight"] = 0;
                }
                if (dr["S_Length"].ToString() == string.Empty)
                {
                    dr["S_Length"] = 0;
                }
                if (dr["S_Width"].ToString() == string.Empty)
                {
                    dr["S_Width"] = 0;
                }
                if (dr["S_Height"].ToString() == string.Empty)
                {
                    dr["S_Height"] = 0;
                }
                if (dr["P_Weight"].ToString() == string.Empty)
                {
                    dr["P_Weight"] = 0;
                }
                if (dr["P_Length"].ToString() == string.Empty)
                {
                    dr["P_Length"] = 0;
                }
                if (dr["P_Width"].ToString() == string.Empty)
                {
                    dr["P_Width"] = 0;
                }
                if (dr["P_Height"].ToString() == string.Empty)
                {
                    dr["P_Height"] = 0;
                }
            }

            #endregion

            //檢查贈品驗收總數量需小於等於該商品驗收數量
            CheckQty(dt, dtGift);

            //檢查材積
            //CheckSize(dt, dtGift);

            //取得稅率
            string TaxRate = dbo.GetTaxRate();

            //計算稅額
            Double TaxAmount = 0;
            Double TaxAmount0 = 0;
            Double TaxAmount2 = 0;
            Double UnTaxAmount1 = 0;
            //應稅總額=sum(明細資料區所有品項的驗收數量*成本價 where 稅別=0)+sum(明細資料區所有品項的驗收數量*成本價 where 稅別=2)
            //未稅總額=sum(明細資料區所有品項的驗收數量*成本價 where 稅別=1)
            //稅額=sum(明細資料區所有品項的驗收數量*成本價 where 稅別=0)*(select taxrate from SYS_VALUEADDTAX where taxtype=0)
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                if (dt.Rows[i]["TaxType"].ToString() == "0")
                {
                    double SubCost0 = double.Parse(dt.Rows[i]["Cost"].ToString()) * int.Parse(dt.Rows[i]["Acc_Qty"].ToString());
                    TaxAmount0 += SubCost0;
                }
                else if (dt.Rows[i]["TaxType"].ToString() == "1")
                {
                    double SubCost1 = double.Parse(dt.Rows[i]["Cost"].ToString()) * int.Parse(dt.Rows[i]["Acc_Qty"].ToString());
                    UnTaxAmount1 += SubCost1;
                }
                else if (dt.Rows[i]["TaxType"].ToString() == "2")
                {
                    double SubCost2 = double.Parse(dt.Rows[i]["Cost"].ToString()) * int.Parse(dt.Rows[i]["Acc_Qty"].ToString());
                    TaxAmount2 += SubCost2;
                }
            }

            TaxAmount = TaxAmount0 + TaxAmount2;
            Double Tax = TaxAmount0 * double.Parse(TaxRate);

            if (PageMode == "1" || PageMode == "")//新增模式
            {
                if (CheckIsFilled(dt))
                {
                    //檢查是否品質檢驗過
                    if (IsChecked())
                    {
                        ArrayList ParameterList = new ArrayList();
                        ParameterList.Clear();
                        ParameterList.Add(UserID); //0
                        ParameterList.Add(CreateDate); //1
                        ParameterList.Add(SLP_AccDate.Text); //(2)[@驗收日期]
                        ParameterList.Add(txtAccTime.Text.Substring(0, 2) + txtAccTime.Text.Substring(3, 2)); //(3)[@驗收時間]
                        ParameterList.Add(txtPurNo.Text); //(4)[@採購單號]
                        ParameterList.Add(txtShipNo.Text); //(5)[@廠商送貨單號]
                        ParameterList.Add(txtInvoiceNo.Text); //(6)[@發票號碼]
                        ParameterList.Add(SLP_Vendor.Text); //(7)[@供應商]
                        ParameterList.Add(TaxAmount); //(8)[@應稅總額]
                        ParameterList.Add(UnTaxAmount1); //(9)[@未稅總額]
                        ParameterList.Add(Tax); //(10)[@稅額]

                        //過濾明細資料,清除不必要欄位
                        //dt.Columns.Remove("ItemCode"); //商品條碼
                        //dt.Columns.Remove("PeriodCode"); //期別條碼
                        //dt.Columns.Remove("ItemName"); //商品名稱
                        //dt.Columns.Remove("TAcc_Qty"); //總驗收數
                        //dt.Columns.Remove("TaxType"); //稅別

                        //過濾贈品明細,清除不必要的資料
                        //dtGift.Columns.Remove("GiftName");
                        //dtGift.Columns.Remove("accept_accqty");
                        //dtGift.Columns.Remove("SQty");

                        dbo.CreateAccept(ParameterList, dt, dtGift, null, out AcceptNo, out Statue, out ErrorItem);

                        this.txtAccNo.Text = AcceptNo;

                        if (Session[SessionIDAccNo] != null)
                        {
                            ((ArrayList)Session[SessionIDAccNo]).Add(AcceptNo);
                        }
                        else
                        {
                            ArrayList al = new ArrayList();
                            al.Add(AcceptNo);
                            Session[SessionIDAccNo] = al;
                        }

                        Response.Redirect("VGI012.aspx?Code=VGI01&PageMode=0&AcceptNo=" + AcceptNo + "&TimeStamp=" + PageTimeStamp.Value);
                    }
                }
            }
            else if (PageMode == "2")
            {
                ArrayList ParameterList = new ArrayList();
                ParameterList.Clear();
                ParameterList.Add(UserID); //0
                ParameterList.Add(CreateDate); //1
                ParameterList.Add(txtAccNo.Text); //2
                ParameterList.Add(SLP_AccDate.Text); //3
                ParameterList.Add(txtPurNo.Text); //(4)[@採購單號]
                ParameterList.Add(txtShipNo.Text); //(5)[@廠商送貨單號]
                ParameterList.Add(txtInvoiceNo.Text); //(6)[@發票號碼]
                ParameterList.Add(TaxAmount); //(7)[@應稅總額]
                ParameterList.Add(UnTaxAmount1); //(8)[@未稅總額]
                ParameterList.Add(Tax); //(9)[@稅額]
                ParameterList.Add(dtMain.Rows[0]["UPDATEDATE"]);//10
                ParameterList.Add(dtMain.Rows[0]["UPDATEUID"]);//11

                //dt.Columns.Remove("ItemCode"); //商品條碼
                //dt.Columns.Remove("PeriodCode"); //期別條碼
                //dt.Columns.Remove("ItemName"); //商品名稱
                //dt.Columns.Remove("TAcc_Qty"); //總驗收數
                //dt.Columns.Remove("TaxType"); //稅別

                //過濾贈品明細,清除不必要的資料
                //dtGift.Columns.Remove("GiftName");
                //dtGift.Columns.Remove("accept_accqty");
                //dtGift.Columns.Remove("SQty");

                string strAcceptDate = SLP_AccDate.Text.Substring(0, 4) + SLP_AccDate.Text.Substring(5, 2) + SLP_AccDate.Text.Substring(8, 2);
                string strNow = DateTime.Now.ToString("yyyyMMdd");

                if (int.Parse(strNow) > int.Parse(strAcceptDate))
                {
                    dbo.UpdateAccept_2(ParameterList, dt, dtGift, null, out Statue, out ErrorItem, out ErrorMsg);
                }
                else
                {
                    dbo.UpdateAccept(ParameterList, dt, dtGift, null, out Statue, out ErrorItem, out ErrorMsg);
                }

                Response.Redirect("VGI012.aspx?Code=VGI01&PageMode=0&AcceptNo=" + txtAccNo.Text + "&TimeStamp=" + PageTimeStamp.Value);
            }

            Session["MainData" + PageTimeStamp.Value] = null;
            Session["DetailData" + PageTimeStamp.Value] = null;
        }
        catch (Exception ex)
        {
            //ResultMsgLabel.Text = ErrorMsg;
            ErrorMsgLabel.Text = ex.Message;

            Session["MainData" + PageTimeStamp.Value] = null;
            Session["DetailData" + PageTimeStamp.Value] = null;
        }
        finally
        {
            ScriptManager.RegisterStartupScript(this, this.GetType(), "savingFlagJs", "savingflag=false;", true);
        }
    }
Exemplo n.º 11
0
    //更新明細及贈品資料
    protected void btnUpdate_Click(object sender, EventArgs e)
    {
        try
        {
            bool IsOK = false;

            IsOK = CheckFill();

            if (IsOK == false)
            {
                return;
            }

            DataTable Dt = null;
            DataTable DtGift = null;

            if (Session["MasterOLDData_" + PageTimeStamp.Value] != null)
            {
                Dt = (DataTable)Session["MasterOLDData_" + PageTimeStamp.Value];
            }
            else
            {
                Dt = MaterDetl();
            }

            if (Session["GiftOLDData_" + PageTimeStamp.Value] != null)
            {
                DtGift = (DataTable)Session["GiftOLDData_" + PageTimeStamp.Value];
            }
            else
            {
                DtGift = GIftDetl();
            }

            //判斷商品有沒有重複的資料列

            bool haveData = false;
            double dblNum = 0;
            int intNum = 0;
            int U = -1;
            VGIModel.MaintainAccept dbo = new VGIModel.MaintainAccept(ConntionDB);

            for (int i = 0; i < Dt.Rows.Count; i++)
            {
                string Item = string.Empty;
                string Period = string.Empty;
                string Cost = string.Empty;
                string Price = string.Empty;
                string TaxType = string.Empty;
                string PURCHASE_QTY = string.Empty;
                string PLAN_ACCEPT_DATE = string.Empty;
                string accept_qty = string.Empty;
                string Qty = string.Empty;
                string DIS_Qty = string.Empty;

                //更新資料
                if (SLP_SKU.Text == Dt.Rows[i]["item"].ToString() && txtPeriod.Text == Dt.Rows[i]["period"].ToString())
                {
                    //取編輯品項的COST TAX_TYPE
                    dbo.QueryItemData(Dt.Rows[i]["ItemCode"].ToString(), Dt.Rows[i]["PeriodCode"].ToString(), this.txtPurNo.Text, out Item, out Period, out Cost,
                                out Price, out TaxType, out PURCHASE_QTY, out PLAN_ACCEPT_DATE, out accept_qty,
                                out Qty, out DIS_Qty);

                    Dt.Rows[i]["ItemCode"] = txtItemCode.Text;
                    Dt.Rows[i]["PeriodCode"] = txtPeriodCode.Text;
                    Dt.Rows[i]["item"] = SLP_SKU.Text;
                    Dt.Rows[i]["period"] = txtPeriod.Text;
                    Dt.Rows[i]["ItemName"] = SLP_SKU.TextBox_Name.Text;
                    Dt.Rows[i]["purchase_Qty"] = txtPurQty.Text;
                    Dt.Rows[i]["In_Date"] = SLP_InDate.Text;
                    Dt.Rows[i]["TAcc_Qty"] = txtTAccQty.Text;
                    Dt.Rows[i]["Acc_Qty"] = SLPAcceNum.Text;
                    Dt.Rows[i]["Cost"] = Cost;
                    //Dt.Rows[i]["Cost"] = this.hid_Cost.Value;
                    Dt.Rows[i]["Price"] = txtSellPrice.Text;
                    //Dt.Rows[i]["TaxType"] = this.hid_TaxType.Value;
                    Dt.Rows[i]["TaxType"] = TaxType;
                    Dt.Rows[i]["Package_Unit"] = int.TryParse(SLP_PackNum.Text, out intNum) ? int.Parse(SLP_PackNum.Text) : 0; //1包裝數
                    Dt.Rows[i]["S_Weight"] = double.TryParse(SLP_SWeight.Text, out dblNum) ? double.Parse(SLP_SWeight.Text) : 0; //單品重量
                    Dt.Rows[i]["S_Length"] = double.TryParse(SLP_SLength.Text, out dblNum) ? double.Parse(SLP_SLength.Text) : 0; //單品寬度
                    Dt.Rows[i]["S_Width"] = double.TryParse(SLP_SWidth.Text, out dblNum) ? double.Parse(SLP_SWidth.Text) : 0; //單品高度
                    Dt.Rows[i]["S_Height"] = double.TryParse(SLP_SHeigh.Text, out dblNum) ? double.Parse(SLP_SHeigh.Text) : 0; //包裝重量
                    Dt.Rows[i]["P_Weight"] = double.TryParse(SLP_PWeight.Text, out dblNum) ? double.Parse(SLP_PWeight.Text) : 0; //包裝重量
                    Dt.Rows[i]["P_Length"] = double.TryParse(SLP_PLength.Text, out dblNum) ? double.Parse(SLP_PLength.Text) : 0; //包裝長度
                    Dt.Rows[i]["P_Width"] = double.TryParse(SLP_PWidth.Text, out dblNum) ? double.Parse(SLP_PWidth.Text) : 0; //包裝寬度
                    Dt.Rows[i]["P_Height"] = double.TryParse(SLP_PHeigh.Text, out dblNum) ? double.Parse(SLP_PHeigh.Text) : 0; //包裝高度

                    if (rbtSource.Items[0].Selected || rbtSource.Items[1].Selected)
                    {
                        Dt.Rows[i]["Product_Source"] = rbtSource.SelectedValue;
                    }
                    if (SLP_MadeDate.Text != "")
                    {
                        Dt.Rows[i]["Produce_Date"] = SLP_MadeDate.Text;
                    }
                    if (SLP_Days.Text != "")
                    {
                        Dt.Rows[i]["Reserved_Period"] = SLP_Days.Text;
                    }
                    if (SLP_EndDate.Text != "")
                    {
                        Dt.Rows[i]["Valid_Date"] = SLP_EndDate.Text;
                    }
                    if (SLP_ReceiveDate.Text != "")
                    {
                        Dt.Rows[i]["AllowAccept_Date"] = SLP_ReceiveDate.Text;
                    }
                    Dt.Rows[i]["RowState"] = "U";

                    Session["MasterOLDData_" + PageTimeStamp.Value] = Dt;
                }
                else
                {
                    //非編輯品項 也要放入Session["MasterOLDData_" + PageTimeStamp.Value]
                    dbo.QueryItemData(Dt.Rows[i]["ItemCode"].ToString(), Dt.Rows[i]["PeriodCode"].ToString(), this.txtPurNo.Text, out Item, out Period, out Cost,
                               out Price, out TaxType, out PURCHASE_QTY, out PLAN_ACCEPT_DATE, out accept_qty,
                               out Qty, out DIS_Qty);

                    Dt.Rows[i]["Cost"] = Cost;
                    Dt.Rows[i]["TaxType"] = TaxType;

                    Dt.Rows[i]["RowState"] = "U";
                    Session["MasterOLDData_" + PageTimeStamp.Value] = Dt;
                }
            }

            string strUID = string.Empty;
            DateTime dtUpdatedate = DateTime.Now;

            //刪除贈品資料
            for (int i = DtGift.Rows.Count - 1; i >= 0; i--)
            {
                if (DtGift.Rows[i]["Item"].ToString() == SLP_SKU.Text && DtGift.Rows[i]["Period"].ToString() == txtPeriod.Text)
                {
                    strUID = DtGift.Rows[i]["UPDATEUID"].ToString();
                    dtUpdatedate = DateTime.Parse(DtGift.Rows[i]["UPDATEDATE"].ToString());

                    DtGift.Rows.RemoveAt(i);
                }
            }

            //插入贈品資料
            for (int i = 0; i < dlGift.Items.Count; i++)
            {
                Label lblVirtualCode = (Label)dlGift.Items[i].FindControl("lblVirtualCode");
                Label lblItem = (Label)dlGift.Items[i].FindControl("lblItem");
                Label lblPeriod = (Label)dlGift.Items[i].FindControl("lblPeriod");
                Label lblPurchase_Qty = (Label)dlGift.Items[i].FindControl("lblPurchase_Qty");
                Label lblGiftAccQty = (Label)dlGift.Items[i].FindControl("lblGiftAccQty");
                Label lblGiftItem = (Label)dlGift.Items[i].FindControl("lblGiftItem");
                TextBox txtGiftAccQty = (TextBox)dlGift.Items[i].FindControl("SLP_GiftAccQty").FindControl("TextBoxCode");
                TextBox txtGiftPack = (TextBox)dlGift.Items[i].FindControl("txt_GiftPack");
                TextBox txtGiftSWe = (TextBox)dlGift.Items[i].FindControl("txt_GiftSWe");
                TextBox txtGiftSL = (TextBox)dlGift.Items[i].FindControl("txt_GiftSL");
                TextBox txtGiftSWi = (TextBox)dlGift.Items[i].FindControl("txt_GiftSWi");
                TextBox txtGiftSH = (TextBox)dlGift.Items[i].FindControl("txt_GiftSH");
                TextBox txtGiftPWe = (TextBox)dlGift.Items[i].FindControl("txt_GiftPWe");
                TextBox txtGiftPL = (TextBox)dlGift.Items[i].FindControl("txt_GiftPL");
                TextBox txtGiftPWi = (TextBox)dlGift.Items[i].FindControl("txt_GiftPWi");
                TextBox txtGiftPH = (TextBox)dlGift.Items[i].FindControl("txt_GiftPH");
                HiddenField GiftAccQty_Old = (HiddenField)dlGift.Items[i].FindControl("GiftAccQty_Old");

                DataRow drGift = DtGift.NewRow();

                int intGiftAccQty;
                string strGiftAccQty;
                if (int.TryParse(txtGiftAccQty.Text, out intGiftAccQty))
                {
                    strGiftAccQty = txtGiftAccQty.Text;
                }
                else
                {
                    strGiftAccQty = "0";
                }

                drGift["Barcode"] = txtBarCode.Text; //商品條碼
                drGift["Item"] = lblItem.Text; //品號
                drGift["Period"] = lblPeriod.Text; //期別
                drGift["Virtual_Code"] = lblVirtualCode.Text; //虛擬品號
                drGift["purchase_Qty"] = lblPurchase_Qty.Text; //採購數量
                drGift["GiftName"] = lblGiftItem.Text;
                drGift["Accept_Qty"] = strGiftAccQty; //驗收數量
                drGift["accept_accqty"] = lblGiftAccQty.Text; //總驗收數
                drGift["Old_Qty"] = double.TryParse(GiftAccQty_Old.Value, out dblNum) ? double.Parse(GiftAccQty_Old.Value) : 0;
                drGift["SQty"] = (int.Parse(lblPurchase_Qty.Text) - int.Parse(strGiftAccQty)).ToString(); //剩餘數量
                drGift["Package_Unit"] = int.TryParse(txtGiftPack.Text, out intNum) ? int.Parse(txtGiftPack.Text) : 0; //1包裝數
                drGift["S_Weight"] = double.TryParse(txtGiftSWe.Text, out dblNum) ? double.Parse(txtGiftSWe.Text) : 0; //單品重量
                drGift["S_Length"] = double.TryParse(txtGiftSL.Text, out dblNum) ? double.Parse(txtGiftSL.Text) : 0; //單品長度
                drGift["S_Width"] = double.TryParse(txtGiftSWi.Text, out dblNum) ? double.Parse(txtGiftSWi.Text) : 0; //單品寬度
                drGift["S_Height"] = double.TryParse(txtGiftSH.Text, out dblNum) ? double.Parse(txtGiftSH.Text) : 0; //單品高度
                drGift["P_Weight"] = double.TryParse(txtGiftPWe.Text, out dblNum) ? double.Parse(txtGiftPWe.Text) : 0; //包裝重量
                drGift["P_Length"] = double.TryParse(txtGiftPL.Text, out dblNum) ? double.Parse(txtGiftPL.Text) : 0; //包裝長度
                drGift["P_Width"] = double.TryParse(txtGiftPWi.Text, out dblNum) ? double.Parse(txtGiftPWi.Text) : 0; //包裝寬度
                drGift["P_Height"] = double.TryParse(txtGiftPH.Text, out dblNum) ? double.Parse(txtGiftPH.Text) : 0; //包裝高度
                drGift["UPDATEUID"] = strUID;
                drGift["UPDATEDATE"] = dtUpdatedate;
                drGift["RowState"] = "U";

                DtGift.Rows.Add(drGift);

            }

            //檢查贈品驗收總數量需小於等於該商品驗收數量
            CheckQty(Dt, DtGift);

            //檢查材積
            //CheckSize(Dt, DtGift);

            Session["GiftOLDData_" + PageTimeStamp.Value] = DtGift;
            Session["VGI012Detl"] = Dt;
            GridView1.DataSource = Dt;
            GridView1.DataBind();

            UnfillData();

            SetClinetFocus(txtBarCode.ClientID);
        }
        catch (Exception ex)
        {
            ErrorMsgLabel.Text = ex.Message;
            ErrorDisableButton();
        }
    }
Exemplo n.º 12
0
    private void databind()
    {
        #region 取得GRIDVIEW資料
        try
        {
            string SessionIDName = "VGI011_" + PageTimeStamp.Value;
            VGIModel.MaintainAccept BCO = new VGIModel.MaintainAccept(ConntionDB);
            ParameterList.Clear();
            ParameterList.Add(this.txtAcceNo.Text);
            ParameterList.Add(this.SLP_AccDate.Text);
            ParameterList.Add(this.SLP_Time.Text);
            ParameterList.Add(this.txtPur.Text);
            ParameterList.Add(this.txtShip.Text);
            ParameterList.Add(this.txtInvoice.Text);
            ParameterList.Add(this.SLP_Vendor.Text);
            ParameterList.Add(this.SLP_SKU.Text);
            ParameterList.Add(this.SLP_Period.Text);
            ParameterList.Add(this.TextBoxRowCountLimit.Text);

            DataTable Dt = new DataTable();

            if (chbLike.Checked == true)
            {
                Dt = BCO.QueryByLike(ParameterList);
            }
            else
            {
                Dt = BCO.QueryByFind(ParameterList);
            }

            if (Dt.Rows.Count == 0)
            {
                ErrorMsgLabel.Text = "查無資料";
            }

            //如果品號和期別有輸入時GRIDVIEW的品號、期別和數量才會顯示
            if (SLP_SKU.Text != string.Empty && SLP_Period.Text != string.Empty)
            {
                GridView1.Columns[6].Visible = true;
                GridView1.Columns[7].Visible = true;
                GridView1.Columns[8].Visible = true;
            }
            else
            {
                GridView1.Columns[6].Visible = false;
                GridView1.Columns[7].Visible = false;
                GridView1.Columns[8].Visible = false;
            }

            DataView dv = Dt.DefaultView;
            dv.Sort = "accept_date DESC, accept_no DESC";

            Session[SessionIDName] = Dt;
            GridView1.DataSource = dv;
            GridView1.PageSize = int.Parse(TextBoxPagesize.Text);
            GridView1.PageIndex = 0;

            GridView1.DataBind();

            ArrayList IDList = new ArrayList();

            for (int i = 0; i < Dt.Rows.Count; i++)
            {
                IDList.Add(Dt.Rows[i]["accept_no"].ToString());
            }

            Session["AcceptNoVGI_" + PageTimeStamp.Value] = IDList;

        }
        catch (Exception ex)
        {
            ErrorMsgLabel.Text = ex.Message;
        }
        #endregion
    }