Пример #1
0
        ///判斷是否為該廠商結算日
        //ParameterList:string UserID,string PurchaseNo,string Item,string Period ,string VirtualCode
        //商品Item = VirtualCode
        public bool ClosePurchaseOrderDetail(ArrayList ParameterList, DbTransaction RootDBT)
        {
            bool IsRootTranscation = false;
            try
            {

                string UserID = ParameterList[0].ToString();
                string PurchaseNo = ParameterList[1].ToString();
                string Item = ParameterList[2].ToString();
                string Period = ParameterList[3].ToString();
                string VirtualCode = ParameterList[4].ToString();

                ArrayList SQLParameters = new ArrayList();
                SQLParameters.Clear();
                SQLParameters.Add(PurchaseNo);
                SQLParameters.Add(Item);
                SQLParameters.Add(Period);
                SQLParameters.Add(VirtualCode);
                DataRow dr = GetPurchaseOrderDetail(SQLParameters);

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

                #region 啟動交易或指定RootTranscation
                if (IsRootTranscation)
                {
                    //獨立呼叫啟動Transcation
                    Conn = USEDB.CreateConnection();
                    Conn.Open();
                    DBT = Conn.BeginTransaction();
                }
                else
                {
                    DBT = RootDBT;
                }
                #endregion

                PURDBO.MaintainPurchaseOrder dbo = new PURDBO.MaintainPurchaseOrder(strConn);
                SQLParameters.Clear();
                SQLParameters.Add(UserID);
                SQLParameters.Add("A");

                dbo.ClosePurchaseOrderDetail(SQLParameters, dr, DBT);

                return true;
            }
            catch (Exception ex)
            {
                #region 交易失敗
                if (IsRootTranscation)
                {
                    //獨立呼叫Transcation失敗
                    DBT.Rollback();
                }
                #endregion

                throw ex;
            }
        }
Пример #2
0
    protected void BtnSendMail_Click(object sender, EventArgs e)
    {
        try
        {
            DataTable Dt1;
            DataTable Dt2;

            DataSet Ds1 = new DataSet();
            DataSet Ds2 = new DataSet();

            Dt1 = (DataTable)ViewState["MasterOLDData"];
            Dt2 = (DataTable)ViewState["AllDetailOLDData"];

            Dt2 = DT_Filter(Dt2, "(ITEM=VIRTUAL_CODE) or (ITEM<>VIRTUAL_CODE And PURCHASE_QTY<>0)");

            if (Dt2.Rows.Count == 0)
            {
                ScriptManager.RegisterStartupScript(this, this.GetType(), "", "alert('查無明細資料或採購量未大於0!')", true);
                return;
            }

            if (txtMAIL_ADDR.Text == string.Empty)
            {
                ScriptManager.RegisterStartupScript(this, this.GetType(), "", "alert('電子信箱無資料!')", true);
                return;            
            }

            
            ErrorMsgLabel.Text = "";
            
            #region 新增寄送的採購單資料
            ArrayList ParameterList = new ArrayList();
            ParameterList.Clear();
            ParameterList.Add(Dt1.Rows[0]["PURCHASE_NO"].ToString());
            ParameterList.Add(Session["UID"].ToString());

            MaintainPurchaseOrder bco = new MaintainPurchaseOrder(ConntionDB);

            string resault =bco.CreatePurchaseMailData(ParameterList,null);

            if (resault == "1")
            {
                ScriptManager.RegisterStartupScript(this, this.GetType(), "", "alert('新增寄送採購資料成功!')", true);
            }
            else
            {
                throw new Exception("新增寄送採購單資料失敗!");
            }

            #endregion

        }
        catch (Exception ex)
        { this.ErrorMsgLabel.Text = ex.Message; }
        finally { }
    }
Пример #3
0
        private DataTable FilterDetail(DataTable dtData, string strMANUFACTURE)
        {
            ArrayList ParameterList = new ArrayList();
            MaintainPurchaseOrder PUR02_BCO = new MaintainPurchaseOrder(strConn);
            DataRow[] FindRow = dtData.Select("MANUFACTURE='" + strMANUFACTURE + "'");
            DataTable dtDetail = Detail_Schema();
            int i = 1;
            foreach (DataRow dr in FindRow)
            {
                ParameterList.Clear();
                ParameterList.Add(dr["ITEM"].ToString());
                ParameterList.Add(dr["PERIOD"].ToString());
                ParameterList.Add(DateTime.Now.ToString("yyyy/MM/dd"));

                DateTime DT2 = DateTime.Now.AddMonths(-1);
                string sDT = DT2.ToString("yyyy/MM");
                sDT = sDT + "/26";
                ParameterList.Add(DateTime.Parse(sDT.Trim()).ToString("yyyy/MM/dd"));

                string DeatilData = PUR02_BCO.GetDetail_Data(ParameterList);
                string[] DetailAry;
                DetailAry = DeatilData.Split(new Char[] { ';' });

                DataRow dRow = dtDetail.NewRow();
                dRow["IS_ADD"] = 1;
                dRow["ID"] = i;
                dRow["ITEM"] = dr["ITEM"].ToString();
                dRow["PERIOD"] = dr["PERIOD"].ToString();
                dRow["VIRTUAL_CODE"] = dr["ITEM"].ToString();
                dRow["COST"] = DetailAry[2].ToString();
                dRow["MDC_QTY"] = DetailAry[3].ToString();
                dRow["ACCEPT_ACCQTY"] = DetailAry[4].ToString();

                //取得預設的採購量
                ParameterList.Clear();
                ParameterList.Add(dr["ITEM"].ToString());
                ParameterList.Add(dr["PERIOD"].ToString());
                ParameterList.Add(dr["ROOT_NO"].ToString());
                DataTable dtQty = GetPURCHASE_QTY(ParameterList);
                dRow["PURCHASE_QTY"] = dtQty.Rows[0][0].ToString();

                //dRow["PLAN_ACCEPT_DATE"] = DetailAry[5].ToString();
                dRow["PLAN_ACCEPT_DATE"] = dtQty.Rows[0][1].ToString();

                dRow["MSG"] = DetailAry[6].ToString();
                dRow["CLOSE_TYPE"] = "";
                dRow["CLOSE_DATE"] = "";
                dtDetail.Rows.Add(dRow);
                i++;
            }
            dtDetail.AcceptChanges();
            return dtDetail;
        }
Пример #4
0
    protected void btnDel_Click(object sender, EventArgs e)
    {
        MaintainPurchaseOrder bcop = new MaintainPurchaseOrder(ConntionDB);
        bool IsAcceptOK = bcop.CheckPurchaseIsACCEPT(this.txtPURCHASE_NO.Text);
        if (IsAcceptOK)
        {

            ErrorMsgLabel.Text = "該筆已有驗收單資料,不可進行刪除!!";
            return;
        }
        else
        {

            //CheckVendorAccountClose BCO_CHECK = new CheckVendorAccountClose(ConntionDB);
            //if (BCO_CHECK.CheckVendorCloseStaus(txtONWAY_DATE.Text.Replace("/", "")) == "1")
            //{
            //    ErrorMsgLabel.Text = "在途日 " + txtONWAY_DATE.Text.Replace("/", "") + " 已日結,不可刪除在途單。";
            //    return;
            //}
            //else
            //{
            try
            {

                DataTable dt1 = (DataTable)Session[PageTimeStamp.Value + GridView1.ID];
                DataTable dt2 = (DataTable)Session[PageTimeStamp.Value + GridView2.ID];

                string strNowDate = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss");

                MaintainGoodsInTransit BCO = new MaintainGoodsInTransit(ConntionDB);

                bool bResult = false;

                //0.Item DataTable
                //1.Gift DataTable        
                //2.ONWAY_NO                        
                //3.UPDATEDATE
                //4.UPDATEUID            
                //5.OLD_UPDATEDATE
                //6.OLD_UPDATEUID            
                ParameterList.Clear();
                ParameterList.Add(dt1);                         //0
                ParameterList.Add(dt2);                         //1            
                ParameterList.Add(txtONWAY_NO.Text);            //2
                ParameterList.Add(strNowDate);                  //3
                ParameterList.Add(Session["UID"].ToString());   //4
                ParameterList.Add(hdfOLD_UPDATEDATE.Value);     //5
                ParameterList.Add(SLP_UPDATEUID.Text);          //6

                bResult = BCO.DeleteGoodsInTransit(ParameterList);

                Response.Redirect("PUR051.aspx?Code=PUR05", false);
            }
            catch (Exception ex)
            {
                ErrorMsgLabel.Text = ex.Message;
            }
            finally { }

            //}
        }
    }
Пример #5
0
    private int CheckItemOverDate(string strItem)
    {
        int iResult = 1;//0:無資料 -1:過期 1:正常 -2:品號不屬於此供應商

        MaintainPurchaseOrder BCO = new MaintainPurchaseOrder(ConntionDB);
        ParameterList.Clear();
        ParameterList.Add(strItem);
        DataTable dt = BCO.QueryItem(ParameterList);

        if (dt.Rows.Count > 0)
        {
            if (PUR_VendorCode.Text.Trim() != dt.Rows[0]["MANUFACTURE"].ToString().Trim())
            {
                iResult = -2;
            }
            else
            {
                string strNowDate = DateTime.Now.ToString("yyyy/MM/dd");
                if (string.Compare(dt.Rows[0]["mdc_end_date"].ToString(), strNowDate) < 0)
                {
                    iResult = -1;
                }
            }

        }
        else
        {
            iResult = 0;
        }

        return iResult;
    }
Пример #6
0
    // 新增明細事件
    protected void btnAddDetail_Click(object sender, EventArgs e)
    {
        ErrorMsgLabel.Text = "";
        int iStartID = 0;
        string strSessionName = "PUR02_DTL_" + PageTimeStamp.Value;

        if (this.hid_PageStatus.Value == "INSERT" || this.hid_PageStatus.Value == "EDIT")
        {
            gv_Detail_CacheUpdate();
            gv_Gift_CacheUpdate();

            DataTable DetailDt = (DataTable)Session[strSessionName];

            if (DetailDt == null || DetailDt.Rows.Count <= 0)
            {
                MaintainPurchaseOrder bco = new MaintainPurchaseOrder(ConntionDB);
                DetailDt = bco.QueryItemSchema();
                iStartID = 1;
            }
            else
            {
                iStartID = int.Parse(DetailDt.Rows[DetailDt.Rows.Count - 1]["ID"].ToString()) + 1;
            }

            addRow(ref DetailDt, iStartID);

            Session[strSessionName] = DetailDt;

            gv_Detail.DataSource = DetailDt;
            gv_Detail.PageIndex = 0;
            gv_Detail.DataBind();

            //SetClinetFocus(((TextBox)gv_Detail.Rows[gv_Detail.Rows.Count - 1].Cells[1].Controls[1].FindControl("TextBoxCode")).ClientID);
        }
    }
Пример #7
0
    // 繫結資料 Master
    private bool databind_Master()
    {
        bool bResult = false;
        ErrorMsgLabel.Text = "";
        MaintainPurchaseOrder bco = new MaintainPurchaseOrder(ConntionDB);
        ParameterList.Clear();
        ParameterList.Add(this.hiddenPurchaseNo.Value);
        DataTable Dt = bco.QuerySwitch(PURModel.PURCommon.QueryType.PK, ParameterList);

        if (Dt.Rows.Count > 0)
        {
            ViewState["MasterOLDData"] = Dt;
            this.hiddenIsClose.Value = Dt.Rows[0]["IS_CLOSE"].ToString();
            this.hiddenPurchase_ID.Value = Dt.Rows[0]["ID"].ToString();
            bResult = true;
        }
        else
        {
            ErrorMsgLabel.Text = "查無此筆資料或已被其他使用者刪除,請點選上一筆/下一筆鈕或回查詢頁重新查詢!";
        }
        return bResult;
    }
Пример #8
0
    // Save 事件
    protected void BtnSave_Click(object sender, EventArgs e)
    {
        gv_Detail_CacheUpdate();
        gv_Gift_CacheUpdate();

        DataTable NewDetail = null;
        DataTable NewGift = null;
        string strCheckMsg = string.Empty;
        ErrorMsgLabel.Text = "";
        try
        {
            if (!Page.IsValid)
                return;

            if (this.PUR_PURDate.Text.Trim() == "")
            {
                ErrorMsgLabel.Text = "請必須選取採購日期!!";  //ShowErrorMessage("請必須選取採購日期!!");
                return;
            }
            else
            {
                //DateTime dtChkDate = DateTime.ParseExact(DateTime.Parse(this.PUR_PURDate.Text.Trim()).ToString("yyyy/MM/dd"), "yyyy/MM/dd", null);
                //if (dtChkDate < DateTime.Today)
                //{
                //    ErrorMsgLabel.Text = "採購日期必須大於等於系統日!!";  //ShowErrorMessage("採購日期必須大於等於系統日!!");
                //    return;
                //}

                //判斷採購單的採購日是否己日結
                //VGIModel.CheckVendorAccountClose dbo = new PIC.VDS2G.LGT.VGI.CheckVendorAccountClose(ConntionDB);
                //string IsClosed = dbo.CheckVendorCloseStaus(DateTime.Parse(this.PUR_PURDate.Text).ToString("yyyyMMdd"));
                //if (IsClosed == "1")
                //{
                //    ErrorMsgLabel.Text = "該採購單日已日結,不可進行新增!!";
                //    return;
                //}
            }

            if (this.PUR_PurUser.Text.Trim() == "")
            {
                ErrorMsgLabel.Text = "請必須選取採購人員!!";  //ShowErrorMessage("請必須選取採購人員!!");
                return;
            }

            switch (this.hid_PageStatus.Value)
            {
                case "INSERT":

                    if (this.PUR_VendorCode.Text.Trim() == "")
                    {
                        ErrorMsgLabel.Text = "請必須選取供應商!!";  //ShowErrorMessage("請必須選取供應商!!");
                        break;
                    }

                    if (gv_Detail.Rows.Count <= 0)
                    {
                        ErrorMsgLabel.Text = "請必須輸入明細資料!!";  //ShowErrorMessage("請必須輸入明細資料!!");
                    }
                    else
                    {
                        NewDetail = this.getDetailData();
                        if (NewDetail == null)
                            break;

                        NewGift = this.getGiftData();
                        if (NewGift == null && gv_Gift.Rows.Count > 0)
                            break;

                        strCheckMsg = CheckSaveData();
                        if (strCheckMsg != "")
                        {
                            ErrorMsgLabel.Text = strCheckMsg;
                        }
                        else
                        {
                            MaintainPurchaseOrder bco = new MaintainPurchaseOrder(ConntionDB);
                            string v_PurchaseNo = "";
                            v_PurchaseNo = bco.CreateMasterAndDetail_Gift(this.getMasterParameterList(), DT_DelEmptyRow(NewDetail), NewGift, null);
                            if (v_PurchaseNo == "")
                            {
                                ErrorMsgLabel.Text = "新增 0 筆資料!";
                            }
                            else
                            {
                                Response.Redirect("PUR022.aspx?PURCHASE_NO=" + v_PurchaseNo + "&SSID=&mode=VIEW&Code=PUR02");
                            }
                        }
                    }

                    break;
                case "EDIT":


                    #region 取得更新前舊值

                    DataTable dtMasterOLD = (DataTable)ViewState["MasterOLDData"];

                    DataTable dtDetailOLD = (DataTable)ViewState["DetailOLDData"];

                    DataTable dtGiftOLD = (DataTable)ViewState["GiftOLDData"];
                    #endregion

                    if (dtMasterOLD.Rows.Count == 0)
                    {
                        ErrorMsgLabel.Text = "抓取不到Master舊值,更新失敗!";
                    }
                    if (dtDetailOLD.Rows.Count == 0)
                    {
                        ErrorMsgLabel.Text = "抓取不到Detail舊值,更新失敗!";
                    }

                    NewDetail = this.getDetailData();
                    if (NewDetail == null)
                        break;

                    NewGift = this.getGiftData();
                    if (NewGift == null)
                        break;

                    strCheckMsg = CheckSaveData();
                    if (strCheckMsg != "")
                    {
                        ErrorMsgLabel.Text = strCheckMsg;
                    }
                    else
                    {
                        MaintainPurchaseOrder bco = new MaintainPurchaseOrder(ConntionDB);
                        bco.UpdatePurMasterAndDetail_Gift(this.getMasterParameterList(), DT_DelEmptyRow(NewDetail), NewGift, null, dtMasterOLD, dtDetailOLD, dtGiftOLD);

                        Response.Redirect("PUR022.aspx?PURCHASE_NO=" + ViewState["PURCHASE_NO"].ToString() + "&SSID=" + ViewState["SSID"].ToString() + "&mode=VIEW&Code=PUR02");
                    }
                    break;
                default:
                    break;
            }
        }
        catch (Exception ex)
        {
            ErrorMsgLabel.Text = ex.Message;
        }
    }
Пример #9
0
    private void RefreshCost()
    {
        ArrayList ParameterList = new ArrayList();
        string sPageTimeStamp = PageTimeStamp.Value;
        DataTable dtDetail = (DataTable)Session["PUR02_DTL_" + sPageTimeStamp];
        foreach (GridViewRow row in gv_Detail.Rows)
        {
            string sID = ((HiddenField)row.FindControl("HidenID")).Value;
            string sItem = ((ASP.itm_slp_slp_sku_vender_ascx)row.FindControl("PUR_SKU")).Text;
            string sPeriod = ((ASP.itm_slp_slp_itemperiod_ascx)row.FindControl("PUR_Period")).Text;

            string DeatilData = string.Empty;
            string sDate = this.PUR_PURDate.Text.Trim();
            if (sDate != "")
            {
                MaintainPurchaseOrder bco = new MaintainPurchaseOrder(ConntionDB);
                ParameterList.Clear();
                ParameterList.Add(sItem);
                ParameterList.Add(sPeriod);
                ParameterList.Add(DateTime.Parse(sDate.Trim()).ToString("yyyy/MM/dd"));

                DateTime DT = DateTime.ParseExact(DateTime.Parse(sDate.Trim()).ToString("yyyy/MM/dd"), "yyyy/MM/dd", null);
                DateTime DT2 = DT.AddMonths(-1);
                string sDT = DT2.ToString("yyyy/MM");
                sDT = sDT + "/26";
                ParameterList.Add(DateTime.Parse(sDT.Trim()).ToString("yyyy/MM/dd"));

                DeatilData = bco.GetDetail_Data(ParameterList);
            }

            //找出新增或修改的筆數資料,將其輸入的值放到Session內
            DataRow[] FindRows = dtDetail.Select("ID='" + sID + "'");
            if (DeatilData != "")
            {
                string[] DetailAry;
                DetailAry = DeatilData.Split(new Char[] { ';' });
                FindRows[0]["ITEM"] = sItem;
                FindRows[0]["PERIOD"] = sPeriod;
                FindRows[0]["COST"] = DetailAry[2].ToString();
                FindRows[0]["MDC_QTY"] = DetailAry[3].ToString();
                FindRows[0]["ACCEPT_ACCQTY"] = DetailAry[4].ToString();
                FindRows[0]["PLAN_ACCEPT_DATE"] = DetailAry[5].ToString();
            }
            else
            {
                FindRows[0]["ITEM"] = sItem;
                FindRows[0]["PERIOD"] = sPeriod;
                FindRows[0]["COST"] = "0";
                FindRows[0]["MDC_QTY"] = "0";
                FindRows[0]["ACCEPT_ACCQTY"] = "0";
                FindRows[0]["PLAN_ACCEPT_DATE"] = "";
            }
        }
        Session["PUR02_DTL_" + sPageTimeStamp] = dtDetail;
    }
Пример #10
0
 private DataTable Get_MainData(string strPURCHASE_NO)
 {
     MaintainPurchaseOrder bco = new MaintainPurchaseOrder(ConntionDB);
     ParameterList.Clear();
     ParameterList.Add("AND M.PURCHASE_NO='" + strPURCHASE_NO + "'");
     DataTable dt = bco.QuerySwitch(PURModel.PURCommon.QueryType.Where1, ParameterList);
     return dt;
 }
Пример #11
0
    protected void gv_Detail_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        StringBuilder sb1 = new StringBuilder();
        StringBuilder sb2 = new StringBuilder();
        StringBuilder sb3 = new StringBuilder();
        StringBuilder sb4 = new StringBuilder();
        StringBuilder sb5 = new StringBuilder();

        #region 設定 GridView Button 的隱藏與顯示狀態
        if (e.Row.RowType == DataControlRowType.Header)
        {
            if (this.hid_PageStatus.Value != "INSERT")
            { e.Row.Cells[12].Visible = true; }
            else
            { e.Row.Cells[12].Visible = false; }
        }
        #endregion

        switch (e.Row.RowType)
        {
            case DataControlRowType.Header:
                sb1.Remove(0, sb1.Length);
                sb2.Remove(0, sb2.Length);
                sb3.Remove(0, sb3.Length);
                sb4.Remove(0, sb4.Length);
                sb5.Remove(0, sb5.Length);

                //先把供應商欄位開啟 在明細時再做判斷
                if (this.hid_PageStatus.Value == "EDIT" || this.hid_PageStatus.Value == "INSERT")
                {
                    PUR_VendorCode.ReadOnly = false;
                }
                break;

            case DataControlRowType.DataRow:

                if (this.hid_PageStatus.Value == "VIEW")
                {
                    ((SLP_SKU_Vender)e.Row.FindControl("PUR_SKU")).ReadOnly = true;
                    ((SLP_ItemPeriod)e.Row.FindControl("PUR_Period")).ReadOnly = true;
                    ((TextBox)e.Row.FindControl("PurQty")).ReadOnly = true;
                    ((TextBox)e.Row.FindControl("PurQty")).CssClass = "readtxtbox";
                    ((SLPDate)e.Row.FindControl("slpDeliverDate")).ReadOnly = true;
                    ((TextBox)e.Row.FindControl("txtMsg")).ReadOnly = true;
                    ((TextBox)e.Row.FindControl("txtMsg")).CssClass = "readtxtbox";
                    ((Button)e.Row.FindControl("btnCloseCase")).Enabled = false;
                    ((Button)e.Row.FindControl("btnDelete")).Enabled = false;
                }
                else if (this.hid_PageStatus.Value == "EDIT")
                {

                    SLP_SKU_Vender PUR_SKU = ((SLP_SKU_Vender)e.Row.FindControl("PUR_SKU"));
                    PUR_SKU.ReadOnly = true;
                    SLP_ItemPeriod PUR_PERIOD = ((SLP_ItemPeriod)e.Row.FindControl("PUR_Period"));
                    PUR_PERIOD.ReadOnly = true;

                    TextBox txtCT = (TextBox)e.Row.FindControl("txtCloseType");
                    if (txtCT.Text.Trim() == "")
                    {
                        //判斷採購單的項目是否有"在途單"
                        MaintainPurchaseOrder bco = new MaintainPurchaseOrder(ConntionDB);
                        bool IsOK = bco.CheckPurItemIsOnWay(this.tbxPUR_No.Text, PUR_SKU.Text, PUR_PERIOD.Text);

                        if (IsOK)
                        {
                            ((Button)e.Row.FindControl("btnCloseCase")).Enabled = false;
                            ((Button)e.Row.FindControl("btnDelete")).Enabled = false;
                        }
                        else
                        {
                            ((Button)e.Row.FindControl("btnCloseCase")).Enabled = true;
                            ((Button)e.Row.FindControl("btnDelete")).Enabled = true;
                        }

                        ((TextBox)e.Row.FindControl("txtMsg")).ReadOnly = false;
                        ((TextBox)e.Row.FindControl("txtMsg")).CssClass = "";
                        ((TextBox)e.Row.FindControl("PurQty")).ReadOnly = false;
                        ((TextBox)e.Row.FindControl("PurQty")).CssClass = "";
                        ((SLPDate)e.Row.FindControl("slpDeliverDate")).ReadOnly = false;

                        HiddenField txtIS_ADD = (HiddenField)e.Row.FindControl("txtIS_ADD");
                        if (txtIS_ADD.Value.ToString() == "1")
                        {
                            ((SLP_SKU_Vender)e.Row.FindControl("PUR_SKU")).ReadOnly = false;
                            ((SLP_ItemPeriod)e.Row.FindControl("PUR_Period")).ReadOnly = false;
                            ((TextBox)e.Row.FindControl("txtMsg")).ReadOnly = false;
                            ((TextBox)e.Row.FindControl("txtMsg")).CssClass = "";
                        }
                    }
                    else
                    {
                        ((Button)e.Row.FindControl("btnCloseCase")).Enabled = false;
                        ((Button)e.Row.FindControl("btnDelete")).Enabled = false;
                        ((TextBox)e.Row.FindControl("txtMsg")).ReadOnly = true;
                        ((TextBox)e.Row.FindControl("txtMsg")).CssClass = "readtxtbox";
                        ((TextBox)e.Row.FindControl("PurQty")).ReadOnly = true;
                        ((TextBox)e.Row.FindControl("PurQty")).CssClass = "readtxtbox";
                        ((SLPDate)e.Row.FindControl("slpDeliverDate")).ReadOnly = true;

                        ((ASP.itm_slp_slp_sku_vender_ascx)e.Row.FindControl("PUR_SKU")).ReadOnly = true;
                        ((ASP.itm_slp_slp_itemperiod_ascx)e.Row.FindControl("PUR_Period")).ReadOnly = true;
                    }

                    //假如供應商未設定 則明細不可輸入
                    if ((PUR_VendorCode.Text.Trim() == "") || (PUR_VendorCode.TextBox_Name.Text.Trim() == "查無資料"))
                    {
                        ((ASP.itm_slp_slp_sku_vender_ascx)e.Row.FindControl("PUR_SKU")).ReadOnly = true;
                        ((ASP.itm_slp_slp_itemperiod_ascx)e.Row.FindControl("PUR_Period")).ReadOnly = true;
                    }
                    //假如有明細資料了 則供應商不可輸入
                    if (
                         (((ASP.itm_slp_slp_sku_vender_ascx)e.Row.FindControl("PUR_SKU")).Text.Trim() != "") ||
                         (((ASP.itm_slp_slp_itemperiod_ascx)e.Row.FindControl("PUR_Period")).Text.Trim() != "")
                       )
                    {
                        PUR_VendorCode.ReadOnly = true;
                    }
                    else if (DetailHaveData() == true)
                    {
                        PUR_VendorCode.ReadOnly = true;
                    }

                }
                else if (this.hid_PageStatus.Value == "INSERT")
                {
                    ((SLP_SKU_Vender)e.Row.FindControl("PUR_SKU")).ReadOnly = false;
                    ((SLP_ItemPeriod)e.Row.FindControl("PUR_Period")).ReadOnly = false;
                    ((TextBox)e.Row.FindControl("txtMsg")).ReadOnly = false;
                    ((TextBox)e.Row.FindControl("txtMsg")).CssClass = "";

                    ((TextBox)e.Row.FindControl("PurQty")).ReadOnly = false;
                    ((TextBox)e.Row.FindControl("PurQty")).CssClass = "";
                    ((SLPDate)e.Row.FindControl("slpDeliverDate")).ReadOnly = false;


                    //假如供應商未設定 則明細不可輸入
                    if ((PUR_VendorCode.Text.Trim() == "") || (PUR_VendorCode.TextBox_Name.Text.Trim() == "查無資料"))
                    {
                        ((ASP.itm_slp_slp_sku_vender_ascx)e.Row.FindControl("PUR_SKU")).ReadOnly = true;
                        ((ASP.itm_slp_slp_itemperiod_ascx)e.Row.FindControl("PUR_Period")).ReadOnly = true;
                    }
                    //假如有明細資料了 則供應商不可輸入
                    if (
                         (((ASP.itm_slp_slp_sku_vender_ascx)e.Row.FindControl("PUR_SKU")).Text.Trim() != "") ||
                         (((ASP.itm_slp_slp_itemperiod_ascx)e.Row.FindControl("PUR_Period")).Text.Trim() != "")
                       )
                    {
                        PUR_VendorCode.ReadOnly = true;
                    }
                    else if (DetailHaveData() == true)
                    {
                        PUR_VendorCode.ReadOnly = true;
                    }
                }

                //設定TextBox屬性,因用Label於GridView上,取值時,會因其Readlony屬性,導致取值時,皆取到初始值
                TextBox txtPurQty = (TextBox)e.Row.FindControl("PurQty");

                TextBox txtCostUP = (TextBox)e.Row.FindControl("txtCostUP");
                if (txtCostUP.Text.Trim() != "")
                    txtCostUP.Text = double.Parse(txtCostUP.Text).ToString("0.00");
                TextBoxNoBorder(txtCostUP);

                TextBox txtMDC_Qty = (TextBox)e.Row.FindControl("txtMDC_Qty");
                TextBoxNoBorder(txtMDC_Qty);
                TextBox txtCheckQty = (TextBox)e.Row.FindControl("txtCheckQty");
                TextBoxNoBorder(txtCheckQty);

                TextBox txtCostSumy = (TextBox)e.Row.FindControl("txtCostSumy");
                if (txtCostSumy.Text.Trim() != "")
                    txtCostSumy.Text = double.Parse(txtCostSumy.Text).ToString("0.00");
                TextBoxNoBorder(txtCostSumy);

                TextBox txtCloseType = (TextBox)e.Row.FindControl("txtCloseType");
                if (txtCloseType.Text == "A")
                    txtCloseType.Text = "自動";
                else if (txtCloseType.Text == "M")
                    txtCloseType.Text = "手動";

                TextBoxNoBorder(txtCloseType);
                TextBox txtCloseDate = (TextBox)e.Row.FindControl("txtCloseDate");
                TextBoxNoBorder(txtCloseDate);

                if (this.hid_PageStatus.Value != "INSERT")
                { e.Row.Cells[12].Visible = true; }
                else
                { e.Row.Cells[12].Visible = false; }

                Button btnCC = (Button)e.Row.Cells[12].FindControl("btnCloseCase");
                btnCC.CommandArgument = e.Row.RowIndex.ToString();

                #region [刪除]設定
                Button btn_gv_Delete = (Button)e.Row.Cells[13].FindControl("btnDelete");
                btn_gv_Delete.CommandArgument = e.Row.RowIndex.ToString();
                #endregion

                if ((this.hid_PageStatus.Value == "INSERT") || (this.hid_PageStatus.Value == "EDIT"))
                {
                    TextBox txtCT = (TextBox)e.Row.FindControl("txtCloseType");
                    if (txtCT.Text.Trim() == "")
                    {

                        if (((TextBox)((ASP.itm_slp_slp_sku_vender_ascx)e.Row.FindControl("PUR_SKU")).FindControl("TextBoxCode")).ReadOnly == false)
                        {
                            // 離開品名/品號
                            sb1.AppendFormat("SetCheck_1_2(\"{0}\",\"{1}\",\"{2}\",\"{3}\",\"{4}\",\"{5}\",\"{6}\",\"{7}\",\"{8}\",this);\r\n",
                                             ((HiddenField)e.Row.Cells[1].FindControl("HidenID")).ClientID,               //0.GridView 識別行號 ID
                                             ((TextBox)e.Row.Cells[1].Controls[1].FindControl("TextBoxCode")).ClientID,   //1.新值ITEM欄位ClientID
                                             ((HiddenField)e.Row.FindControl("HidenItem")).ClientID,                      //2.隱藏舊值的ITEM欄位ClientID
                                             ((TextBox)e.Row.Cells[2].Controls[1].FindControl("TextBoxCode")).ClientID,   //3.新值Period欄位ClientID  
                                             ((HiddenField)e.Row.Cells[2].FindControl("HidenPeriod")).ClientID,           //4.隱藏舊值的Period欄位ClientID                                                                                              
                                             ((TextBox)this.PUR_PURDate.Controls[1].FindControl("TextBoxCode")).ClientID, //5.採購日期          
                                             "1",                                                                          //6.Click哪個Button
                                             ((TextBox)e.Row.FindControl("PurQty")).ClientID.Replace("PurQty", ""), //7.RowClientID
                                             ((ASP.wui_slp_slp_slpdate_ascx)e.Row.FindControl("slpDeliverDate")).ClientID + "_TextBoxCode" //8.採購日期                                             
                                            );
                            ((TextBox)((ASP.itm_slp_slp_sku_vender_ascx)e.Row.FindControl("PUR_SKU")).FindControl("TextBoxCode")).Attributes["onblur"] = sb1.ToString();
                            ((TextBox)((ASP.itm_slp_slp_sku_vender_ascx)e.Row.FindControl("PUR_SKU")).FindControl("TextBoxCode")).Attributes["onfocus"] += "nowfocus='" + ((TextBox)((ASP.itm_slp_slp_sku_vender_ascx)e.Row.FindControl("PUR_SKU")).FindControl("TextBoxCode")).ClientID + "';";
                            ((TextBox)((ASP.itm_slp_slp_sku_vender_ascx)e.Row.FindControl("PUR_SKU")).FindControl("TextBoxCode")).Attributes["onfocus"] += "document.getElementById('" + this.BtnSave.ClientID + "').disabled=true;";
                        }

                        if (((TextBox)e.Row.Cells[2].Controls[1].FindControl("TextBoxCode")).ReadOnly == false)
                        {
                            //離開期別
                            sb2.AppendFormat("SetCheck_1_2(\"{0}\",\"{1}\",\"{2}\",\"{3}\",\"{4}\",\"{5}\",\"{6}\",\"{7}\",\"{8}\",this);\r\n",
                                              ((HiddenField)e.Row.Cells[1].FindControl("HidenID")).ClientID,               //0.GridView 識別行號 ID
                                              ((TextBox)e.Row.Cells[1].Controls[1].FindControl("TextBoxCode")).ClientID,   //1.新值ITEM欄位ClientID
                                              ((HiddenField)e.Row.FindControl("HidenItem")).ClientID,                      //2.隱藏舊值的ITEM欄位ClientID
                                              ((TextBox)e.Row.Cells[2].Controls[1].FindControl("TextBoxCode")).ClientID,   //3.新值Period欄位ClientID  
                                              ((HiddenField)e.Row.Cells[2].FindControl("HidenPeriod")).ClientID,           //4.隱藏舊值的Period欄位ClientID   
                                              ((TextBox)this.PUR_PURDate.Controls[1].FindControl("TextBoxCode")).ClientID, //5.採購日期                                                            
                                              "2",                                                                         //6.Click哪個Button
                                              ((TextBox)e.Row.FindControl("PurQty")).ClientID.Replace("PurQty", ""), //7.RowClientID
                                              ((ASP.wui_slp_slp_slpdate_ascx)e.Row.FindControl("slpDeliverDate")).ClientID + "_TextBoxCode" //8.採購日期                                              
                                             );
                            ((TextBox)e.Row.Cells[2].Controls[1].FindControl("TextBoxCode")).Attributes["onblur"] = sb2.ToString();
                            ((TextBox)e.Row.Cells[2].Controls[1].FindControl("TextBoxCode")).Attributes["onfocus"] += "nowfocus='" + ((TextBox)e.Row.Cells[2].Controls[1].FindControl("TextBoxCode")).ClientID + "';";
                            ((TextBox)e.Row.Cells[2].Controls[1].FindControl("TextBoxCode")).Attributes["onfocus"] += "ParentSKU('" + ((TextBox)((ASP.itm_slp_slp_sku_vender_ascx)e.Row.FindControl("PUR_SKU")).FindControl("TextBoxCode")).ClientID + "');";
                            ((TextBox)e.Row.Cells[2].Controls[1].FindControl("TextBoxCode")).Attributes["onfocus"] += "document.getElementById('" + this.BtnSave.ClientID + "').disabled=true;";
                            ((Image)e.Row.Cells[2].Controls[1].FindControl("Image1")).Attributes["onmousedown"] += "ParentSKU('" + ((TextBox)((ASP.itm_slp_slp_sku_vender_ascx)e.Row.FindControl("PUR_SKU")).FindControl("TextBoxCode")).ClientID + "');";
                        }

                        //離開採購數量
                        if (((TextBox)e.Row.Cells[6].FindControl("PurQty")).ReadOnly == false)
                        {
                            ((TextBox)e.Row.Cells[6].FindControl("PurQty")).Attributes["onkeypress"] = @"checkKeyPress(this,/^[0-9]+$/);";
                            ((TextBox)e.Row.Cells[6].FindControl("PurQty")).Attributes["onblur"] = "CAL_SUM('" + txtPurQty.ClientID + "','" + txtCostUP.ClientID + "','" + txtCostSumy.ClientID + "');";
                        }


                        //離開交貨日期
                        //修改贈品的交貨日期等於明細的交貨日期 
                        if (((TextBox)e.Row.Cells[7].Controls[1].FindControl("TextBoxCode")).ReadOnly == false)
                        {
                            ((TextBox)e.Row.Cells[7].Controls[1].FindControl("TextBoxCode")).Attributes["onfocus"] = "document.getElementById('" + this.BtnSave.ClientID + "').disabled=true;";
                            ((TextBox)e.Row.Cells[7].Controls[1].FindControl("TextBoxCode")).Attributes["onblur"] = "Enable_Progress();window.setTimeout(\"$get('ctl00_CPH_BtnRsfresh_Gift').click();\",1);";
                        }

                        //限制欄位最多只能輸入60個字元
                        string strMaxLength = "60";
                        TextBox txtMsg = (TextBox)e.Row.FindControl("txtMsg");
                        txtMsg.Attributes["onkeypress"] += String.Format(@"return limit_length({0},{1});", txtMsg.ClientID, strMaxLength);
                        txtMsg.Attributes["onblur"] += "limit_lengths('" + txtMsg.ClientID + "','" + strMaxLength + "');";

                    }
                }
                break;

            default:
                break;
        }
    }
Пример #12
0
 //更新明細內本月驗收合計
 private void UpdateDetail_AcceptQty()
 {
     DataTable dtDetail = (DataTable)Session["PUR02_DTL_" + PageTimeStamp.Value];
     ArrayList ParameterList = new ArrayList();
     MaintainPurchaseOrder bco = new MaintainPurchaseOrder(ConntionDB);
     for (int i = 0; i < dtDetail.Rows.Count; i++)
     {
         ParameterList.Clear();
         ParameterList.Add(dtDetail.Rows[i]["ITEM"].ToString());
         ParameterList.Add(dtDetail.Rows[i]["PERIOD"].ToString());
         ParameterList.Add(PUR_PURDate.Text);
         int iAcceptQty = bco.Get_AcceptQty(ParameterList);
         dtDetail.Rows[i]["ACCEPT_ACCQTY"] = iAcceptQty.ToString();
     }
     dtDetail.AcceptChanges();
     Session["PUR02_DTL_" + PageTimeStamp.Value] = dtDetail;
 }
Пример #13
0
    protected void BtnQuery_Click(object sender, EventArgs e)
    {
        try
        {
            ErrorMsgLabel.Text = "";
            ResultMsgLabel.Text = "";
            IsCheckOK = true;
            DataTable Dt = new DataTable();

            // 清空靜態變數 與 檢查各查詢參數是否正確   
            string strWhere = "";
            strWhere = this.getQuerySqlStatement();

            if (IsCheckOK)
            {
                MaintainPurchaseOrder bco = new MaintainPurchaseOrder(ConntionDB);
                ParameterList.Clear();
                ParameterList.Add(strWhere);
                ParameterList.Add(TextBoxRowCountLimit.Text.Trim());
                Dt = bco.QuerySwitch(PURModel.PURCommon.QueryType.Where1, ParameterList);

                if (Dt == null || (Dt != null && Dt.Rows.Count <= 0))
                {
                    ResultMsgLabel.Text = "查無資料";
                }
                else
                {
                    dt_Detail = Dt;
                }

                // 設定頁面狀態
                this.hid_PageStatus.Value = "QUERY";
                this.txt_PageStatus.Text = "QUERY";

                // 設定查詢結果
                this.gv_Detail.DataSource = Dt;
                this.gv_Detail.PageSize = (TextBoxPagesize.Text == "") ? 10 : (int.Parse(TextBoxPagesize.Text) < 0) ? 10 : int.Parse(TextBoxPagesize.Text);
                this.gv_Detail.PageIndex = 0;

                if (Dt.Rows.Count > 0)
                    Set_SessionNo(dt_Detail.DefaultView);
                else
                    Session["PUR02_SortKey" + PageTimeStamp.Value] = null;
            }
            else
            {
                this.gv_Detail.DataSource = null;
            }
            this.gv_Detail.DataBind();

        }
        catch (Exception ex)
        { this.ErrorMsgLabel.Text = ex.ToString(); }
        finally { }

    }
Пример #14
0
    // 整張結案 
    protected void BtnCloseCase_Click(object sender, EventArgs e)
    {
        try
        {
            //判斷採購單的採購日是否己日結
            //VGIModel.CheckVendorAccountClose dbo = new PIC.VDS2G.LGT.VGI.CheckVendorAccountClose(ConntionDB);
            //string IsClosed = dbo.CheckVendorCloseStaus(DateTime.Parse(this.PUR_PURDate.Text).ToString("yyyyMMdd"));
            //if (IsClosed == "1")
            //{
            //    ErrorMsgLabel.Text = "該採購單日已日結,不可進行結案!!";
            //    return;
            //}
            //else
            //{
            MaintainPurchaseOrder bco = new MaintainPurchaseOrder(ConntionDB);
            DataTable MasterOldDt = (DataTable)ViewState["MasterOLDData"];

            ParameterList.Clear();
            ParameterList.Add(Session["UID"].ToString());
            ParameterList.Add(75);

            //做資料儲存的動作
            bco.ClosePurchaseOrder(ParameterList, MasterOldDt.Rows[0], null);

            //存檔後資料重新讀取
            //this.databind();

            //#region 存檔後狀態設定
            //this.hid_PageStatus.Value = "VIEW";
            //this.txt_PageStatus.Text = "VIEW";
            //#endregion

            //SetPageStatus();

            Response.Redirect("PUR022.aspx?PURCHASE_NO=" + MasterOldDt.Rows[0]["PURCHASE_NO"].ToString().Trim() + "&SSID=" + ViewState["SSID"].ToString() + "&mode=VIEW&Code=PUR02", false);
            //}
        }
        catch (Exception ex)
        {
            this.ErrorMsgLabel.Text = ex.Message;
        }
        finally
        {

        }
    }
Пример #15
0
    // 繫結資料 Detail
    private void databind_Detail()
    {
        #region
        try
        {
            ErrorMsgLabel.Text = "";
            MaintainPurchaseOrder bco = new MaintainPurchaseOrder(ConntionDB);
            ParameterList.Clear();
            ParameterList.Add(this.hiddenPurchaseNo.Value);
            DataTable Dt = bco.GetItemsByPurchase_No(ParameterList);//取正常品Detail資料
            DataTable DtAll = bco.GetAllItemsByPurchase_No(ParameterList);//取正常品與贈品資料

            //將明細資料放至DetailDt中
            Session["PUR02_DTL_" + PageTimeStamp.Value] = Dt;

            ViewState["DetailOLDData"] = ChangeNullValues(Dt);
            ViewState["AllDetailOLDData"] = ChangeNullValues(DtAll);

            this.setGV_Detail(-1, Dt, false);
        }
        catch (Exception ex)
        {
            ErrorMsgLabel.Text = ex.Message;
        }
        #endregion
    }
Пример #16
0
    //刪除主檔 事件
    protected void BtnDelMain_Click(object sender, EventArgs e)
    {
        ErrorMsgLabel.Text = "";
        if (this.hid_PageStatus.Value == "VIEW")
        {
            try
            {
                if (this.hiddenIsClose.Value == "1")
                {
                    //判斷採購單是否有"在途單"內
                    MaintainPurchaseOrder bco = new MaintainPurchaseOrder(ConntionDB);
                    bool IsOK = bco.CheckPurchaseIsOnWay(this.tbxPUR_No.Text);

                    if (IsOK)
                    {
                        this.hid_PageStatus.Value = "VIEW";
                        this.txt_PageStatus.Text = "VIEW";
                        ErrorMsgLabel.Text = "該採購單有在途單,不可進行刪除!!";
                    }
                    else
                    {
                        //如驗收單已有資料時,不得刪除資料。
                        bool IsAcceptOK = bco.CheckPurchaseIsACCEPT(this.tbxPUR_No.Text);
                        if (IsAcceptOK)
                        {
                            this.hid_PageStatus.Value = "VIEW";
                            this.txt_PageStatus.Text = "VIEW";
                            ErrorMsgLabel.Text = "該採購單已有驗收單資料,不可進行刪除!!";
                        }
                        else
                        {
                            ////判斷採購單的採購日是否己日結
                            //VGIModel.CheckVendorAccountClose dbo = new PIC.VDS2G.LGT.VGI.CheckVendorAccountClose(ConntionDB);
                            //string IsClosed = dbo.CheckVendorCloseStaus(DateTime.Parse(this.PUR_PURDate.Text).ToString("yyyyMMdd"));
                            //if (IsClosed == "1")
                            //{
                            //    ErrorMsgLabel.Text = "該採購單日已日結,不可進行修改!!";
                            //}
                            //else
                            //{
                            DataTable dtMasterOLD = (DataTable)ViewState["MasterOLDData"];
                            DataTable dtDetailOLD = (DataTable)ViewState["DetailOLDData"];
                            DataTable dtGiftOLD = (DataTable)ViewState["GiftOLDData"];

                            #region 刪除主檔時,相關動作
                            bco.DeteleMain_DetailData(this.tbxPUR_No.Text, Session["UID"].ToString(), null);
                            ShowErrorMessage("刪除完成!!");
                            Response.Redirect("PUR021.aspx?Code=PUR02");
                            #endregion
                            //}
                        }
                    }
                }
                else
                {
                    ShowErrorMessage("該採購單已結案,不可刪除!!");
                }
            }
            catch (Exception ex)
            {
                this.ErrorMsgLabel.Text = ex.Message;
            }
            finally
            {

            }
        }
    }
Пример #17
0
    // 繫結資料 Gift
    private void databind_Gift()
    {
        #region
        try
        {
            ErrorMsgLabel.Text = "";
            MaintainPurchaseOrder bco = new MaintainPurchaseOrder(ConntionDB);
            ParameterList.Clear();
            ParameterList.Add(this.hiddenPurchaseNo.Value);
            DataTable Dt = bco.GetItemGiftByPurchase_No(ParameterList);

            //將明細贈品資料放至Gift中
            Session["PUR02_Gift_" + PageTimeStamp.Value] = Dt;
            ViewState["GiftOLDData"] = ChangeNullValues(Dt);
            this.setGV_Gift(-1, Dt, false);
        }
        catch (Exception ex)
        {
            ErrorMsgLabel.Text = ex.Message;
        }
        #endregion
    }
Пример #18
0
    /// <summary>
    /// Page_Load事件
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            ErrorMsgLabel.Text = "";
            ResultMsgLabel.Text = "";
            AuthorityControls(this);

            if (!IsPostBack)
            {
                //寫入首次載入Page TimeStamp
                PageTimeStamp.Value = string.Format("{0}{1}{2}{3}{4}{5}",
                                                    DateTime.Now.Year.ToString(),
                                                    DateTime.Now.Month.ToString().PadLeft(2, '0'),
                                                    DateTime.Now.Day.ToString().PadLeft(2, '0'),
                                                    DateTime.Now.Hour.ToString().PadLeft(2, '0'),
                                                    DateTime.Now.Minute.ToString().PadLeft(2, '0'),
                                                    DateTime.Now.Second.ToString().PadLeft(2, '0')
                                                    );
                //設定GridView預設的狀態
                Initialization_Component();
                ViewState["PageIndex_Detail"] = 0;
                ViewState["PageIndex_Gift"] = 0;
                #region 設定 Page_Status 狀態
                //該頁面共有3種狀態
                //檢視 VIEW
                //編輯 EDIT
                //新增 INSERT
                //模式指定
                string mode = "VIEW";
                if (!string.IsNullOrEmpty(Request.QueryString["mode"]))
                {
                    mode = Request.QueryString["mode"].ToString().ToUpper();
                }

                ViewState["SSID"] = "";
                if (Session[Request.QueryString["SSID"]] != null)
                {
                    ViewState["SSID"] = Request.QueryString["SSID"];
                    IDCollection = (StringCollection)Session[ViewState["SSID"].ToString()];
                }

                this.hid_PageStatus.Value = mode;
                this.txt_PageStatus.Text = mode;

                if ((mode == "VIEW") || (mode == "EDIT"))
                {
                    string strPURCHASE_NO = string.Empty;
                    if (!string.IsNullOrEmpty(Request.QueryString["PURCHASE_NO"]))
                    {
                        strPURCHASE_NO = Request.QueryString["PURCHASE_NO"].ToString();
                        ViewState["PURCHASE_NO"] = strPURCHASE_NO;
                    }

                    DataTable dtMain = Get_MainData(strPURCHASE_NO);
                    if (dtMain.Rows.Count > 0)
                    {
                        this.hiddenPurchaseNo.Value = strPURCHASE_NO;
                        this.hiddenIsClose.Value = dtMain.Rows[0]["IS_CLOSE"].ToString();
                        this.hiddenIsAccept.Value = dtMain.Rows[0]["IS_AP"].ToString();
                    }
                    else
                    {
                        this.hiddenPurchaseNo.Value = "";
                        this.hiddenIsClose.Value = "";
                        this.hiddenIsAccept.Value = "";
                    }
                    Session["PUR02_DTL_" + PageTimeStamp.Value] = null;
                    if (mode == "VIEW")
                    {
                        lblStar1.Visible = false;
                        lblStar2.Visible = false;
                        lblStar3.Visible = false;
                    }
                    if (mode == "EDIT")
                    {
                        lblStar1.Visible = true;
                        lblStar2.Visible = true;
                        lblStar3.Visible = true;
                    }
                }
                else if (mode == "INSERT")
                {
                    PUR_PurUser.Text = Session["UID"].ToString();
                    MaintainPurchaseOrder bco = new MaintainPurchaseOrder(ConntionDB);
                    for (int i = 0; i < 5; i++)
                    {
                        DataTable DetailDt = (DataTable)Session["PUR02_DTL_" + PageTimeStamp.Value];
                        if (DetailDt == null)
                            DetailDt = bco.QueryItemSchema();

                        DataTable dtTmp = new DataTable();
                        dtTmp = bco.QueryItemSchema();
                        addRow(ref dtTmp, i + 1);
                        DetailDt.Merge(dtTmp);

                        Session["PUR02_DTL_" + PageTimeStamp.Value] = DetailDt;
                        gv_Detail.DataSource = DetailDt;
                        gv_Detail.PageIndex = 0;
                    }
                    gv_Detail.DataBind();

                    lblStar1.Visible = true;
                    lblStar2.Visible = true;
                    lblStar3.Visible = true;
                }
                #endregion

                SetPageStatus();//設定各種模式預設值                
            }
            else
            {
                ViewState["NoRefreshItem"] = "0";
                //UnSetClinetFocus();
            }
        }
        catch (Exception ex)
        {
            ErrorMsgLabel.Text = ex.Message;
        }
        finally
        {
            ToolBarInit();
            this.panel_sku_parent.Attributes.Add("style", "display:none");
        }
    }
Пример #19
0
    public void GetVendorData(string strVendor)
    {
        if (strVendor != "")
        {
            MaintainPurchaseOrder bco = new MaintainPurchaseOrder(ConntionDB);
            ParameterList.Clear();
            ParameterList.Add(strVendor);
            DataTable Dt = bco.GetVendorDataByVendorNo(ParameterList);

            if (Dt.Rows.Count > 0)
            {
                tbxContactUser.Text = Dt.Rows[0]["BUSINESS_CONTACT"].ToString();
                SLP_Area.Text = Dt.Rows[0]["INV_TEL_AREA"].ToString();
                SLP_Tel.Text = Dt.Rows[0]["INV_TEL"].ToString();
            }
            else
            {
                tbxContactUser.Text = "";
                SLP_Area.Text = "";
                SLP_Tel.Text = "";
            }
        }
        else
        {
            tbxContactUser.Text = "";
            SLP_Area.Text = "";
            SLP_Tel.Text = "";
        }
    }
Пример #20
0
    private bool CheckPeriodExist(string strItem, string strPeriod)
    {
        bool bResult = false;//true:存在 false:不存在

        MaintainPurchaseOrder BCO = new MaintainPurchaseOrder(ConntionDB);
        ParameterList.Clear();
        ParameterList.Add(strItem);
        ParameterList.Add(strPeriod);
        DataTable dt = BCO.QueryPeriod(ParameterList);
        if (dt.Rows.Count > 0)
        {
            bResult = true;
        }
        return bResult;
    }
Пример #21
0
    //離開品號或期別的時候,去資料庫內讀取符合條件的相關資料
    public static string AddNewToSession(string sItem, string sPeriod, string sDate, string sPageTimeStamp, string sID)
    {
        String rtnValue = "";
        ArrayList ParameterList = new ArrayList();

        PUR_PUR022 PUR022 = new PUR_PUR022();
        DataTable dtDetail = (DataTable)PUR022.Session["PUR02_DTL_" + sPageTimeStamp];

        string DeatilData = string.Empty;
        if (sDate.Trim() != "")
        {
            MaintainPurchaseOrder bco = new MaintainPurchaseOrder(ConntionDB);
            ParameterList.Clear();
            ParameterList.Add(sItem);
            ParameterList.Add(sPeriod);
            ParameterList.Add(DateTime.Parse(sDate.Trim()).ToString("yyyy/MM/dd"));

            DateTime DT = DateTime.ParseExact(DateTime.Parse(sDate.Trim()).ToString("yyyy/MM/dd"), "yyyy/MM/dd", null);
            DateTime DT2 = DT.AddMonths(-1);
            string sDT = DT2.ToString("yyyy/MM");
            sDT = sDT + "/26";
            ParameterList.Add(DateTime.Parse(sDT.Trim()).ToString("yyyy/MM/dd"));

            DeatilData = bco.GetDetail_Data(ParameterList);
        }

        //找出新增或修改的筆數資料,將其輸入的值放到Session內
        DataRow[] FindRows = dtDetail.Select("ID='" + sID + "'");
        if (DeatilData != "")
        {
            string[] DetailAry;
            DetailAry = DeatilData.Split(new Char[] { ';' });
            FindRows[0]["ITEM"] = sItem;
            FindRows[0]["PERIOD"] = sPeriod;
            FindRows[0]["COST"] = DetailAry[2].ToString();
            FindRows[0]["MDC_QTY"] = DetailAry[3].ToString();
            FindRows[0]["ACCEPT_ACCQTY"] = DetailAry[4].ToString();
            FindRows[0]["PURCHASE_QTY"] = "0";
            FindRows[0]["PLAN_ACCEPT_DATE"] = DetailAry[5].ToString();
            FindRows[0]["SUMY_COST"] = "0.00";
            FindRows[0]["MSG"] = DetailAry[6].ToString();
            FindRows[0]["STATUS"] = "FIRST";
            rtnValue = "NEW";
        }
        else
        {
            FindRows[0]["ITEM"] = sItem;
            FindRows[0]["PERIOD"] = sPeriod;
            FindRows[0]["COST"] = "0";
            FindRows[0]["MDC_QTY"] = "0";
            FindRows[0]["ACCEPT_ACCQTY"] = "0";
            FindRows[0]["PURCHASE_QTY"] = "0";
            FindRows[0]["PLAN_ACCEPT_DATE"] = "";
            FindRows[0]["SUMY_COST"] = "0.00";
            FindRows[0]["MSG"] = "";
            rtnValue = "NEW_NOREF";
        }
        rtnValue = rtnValue + "<partition>" + decimal.Parse(FindRows[0]["COST"].ToString()).ToString("0.00") + "<partition>" + FindRows[0]["ACCEPT_ACCQTY"].ToString() + "<partition>" + FindRows[0]["MDC_QTY"].ToString() + "<partition>" + FindRows[0]["PLAN_ACCEPT_DATE"].ToString() + "<partition>" + FindRows[0]["MSG"].ToString();
        PUR022.Session["PUR02_DTL_" + sPageTimeStamp] = dtDetail;

        return rtnValue;
    }
Пример #22
0
        /// <summary>
        ///1.目的:將暫存檔中的待處理資料,匯入正式表單

        ///2.傳入參數:@處理檔名、@使用者
        ///  回傳參數:@處理筆數、@正確筆數、@錯誤筆數、@錯誤訊息

        ///3.處理表格:VDS_PUR_PURCHASEORDER_TMP(T)、VDS_PUR_PURCHASE_MAIN(M)、VDS_PUR_PURCHASE_ITEM(D)

        ///4.將暫存檔中的[狀態]欄位調整為2:TMP TO DB

        ///5.匯入處理完成後,回傳匯入處理結果:處理總筆數、成功筆數、失敗筆數、@錯誤訊息(成功時=null)
        /// </summary>
        public ArrayList TmpToDB(string s_LoginUser,string MAIL_ADDR, string ConnectionDB)
        {
            #region
            ArrayList arl_Return = new ArrayList();

            try
            {
                string strPURCHASE_NO = string.Empty;
                ParameterList.Clear();
                ParameterList.Add(s_LoginUser);
                ParameterList.Add(MAIL_ADDR);
                int iResult = TMP_To_Purchase_Order(ParameterList, out strPURCHASE_NO, null);

                PUR_PurchaseOrderDBO dbo = new PUR_PurchaseOrderDBO(ref USEDB);
                ParameterList.Clear();
                ParameterList.Add(strPURCHASE_NO);
                DataTable dtPur = dbo.doQueryPurData(ParameterList); ;

                MaintainPurchaseOrder po = new MaintainPurchaseOrder(ConnectionDB);
                #region 更新期別屬性檔&圖書採購卡或雜誌採購卡採購單號
                DataRow[] DetailRows = dtPur.Select("ITEM=VIRTUAL_CODE");
                foreach (DataRow dRow in DetailRows)
                {
                    //更新期別屬性檔(VDS_ITM_PERIOD_PROFILE)中,該品號期別的交貨日期、採購日、採購量與採購單號
                    po.UpdatePeriodProfile(dRow["ITEM"].ToString().Trim(),
                                           dRow["PERIOD"].ToString().Trim(),
                                           dRow["PLAN_ACCEPT_DATE"].ToString().Trim(),
                                           dRow["PURCHSE_DATE"].ToString().Trim(),
                                           dRow["PURCHASE_QTY"].ToString().Trim(),
                                           dRow["PURCHASE_NO"].ToString().Trim(),
                                           s_LoginUser,
                                           null);

                    //更新圖書採購卡或雜誌採購卡採購單號
                    if (dRow["PERIOD"].ToString().Trim() == "000000") //在圖書裡其period值絕對是000000
                    {
                        po.Update_B_PURCARD(dRow["PURCHASE_NO"].ToString().Trim(),
                                            dRow["ITEM"].ToString().Trim(),
                                            s_LoginUser,
                                            null);
                    }
                    else
                    {
                        po.Update_PURCARD(dRow["PURCHASE_NO"].ToString().Trim(),
                                          dRow["ITEM"].ToString().Trim(),
                                          dRow["PERIOD"].ToString().Trim(),
                                          s_LoginUser,
                                          null);
                    }
                }
                #endregion

                #region 更新贈品屬性檔
                DataRow[] GiftRows = dtPur.Select("ITEM<>VIRTUAL_CODE");
                foreach (DataRow gRow in GiftRows)
                {
                    //更新贈品屬性檔(VDS_MKT_GIFT_PROFILE)資料中,該品號期別的交貨日期、採購日、採購量與採購單號
                    po.UpdateGiftProfile(gRow["ITEM"].ToString().Trim(),
                                         gRow["PERIOD"].ToString().Trim(),
                                         gRow["VIRTUAL_CODE"].ToString().Trim(),
                                         gRow["PLAN_ACCEPT_DATE"].ToString().Trim(),
                                         gRow["PURCHSE_DATE"].ToString().Trim(),
                                         gRow["PURCHASE_QTY"].ToString().Trim(),
                                         gRow["PURCHASE_NO"].ToString().Trim(),
                                         s_LoginUser,
                                         null);
                }
                #endregion


                if (iResult > 0)
                {
                    arl_Return.Add("TEMPTODB 正確");
                    arl_Return.Add(iResult);
                    arl_Return.Add(iResult);
                    arl_Return.Add(0);
                }
            }
            catch (Exception ex)
            {
                arl_Return.Add("程式錯誤");
                arl_Return.Add(ex.Message);
            }
            finally
            { }

            return arl_Return;
            #endregion
        }
Пример #23
0
    private static int CheckItemDate(string sItem)
    {
        int iResult = -2; //-2:無資料 -1:過期 0:正常
        MaintainPurchaseOrder BCO = new MaintainPurchaseOrder(ConntionDB);
        ParameterList.Clear();
        ParameterList.Add(sItem);
        DataTable dt = BCO.QueryItem(ParameterList);

        if (dt.Rows.Count > 0)
        {
            string strNowDate = DateTime.Now.ToString("yyyy/MM/dd");
            if (string.Compare(dt.Rows[0]["mdc_end_date"].ToString(), strNowDate) < 0)
            {
                iResult = -1;
            }
            else
            {
                iResult = 0;
            }
        }
        return iResult;
    }
Пример #24
0
        public string CreateData(string strUID, string strDate, DataTable dtData)
        {
            Int32 PID = 0;
            string[] sID_NO;
            string vID_NO;
            string sTemp = "";
            string sPurchaseNo = "";
            string strResult = string.Empty;
            try
            {
                ArrayList ParameterList = new ArrayList();
                //獨立呼叫啟動Transcation
                Conn = USEDB.CreateConnection();
                Conn.Open();
                DBT = Conn.BeginTransaction();

                MaintainPurchaseOrder PUR02_BCO = new MaintainPurchaseOrder(strConn);

                DataTable dtMANUFACTURE = dtData.DefaultView.ToTable(true, new string[] { "MANUFACTURE" });

                for (int i = 0; i < dtMANUFACTURE.Rows.Count; i++)
                {
                    ParameterList.Clear();
                    ParameterList.Add(strDate);  //0.採購單日期
                    ParameterList.Add(strUID);   //1.採購人員
                    ParameterList.Add(dtMANUFACTURE.Rows[i]["MANUFACTURE"].ToString());  //2.廠商編號
                    ParameterList.Add("25");    //3.CloseCase
                    ParameterList.Add(strUID);  //4.UID 

                    //寫入 Master Table
                    vID_NO = PUR02_BCO.CreatePurchaseOrder(ParameterList, DBT);
                    sID_NO = vID_NO.Split(new Char[] { ';' });
                    PID = int.Parse(sID_NO[0].ToString());
                    sPurchaseNo = sID_NO[1].ToString();
                    strResult += sPurchaseNo + ";";

                    ParameterList.Add(sPurchaseNo);
                    ParameterList.Add(PID);

                    DataTable DetailData = FilterDetail(dtData, dtMANUFACTURE.Rows[i]["MANUFACTURE"].ToString());

                    #region 新增明細資料與更新 VDS_MKT_PURCARD_MAIN.PUR_NO(雜誌採購卡) 或 VDS_MKT_BPURCARD_MAIN.PUR_NO(圖書採購卡)
                    foreach (DataRow dRow in DetailData.Rows)
                    {
                        PUR02_BCO.CreatePurchaseOrderDetail(PID, ParameterList, dRow, DBT);

                        //更新期別屬性檔(VDS_ITM_PERIOD_PROFILE)中,該品號期別的交貨日期、採購日、採購量與採購單號
                        PUR02_BCO.UpdatePeriodProfile(dRow["ITEM"].ToString().Trim(),
                                                      dRow["PERIOD"].ToString().Trim(),
                                                      dRow["PLAN_ACCEPT_DATE"].ToString().Trim(),
                                                      ParameterList[0].ToString().Trim(),
                                                      dRow["PURCHASE_QTY"].ToString().Trim(),
                                                      sPurchaseNo,
                                                      ParameterList[4].ToString().Trim(),
                                                      DBT);

                        //更新圖書採購卡或雜誌採購卡採購單號
                        if (dRow["PERIOD"].ToString().Trim() == "000000") //在圖書裡其period值絕對是000000
                        {
                            PUR02_BCO.Update_B_PURCARD(sPurchaseNo,
                                                       dRow["ITEM"].ToString().Trim(),
                                                       ParameterList[4].ToString().Trim(),
                                                       DBT);
                        }
                        else
                        {
                            PUR02_BCO.Update_PURCARD(sPurchaseNo,
                                                     dRow["ITEM"].ToString().Trim(),
                                                     dRow["PERIOD"].ToString().Trim(),
                                                     ParameterList[4].ToString().Trim(),
                                                     DBT);
                        }
                    }
                    #endregion

                    DataTable GiftData = Add_Gift(DetailData);
                    #region 新增明細贈品資料
                    if (GiftData != null)
                    {
                        foreach (DataRow gRow in GiftData.Rows)
                        {
                            PUR02_BCO.CreatePurchaseOrderDetail(PID, ParameterList, gRow, DBT);

                            //更新贈品屬性檔(VDS_MKT_GIFT_PROFILE)資料中,該品號期別的交貨日期、採購日、採購量與採購單號
                            PUR02_BCO.UpdateGiftProfile(gRow["ITEM"].ToString().Trim(),
                                                        gRow["PERIOD"].ToString().Trim(),
                                                        gRow["VIRTUAL_CODE"].ToString().Trim(),
                                                        gRow["PLAN_ACCEPT_DATE"].ToString().Trim(),
                                                        ParameterList[0].ToString().Trim(),
                                                        gRow["PURCHASE_QTY"].ToString().Trim(),
                                                        sPurchaseNo,
                                                        ParameterList[4].ToString().Trim(),
                                                        DBT);
                        }
                    }
                    #endregion
                }
                DBT.Commit();
            }
            catch (Exception ex)
            {
                if (DBT != null)
                    DBT.Rollback();
                throw ex;
            }
            finally
            {
                //獨立呼叫Transcation,關閉連線
                if (Conn.State == ConnectionState.Connecting)
                    Conn.Close();
            }
            return strResult;
        }
Пример #25
0
    //加入符合此品號/期別的贈品資料
    public static string Add_Gift(string sItem, string sPeriod, string sPageTimeStamp)
    {
        String rtnValue = "";

        if (sItem != "" && sPeriod != "")
        {
            PUR_PUR022 PUR022 = new PUR_PUR022();
            DataTable dtGift = (DataTable)PUR022.Session["PUR02_Gift_" + sPageTimeStamp];
            DataTable dtDetail = (DataTable)PUR022.Session["PUR02_DTL_" + sPageTimeStamp];

            if (dtGift == null)
            {
                MaintainPurchaseOrder bco = new MaintainPurchaseOrder(ConntionDB);
                dtGift = bco.QueryGiftSchema();
            }

            MaintainGift Gbco = new MaintainGift(ConntionDB);
            ParameterList.Clear();
            ParameterList.Add(sItem);
            ParameterList.Add(sPeriod);
            ParameterList.Add(-1);
            DataTable dtTmp = Gbco.QueryGift(ParameterList);
            int iAddRow = 0;
            if (dtTmp != null && dtTmp.Rows.Count > 0)
            {
                for (int i = 0; i < dtTmp.Rows.Count; i++)
                {
                    if (dtTmp.Rows[i]["ID"].ToString() != "0")
                    {
                        DataRow dr = dtGift.NewRow();
                        dr["ID"] = 1 + i;
                        dr["ITEM"] = sItem;
                        dr["PERIOD"] = sPeriod;
                        dr["VIRTUAL_CODE"] = dtTmp.Rows[i]["VIRTUAL_CODE"].ToString();
                        dr["VIRTUAL_NAME"] = dtTmp.Rows[i]["VIRTUAL_NAME"].ToString();
                        dr["PURCHASE_QTY"] = dtTmp.Rows[i]["PLAN_QTY"].ToString();
                        string strDate = string.Empty;
                        if (dtDetail != null)
                        {
                            DataRow[] FindRows = dtDetail.Select("ITEM='" + sItem + "' And PERIOD='" + sPeriod + "'");
                            if (FindRows.Length > 0)
                            {
                                strDate = FindRows[0]["PLAN_ACCEPT_DATE"].ToString();
                            }
                        }
                        dr["PLAN_ACCEPT_DATE"] = strDate;
                        dr["COST"] = 0;
                        dr["MDC_QTY"] = 0;
                        dr["ACCEPT_ACCQTY"] = 0;
                        dr["MSG"] = "";
                        dtGift.Rows.Add(dr);
                        iAddRow++;
                    }
                }
                if (iAddRow > 0)
                    PUR022.Session["PUR02_Gift_" + sPageTimeStamp] = dtGift;
            }
        }
        return rtnValue;
    }
Пример #26
0
    protected int QueryPurchaseMain()
    {
        MaintainPurchaseOrder BCO = new MaintainPurchaseOrder(ConntionDB);

        ParameterList.Clear();

        ParameterList.Add(txtPURCHASE_NO.Text.Trim());

        DataTable dt = BCO.QuerySwitch(PURCommon.QueryType.PK, ParameterList);

        //iResult 0:查無資料 1:有資料但全部結案 2:有資料(可能包含部分結案)

        SLP_VendorBase1.Text = "";
        txtStatus.Text = ""; //此欄位是在途單的狀態 非採購單的狀態

        int iResult = 2;
        if (dt.Rows.Count == 0)
        {
            iResult = 0;
        }
        else
        {
            SLP_VendorBase1.Text = dt.Rows[0]["VENDOR"].ToString().Trim();
            if (dt.Rows[0]["STATUS"].ToString().Trim() == "75")
            {
                iResult = 1;
            }
        }
        return iResult;
    }
Пример #27
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="ParameterList">0.V_UID.1.V_UpdateDate,2.V_AcceptNo,3.V_AcceptDate4.V_PurchaseNo,5.V_WayBillNo,6.V_InvoiceNo,7.V_TaxAmt,8.V_UtaxAmt,9.V_Tax,10.out V_ID,11.out V_Result,12. out V_Err_Msg</param>
        /// <param name="dtDetls"></param>
        /// <param name="dtGifts"></param>
        /// <param name="RootDBT"></param>
        /// <param name="AcceptNo"></param>
        /// <param name="Statue"></param>
        /// <param name="ErrorItem"></param>
        /// <returns></returns>
        public bool UpdateAccept(ArrayList ParameterList, DataTable dtDetls, DataTable dtGifts, DbTransaction RootDBT, out string Statue, out string ErrorItem, out string ErrMsg)
        {
            bool IsRootTranscation = false;

            //檢查商品和贈品是不是都驗收了,未驗收結案才能繼續
            ErrorItem = string.Empty;
            Statue = string.Empty;

            int ID = -1;
            int PID = -1;
            string Result = "";

            try
            {
                string UserID = ParameterList[0].ToString();
                string UpdateDate = ParameterList[1].ToString();
                string AcceptNo = ParameterList[2].ToString();
                string AcceptDate = ParameterList[3].ToString();
                string PurchaseNo = ParameterList[4].ToString();
                string WaybillNo = ParameterList[5].ToString();
                string InvoiceNo = ParameterList[6].ToString();
                string TaxAmt = ParameterList[7].ToString();
                string UtaxAmt = ParameterList[8].ToString();
                string Tax = ParameterList[9].ToString();

                DBO.MaintainAcceptDBO VGIDBO = new DBO.MaintainAcceptDBO(ref USEDB);
                DBO.MaintainAcceptQualityCheck VGIQC = new DBO.MaintainAcceptQualityCheck(strConn);
                PURDBO.MaintainGoodsInTransit PURDB = new PURDBO.MaintainGoodsInTransit(strConn);
                IVMDBO.MaintainStockInOut IVMDB = new IVMDBO.MaintainStockInOut(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

                //更新主檔
                ArrayList InsertParameter = new ArrayList();
                InsertParameter.Clear();
                InsertParameter.Add(UserID);//0
                InsertParameter.Add(UpdateDate);//1
                InsertParameter.Add(AcceptNo);//2
                InsertParameter.Add(PurchaseNo);//3
                InsertParameter.Add(WaybillNo);//4
                InsertParameter.Add(InvoiceNo);//5
                InsertParameter.Add(TaxAmt);//6
                InsertParameter.Add(UtaxAmt);//7
                InsertParameter.Add(Tax);//8
                InsertParameter.Add(ParameterList[10]);//9 OLD UPDATEDATE 
                InsertParameter.Add(ParameterList[11]);//10 OLD UPDATEUID

                VGIDBO.UpdateAcceptMain(InsertParameter, DBT, out ID, out Result, out ErrMsg);

                if (Result == "0")
                {
                    return false;
                }

                //新增明細

                DataTable dtStockIn = new DataTable();
                dtStockIn.Columns.Add("LocateNo");
                dtStockIn.Columns.Add("LocateSec");
                dtStockIn.Columns.Add("Item");
                dtStockIn.Columns.Add("Period");
                dtStockIn.Columns.Add("Old_Qty");
                dtStockIn.Columns.Add("New_Qty");

                //取得入庫暫存儲區、儲格
                string LocateNo = "";
                string LocateSec = "";

                LocateSec = VGIDBO.GetStockInTempLocateSec();

                if (LocateSec == string.Empty)
                {
                    throw new Exception("無法取得入庫暫存儲區或儲位");
                }
                else
                {
                    LocateNo = LocateSec.Substring(0, 1);
                }

                #region 商品明細
                //barcode
                //item
                //period
                //purchase_Qty
                //In_Date
                //TAcc_Qty
                //Acc_Qty
                //Cost
                //Price
                //Package_Unit
                //S_Weight
                //S_Length
                //S_Width
                //S_Height
                //P_Weight
                //P_Length
                //P_Width
                //P_Height
                //Product_Source
                //Produce_Date
                //Reserved_Period
                //Valid_Date
                //AllowAccept_Date
                //Old_Qty
                //RowState

                for (int i = 0; i < dtDetls.Rows.Count; i++)
                {
                    int DetlID = -1;

                    string Barcode = dtDetls.Rows[i]["barcode"].ToString();
                    string Item = dtDetls.Rows[i]["item"].ToString();
                    string Period = dtDetls.Rows[i]["period"].ToString();
                    string In_Date = dtDetls.Rows[i]["In_Date"].ToString();
                    string PurchaseQty = dtDetls.Rows[i]["purchase_Qty"].ToString();
                    string TotalAcceptQty = dtDetls.Rows[i]["TAcc_Qty"].ToString();
                    string AcceptQty = dtDetls.Rows[i]["Acc_Qty"].ToString();
                    string OLDQty = dtDetls.Rows[i]["Old_Qty"].ToString();
                    string DFlag = dtDetls.Rows[i]["RowState"].ToString();

                    int accept_days = -1;
                    int out_days = -1;

                    //取得入庫單調整明細資料
                    DataRow drStockIn = dtStockIn.NewRow();
                    drStockIn["LocateNo"] = LocateNo;
                    drStockIn["LocateSec"] = LocateSec;
                    drStockIn["Item"] = Item;
                    drStockIn["Period"] = Period;
                    drStockIn["Old_Qty"] = OLDQty;
                    drStockIn["New_Qty"] = AcceptQty;
                    dtStockIn.Rows.Add(drStockIn);

                    //寫入明細檔資料,逐筆寫入
                    InsertParameter.Clear();
                    InsertParameter.Add(UserID);
                    InsertParameter.Add(UpdateDate);
                    InsertParameter.Add(AcceptNo);
                    InsertParameter.Add(Barcode); //BarCode
                    InsertParameter.Add(Item); //Item
                    InsertParameter.Add(Period); //Period
                    InsertParameter.Add(AcceptQty); //NewQty
                    InsertParameter.Add(dtDetls.Rows[i]["Cost"].ToString());            //Cost
                    InsertParameter.Add(dtDetls.Rows[i]["Price"].ToString());           //Price
                    InsertParameter.Add(dtDetls.Rows[i]["Package_Unit"].ToString());    //Package_Unit
                    InsertParameter.Add(dtDetls.Rows[i]["S_Weight"].ToString());        //S_Weight
                    InsertParameter.Add(dtDetls.Rows[i]["S_Length"].ToString());        //S_Length
                    InsertParameter.Add(dtDetls.Rows[i]["S_Width"].ToString());         //S_Width
                    InsertParameter.Add(dtDetls.Rows[i]["S_Height"].ToString());        //S_Height
                    InsertParameter.Add(dtDetls.Rows[i]["P_Weight"].ToString());        //P_Weight
                    InsertParameter.Add(dtDetls.Rows[i]["P_Length"].ToString());        //P_Length
                    InsertParameter.Add(dtDetls.Rows[i]["P_Width"].ToString());         //P_Width
                    InsertParameter.Add(dtDetls.Rows[i]["P_Height"].ToString());        //P_Height
                    InsertParameter.Add(dtDetls.Rows[i]["Product_Source"].ToString());  //Product_Source
                    InsertParameter.Add(dtDetls.Rows[i]["Produce_Date"].ToString());    //Produce_Date
                    InsertParameter.Add(dtDetls.Rows[i]["Reserved_Period"].ToString()); //Reserved_Period
                    InsertParameter.Add(dtDetls.Rows[i]["Valid_Date"].ToString());      //Valid_Date
                    InsertParameter.Add(dtDetls.Rows[i]["AllowAccept_Date"].ToString());//AllowAccept_Date
                    InsertParameter.Add(DFlag); //23.FLAG 
                    InsertParameter.Add(dtDetls.Rows[i]["UPDATEDATE"]);                 //OLD UPDATEDATE
                    InsertParameter.Add(dtDetls.Rows[i]["UPDATEUID"]);                  //OLD UPDATEUID
                    //24 OldQty
                    VGIDBO.UpdateAcceptDetl(InsertParameter, DBT, out DetlID);

                    ////寫入商品檢驗結果
                    //InsertParameter.Clear();
                    //InsertParameter.Add(UserID);
                    //InsertParameter.Add(UpdateDate);
                    //InsertParameter.Add(DetlID);
                    //InsertParameter.Add(AcceptNo);
                    //InsertParameter.Add(Item);
                    //InsertParameter.Add(Period);

                    //VGIQC.CreateQualityCheck(InsertParameter, DBT);

                    //若該商品品項的[@總驗收數]+[@驗收數量]>=[採購數量],則呼叫[MaintainPurchaseOrder.ClosePurchaseOrderDetail]
                    if (int.Parse(TotalAcceptQty) - int.Parse(OLDQty) + int.Parse(AcceptQty) >= int.Parse(PurchaseQty))
                    {
                        InsertParameter.Clear();
                        InsertParameter.Add(UserID);
                        InsertParameter.Add(PurchaseNo);
                        InsertParameter.Add(Item);
                        InsertParameter.Add(Period);
                        InsertParameter.Add(Item);//VirtualCode = Item
                        ClosePurchaseOrderDetail(InsertParameter, DBT);
                    }
                    else
                    {
                        PIC.VDS2G.BSM.PUR.MaintainPurchaseOrder bco = new PIC.VDS2G.BSM.PUR.MaintainPurchaseOrder(strConn);
                        InsertParameter.Clear();
                        InsertParameter.Add(PurchaseNo);
                        InsertParameter.Add(Item);
                        InsertParameter.Add(Period);
                        InsertParameter.Add(Item);//VirtualCode = Item
                        bco.OpenPurchaseOrderDetail(InsertParameter, DBT);
                    }

                    //依傳入的明細資料集參數,將正常品資料回寫生效中(enable=1)的商品屬性檔(VDS_ITM_PERIOD_PROFILE)的下列欄位
                    InsertParameter.Clear();
                    InsertParameter.Add(Item);
                    InsertParameter.Add(Period);
                    InsertParameter.Add(dtDetls.Rows[i]["Package_Unit"].ToString());    //Package_Unit
                    InsertParameter.Add(dtDetls.Rows[i]["S_Weight"].ToString());        //S_Weight
                    InsertParameter.Add(dtDetls.Rows[i]["S_Length"].ToString());        //S_Length
                    InsertParameter.Add(dtDetls.Rows[i]["S_Width"].ToString());         //S_Width
                    InsertParameter.Add(dtDetls.Rows[i]["S_Height"].ToString());        //S_Height
                    InsertParameter.Add(dtDetls.Rows[i]["P_Weight"].ToString());        //P_Weight
                    InsertParameter.Add(dtDetls.Rows[i]["P_Length"].ToString());        //P_Length
                    InsertParameter.Add(dtDetls.Rows[i]["P_Width"].ToString());         //P_Width
                    InsertParameter.Add(dtDetls.Rows[i]["P_Height"].ToString());        //P_Height
                    InsertParameter.Add(AcceptDate);
                    InsertParameter.Add(AcceptQty); //NewQty
                    InsertParameter.Add(dtDetls.Rows[i]["Valid_Date"].ToString());      //Valid_Date
                    InsertParameter.Add(dtDetls.Rows[i]["AllowAccept_Date"].ToString());//AllowAccept_Date
                    //23.FLAG 
                    //24 OldQty
                    UpdateItmPeriodProfile(UserID, UpdateDate, InsertParameter, DBT, out accept_days, out out_days);

                    //呼叫[MaintainGoodsInTransit.UpdateGoodsInTrainsitByGoodsReceive]
                    //傳入[@品號],[@期別],[@虛擬品號],[@採購單號],[@驗收量](若品項為正常品,則[@虛擬品號]=[@品號]),更新在途量
                    //若未找到相對應的在途單資料,表示未開立在途單,不需更新
                    InsertParameter.Clear();
                    InsertParameter.Add(PurchaseNo);
                    InsertParameter.Add(Item);
                    InsertParameter.Add(Period);
                    InsertParameter.Add(Item);
                    InsertParameter.Add(Convert.ToString(int.Parse(AcceptQty) - int.Parse(OLDQty)));
                    PURDB.UpdateGoodsInTrainsitByGoodsReceive(InsertParameter, DBT);

                    #region 贈品明細

                    //Barcode           商品條碼        
                    //Item              品號               
                    //Period            期別             
                    //Virtual_Code      虛擬品號   
                    //purchase_Qty      採購數量   
                    //GiftName                  
                    //Accept_Qty        驗收數量     
                    //accept_accqty     總驗收數   
                    //Old_Qty           驗收數量(原始)
                    //SQty              剩餘數量           
                    //Package_Unit      1包裝數    
                    //S_Weight          單品重量       
                    //S_Length          單品長度       
                    //S_Width           單品寬度        
                    //S_Height          單品高度       
                    //P_Weight          包裝重量       
                    //P_Length          包裝長度       
                    //P_Width           包裝寬度        
                    //P_Height          包裝高度       
                    //UPDATEUID                 
                    //UPDATEDATE                
                    //RowState          "U";               

                    if (DFlag == "U")
                    {
                        //更新贈品明細
                        for (int x = 0; x < dtGifts.Rows.Count; x++)
                        {
                            string GiftBarcode = dtGifts.Rows[x]["Barcode"].ToString();
                            string GiftItem = dtGifts.Rows[x]["Item"].ToString();
                            string GiftPeriod = dtGifts.Rows[x]["Period"].ToString();
                            string GiftVirtualCode = dtGifts.Rows[x]["Virtual_Code"].ToString();
                            string GFlag = dtGifts.Rows[x]["RowState"].ToString();
                            string GiftTotalAcceptQty = dtGifts.Rows[x]["accept_accqty"].ToString();
                            string GiftAcceptQty = dtGifts.Rows[x]["Accept_Qty"].ToString();
                            string GiftAcceptQty_Old = dtGifts.Rows[x]["Old_Qty"].ToString();
                            string GiftPurchaseQty = dtGifts.Rows[x]["purchase_Qty"].ToString();

                            if (Barcode == GiftBarcode && Item == GiftItem && Period == GiftPeriod)
                            {
                                InsertParameter.Clear();
                                InsertParameter.Add(UserID);                                    //0
                                InsertParameter.Add(UpdateDate);                                //1
                                InsertParameter.Add(DetlID);                                    //2
                                InsertParameter.Add(dtGifts.Rows[x]["Barcode"].ToString());     //3  Barcode
                                InsertParameter.Add(GiftItem);                                  //4  Item
                                InsertParameter.Add(GiftPeriod);                                //5  Period
                                InsertParameter.Add(GiftVirtualCode);                           //6  VirtualCode
                                InsertParameter.Add(AcceptNo);                                  //7
                                InsertParameter.Add(dtGifts.Rows[x]["purchase_Qty"].ToString());//8  PurchaseQty
                                InsertParameter.Add(dtGifts.Rows[x]["Accept_Qty"].ToString());  //9  AcceptQty
                                InsertParameter.Add(dtGifts.Rows[x]["Package_Unit"].ToString());//10 PackageUnit
                                InsertParameter.Add(dtGifts.Rows[x]["S_Weight"].ToString());    //11 SWeight
                                InsertParameter.Add(dtGifts.Rows[x]["S_Length"].ToString());    //12 SLength
                                InsertParameter.Add(dtGifts.Rows[x]["S_Width"].ToString());     //13 SWidth
                                InsertParameter.Add(dtGifts.Rows[x]["S_Height"].ToString());    //14 SHeigh
                                InsertParameter.Add(dtGifts.Rows[x]["P_Weight"].ToString());    //15 PWeight
                                InsertParameter.Add(dtGifts.Rows[x]["P_Length"].ToString());    //16 PLength
                                InsertParameter.Add(dtGifts.Rows[x]["P_Width"].ToString());     //17 PWidth
                                InsertParameter.Add(dtGifts.Rows[x]["P_Height"].ToString());    //18 PHeigh
                                InsertParameter.Add(dtGifts.Rows[x]["RowState"].ToString());    //19 RowState
                                InsertParameter.Add(dtGifts.Rows[x]["UPDATEDATE"]);             //20 OLD UPDATEDATE
                                InsertParameter.Add(dtGifts.Rows[x]["UPDATEUID"]);              //21 OLD UPDATEUID

                                VGIDBO.UpdateAcceptGift(InsertParameter, DBT);

                                if (GFlag == "U")
                                {
                                    //若該贈品品項的[@總驗收數]+[@驗收數量]>=[採購數量],則呼叫[MaintainPurchaseOrder.ClosePurchaseOrderDetail]
                                    if (int.Parse(GiftTotalAcceptQty) - int.Parse(GiftAcceptQty_Old) + int.Parse(GiftAcceptQty) >= int.Parse(GiftPurchaseQty))
                                    {
                                        InsertParameter.Clear();
                                        InsertParameter.Add(UserID);                                    //0
                                        InsertParameter.Add(PurchaseNo);                                //1
                                        InsertParameter.Add(dtGifts.Rows[x]["Item"].ToString());        //2
                                        InsertParameter.Add(dtGifts.Rows[x]["Period"].ToString());      //3
                                        InsertParameter.Add(dtGifts.Rows[x]["Virtual_Code"].ToString());//4

                                        ClosePurchaseOrderDetail(InsertParameter, DBT);
                                    }
                                    else
                                    {
                                        PIC.VDS2G.BSM.PUR.MaintainPurchaseOrder bco = new PIC.VDS2G.BSM.PUR.MaintainPurchaseOrder(strConn);
                                        InsertParameter.Clear();
                                        InsertParameter.Add(PurchaseNo);                                //0
                                        InsertParameter.Add(dtGifts.Rows[x]["Item"].ToString());        //1
                                        InsertParameter.Add(dtGifts.Rows[x]["Period"].ToString());      //2
                                        InsertParameter.Add(dtGifts.Rows[x]["Virtual_Code"].ToString());//3
                                        bco.OpenPurchaseOrderDetail(InsertParameter, DBT);
                                    }

                                    //依傳入的贈品明細資料集參數,將贈品資料回寫贈品屬性檔(VDS_MKT_GIFT_PROFILE)的下列欄位
                                    InsertParameter.Clear();
                                    InsertParameter.Add(UserID);                                    //0
                                    InsertParameter.Add(UpdateDate);                                //1
                                    InsertParameter.Add(GiftItem);                                  //2  Item
                                    InsertParameter.Add(GiftPeriod);                                //3  Period
                                    InsertParameter.Add(GiftVirtualCode);                           //4  VirtualCode
                                    InsertParameter.Add(dtGifts.Rows[x]["Package_Unit"].ToString());//5  PackageUnit
                                    InsertParameter.Add(dtGifts.Rows[x]["S_Weight"].ToString());    //6  SWeight
                                    InsertParameter.Add(dtGifts.Rows[x]["S_Length"].ToString());    //7  SLength
                                    InsertParameter.Add(dtGifts.Rows[x]["S_Width"].ToString());     //8  SWidth
                                    InsertParameter.Add(dtGifts.Rows[x]["S_Height"].ToString());    //9  SHeigh
                                    InsertParameter.Add(dtGifts.Rows[x]["P_Weight"].ToString());    //10 PWeight
                                    InsertParameter.Add(dtGifts.Rows[x]["P_Length"].ToString());    //11 PLength
                                    InsertParameter.Add(dtGifts.Rows[x]["P_Width"].ToString());     //12 PWidth
                                    InsertParameter.Add(dtGifts.Rows[x]["P_Height"].ToString());    //13 PHeigh
                                    InsertParameter.Add(AcceptDate);                                //14
                                    InsertParameter.Add(dtGifts.Rows[x]["Accept_Qty"].ToString());  //15 accept_qty
                                    InsertParameter.Add(accept_days);                               //16
                                    InsertParameter.Add(out_days);                                  //17

                                    //UpdateGiftProfile(UserID, UpdateDate, accept_days, out_days, InsertParameter, DBT);

                                    DBO.MaintainAcceptDBO dbo = new DBO.MaintainAcceptDBO(ref USEDB);
                                    dbo.UpdateMktGiftProfile(InsertParameter, DBT);

                                    //呼叫[MaintainGoodsInTransit.UpdateGoodsInTrainsitByGoodsReceive]
                                    //傳入[@品號],[@期別],[@虛擬品號],[@採購單號],[@驗收量](若品項為正常品,則[@虛擬品號]=[@品號]),更新在途量
                                    //若未找到相對應的在途單資料,表示未開立在途單,不需更新
                                    InsertParameter.Clear();
                                    InsertParameter.Add(PurchaseNo);        //0
                                    InsertParameter.Add(GiftItem);          //1
                                    InsertParameter.Add(GiftPeriod);        //2
                                    InsertParameter.Add(GiftVirtualCode);   //3
                                    InsertParameter.Add(Convert.ToString(int.Parse(GiftAcceptQty) - int.Parse(GiftAcceptQty_Old)));         //4

                                    PURDB.UpdateGoodsInTrainsitByGoodsReceive(InsertParameter, DBT);
                                }
                            }
                        }
                    }

                    #endregion

                    //判斷該品項是否需產生新的期別
                    //(1)該品項的期別(period)若不為[000000]且定期出刊(select attribute from vds_itm_item where item=[@item] , attribute的值為=1表示定期出刊),則需需產生下一期別資料
                    //(2)產生新期別的步驟如下:
                    //*檢查該品項期別是否已產生下一期期別資料(select count(*) from vds_itm_period_main where item=@item and period=lpad(to_char(to_number(@period) +(select period_step from vds_itm_item where item=@item)),6,'0')),若尚未產生,則呼叫[MaintainSKUPeriod.ProcessAddNextPeriod]產生新的期別資料,傳入資料參數如[新增下一期別.doc]文件所述
                    InsertParameter.Clear();
                    InsertParameter.Add(Item);
                    InsertParameter.Add(Period);
                    string V_Next = VGIDBO.CheckNextPeriod(ParameterList);

                    if (V_Next == "1")
                    {
                        string Msg = "";
                        string Result2 = "";
                        InsertParameter.Clear();
                        InsertParameter.Add(AcceptNo);
                        InsertParameter.Add(UserID);
                        InsertParameter.Add(DateTime.Now);
                        VGIDBO.AddNextPeriod(InsertParameter, DBT, out Msg, out Result2);
                        if (Result != "1")
                        {
                            throw new Exception("新增下一期別發生錯誤" + Msg);
                        }
                    }
                }

                #region 更新稅額

                InsertParameter.Clear();
                InsertParameter.Add(AcceptNo);
                InsertParameter.Add(UserID);
                InsertParameter.Add(UpdateDate);

                VGIDBO.CalculateTax(InsertParameter, DBT);

                #endregion

                #endregion

                //建立入庫單
                //取得入庫單主檔資料 >輸入變數 0.CheckFreeze_Flag(預設1) 1.ReasonNo 2.ADJNo 3.SourceNo 4.UserID
                //(0)Flag
                //(1)出入庫原因 (InOut_Reason_No)=S1
                //(2)調整單號 (Adjust_No)=null
                //(3)來源單號 (Source_No)=[@驗收單號]
                //(4)使用者
                InsertParameter.Clear();
                InsertParameter.Add("1");
                InsertParameter.Add(AcceptNo);
                InsertParameter.Add(UserID);
                IVMDB.UpdStockIn(InsertParameter, dtStockIn, 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
            }

        }