コード例 #1
0
ファイル: IVM112.aspx.cs プロジェクト: ChiangHanLung/PIC_VDS
    private void databind_Dtl()
    {
        #region
        try
        {
            string SessionIDName = "IVM11_DTL_" + PageTimeStamp.Value;
            IVMModel.MaintainAdjustData BCO = new IVMModel.MaintainAdjustData(ConntionDB);
            ParameterList.Clear();

            if (Request.QueryString["ID"] != null)
            {
                ParameterList.Add(Request.QueryString["ID"].ToString());
            }
            else
            {
                ParameterList.Add(CraeteMainID);
            }

            DataTable Dt = BCO.QueryAdjustDetlByID(ParameterList);

            #region 使用XML放置到前端資料
            Session[SessionIDName] = Dt;

            #endregion
            iDetlRowsCount = Dt.Rows.Count;
            Session[SessionIDName] = Dt;
            GridView1.DataSource = Dt;
            GridView1.DataSource = Dt;
            GridView1.PageIndex = 0;
            GridView1.DataBind();

            if (this.hid_Page_Status.Value == "VIEW")
            {
                btnPRINT.Enabled = true;
                btnNewSave.Visible = false;
                btnCancel.Visible = false;
                GridView1.Columns[0].Visible = false;
            }

        }
        catch (Exception ex)
        {
            ErrorMsgLabel.Text = ex.Message;
        }
        #endregion
    }
コード例 #2
0
ファイル: IVM112.aspx.cs プロジェクト: ChiangHanLung/PIC_VDS
    protected void btnAdd_Click(object sender, EventArgs e)
    {
        #region 檢查輸入值

        hid_Bill_Ini.Value = "";

        ErrorMsgLabel.Text = "";
        string strErr = "";

        try
        {
            string SessionIDName = "IVM11_DTL_" + PageTimeStamp.Value;

            IVMModel.MaintainAdjustData BCO = new IVMModel.MaintainAdjustData(ConntionDB);

            if (SLP_SKU1.Text == string.Empty)
            {
                strErr = "請輸入品號 ";
                ScriptManager.RegisterStartupScript(this.UpdatePanel1, typeof(UpdatePanel), "IVM112", "alert('" + strErr + "');", true);
                TextBox txtItem = (TextBox)this.SLP_SKU1.FindControl("TextBoxCode");
                ScriptManager.RegisterStartupScript(this.UpdatePanel1, typeof(UpdatePanel), "隨便寫", "document.getElementById('" + txtItem.ClientID + "').focus();", true);
                return;
            }

            if (SLP_ItemPeriod1.Text == string.Empty)
            {
                strErr = "請輸入期間 ";
                ScriptManager.RegisterStartupScript(this.UpdatePanel1, typeof(UpdatePanel), "IVM112", "alert('" + strErr + "');", true);
                TextBox txtPeriod = (TextBox)this.SLP_ItemPeriod1.FindControl("TextBoxCode");
                ScriptManager.RegisterStartupScript(this.UpdatePanel1, typeof(UpdatePanel), "隨便寫", "document.getElementById('" + txtPeriod.ClientID + "').focus();", true);
                return;
            }

            TextBox txtLocate = (TextBox)this.SLP_LocateSec1.FindControl("TextBoxCode");
            TextBox txtLocateSec = (TextBox)this.SLP_LocateSec1.FindControl("TextBoxCode2");

            if (txtLocate.Text == "")
            {
                strErr = "請輸入儲區";
                ScriptManager.RegisterStartupScript(this.UpdatePanel1, typeof(UpdatePanel), "IVM112", "alert('" + strErr + "');", true);
                ScriptManager.RegisterStartupScript(this.UpdatePanel1, typeof(UpdatePanel), "隨便寫", "document.getElementById('" + txtLocate.ClientID + "').focus();", true);
                return;
            }

            if (txtLocateSec.Text == "")
            {
                strErr = "請輸入儲位";
                ScriptManager.RegisterStartupScript(this.UpdatePanel1, typeof(UpdatePanel), "IVM112", "alert('" + strErr + "');", true);
                ScriptManager.RegisterStartupScript(this.UpdatePanel1, typeof(UpdatePanel), "隨便寫", "document.getElementById('" + txtLocateSec.ClientID + "').focus();", true);
                return;
            }

            if (txtAdjQty.Text == string.Empty)
            {
                strErr = "請輸入調整數量 ";
                ScriptManager.RegisterStartupScript(this.UpdatePanel1, typeof(UpdatePanel), "IVM112", "alert('" + strErr + "');", true);
                ScriptManager.RegisterStartupScript(this.UpdatePanel1, typeof(UpdatePanel), "隨便寫", "document.getElementById('" + txtAdjQty.ClientID + "').focus();", true);
                
                return;
            }
            else
            {
                int i = 0;
                bool Result = int.TryParse(txtAdjQty.Text, out i);
                if (Result == false)
                {
                    strErr = "請輸入正確數值 ";
                    ScriptManager.RegisterStartupScript(this.UpdatePanel1, typeof(UpdatePanel), "IVM112", "alert('" + strErr + "');", true);
                    ScriptManager.RegisterStartupScript(this.UpdatePanel1, typeof(UpdatePanel), "隨便寫", "document.getElementById('" + txtAdjQty.ClientID + "').focus();", true);
                    return;
                }
                else
                {
                    if (int.Parse(txtAdjQty.Text) == 0)
                    {
                        strErr ="請輸入有效調整數量 ";
                        ScriptManager.RegisterStartupScript(this.UpdatePanel1, typeof(UpdatePanel), "IVM112", "alert('" + strErr + "');", true);
                        ScriptManager.RegisterStartupScript(this.UpdatePanel1, typeof(UpdatePanel), "隨便寫", "document.getElementById('" + txtAdjQty.ClientID + "').focus();", true);
                        return;
                    }
                }
            }

            #endregion

            #region 如果沒有資料取得空DATASET

            DataTable Dt = (DataTable)Session[SessionIDName];

            if (Dt == null)
            {
                //從DB讀取一空table回來

                ParameterList.Clear();
                Dt = BCO.QueryAdjustDataEmpty();
            }

            //檢查是否有重複的品項、期別、儲位

            for (int i = 0 ; i <= Dt.Rows.Count - 1; i++)
            {
                if ((Dt.Rows[i]["item"].ToString() == SLP_SKU1.Text) &&
                    (Dt.Rows[i]["locate_name"].ToString().Split(' ')[0] == SLP_LocateSec1.Text) &&
                    (Dt.Rows[i]["period"].ToString() == SLP_ItemPeriod1.Text))
                {
                    strErr = "此調整明細已存在! ";
                    ScriptManager.RegisterStartupScript(this.UpdatePanel1, typeof(UpdatePanel), "IVM112", "alert('" + strErr + "');", true);
                    return;
                }
            }

            #region 取得庫存成本

            bool Getdata = false;
            string strItem = string.Empty;
            string strperiod = string.Empty;
            double dblCost = 0;
            string Item_Cost = "";
            Getdata = BCO.GetBarCodeData(txtBarCode.Text, out strItem, out strperiod, out dblCost);
            if (txtBarCode.Text != string.Empty)
            {
                Item_Cost = dblCost.ToString();
            }
            else
            {
                IVMModel.MaintainRemoveDataDetail dbo = new IVMModel.MaintainRemoveDataDetail(ConntionDB);
                bool haveData = dbo.GetItemPeriodCost(SLP_SKU1.Text, SLP_ItemPeriod1.Text, out dblCost);
                if (haveData == false)
                {
                    ErrorMsgLabel.Text="產品編號" + SLP_SKU1.Text + "期別編號" + SLP_ItemPeriod1.Text + "查無成本資料";
                }
                Item_Cost = dblCost.ToString();
            }

            #endregion

            tempID = 0;

            DataView tempDT = new DataView();
            tempDT.Table = Dt.Copy();
            tempDT.Sort = "ID ASC";
            if (Dt.Rows.Count != 0)
            {
                tempID = Convert.ToInt32(tempDT[Dt.Rows.Count - 1]["ID"].ToString());
            }

            #region 取得開單庫存

            
            ParameterList.Clear();

            ParameterList.Add(SLP_LocateSec1.Text);
            ParameterList.Add(SLP_SKU1.Text);
            ParameterList.Add(SLP_ItemPeriod1.Text);

            DataTable dtQty = BCO.QueryNewOnhdQty(ParameterList);

            int NowOnhdQty = 0;
            if (dtQty.Rows.Count > 0)
                NowOnhdQty = int.Parse(dtQty.Rows[0]["onhd_qty"].ToString());

            if (NowOnhdQty + int.Parse(txtAdjQty.Text) < 0)
            {
                strErr = "調整後數量<0 ";
                ScriptManager.RegisterStartupScript(this.UpdatePanel1, typeof(UpdatePanel), "IVM112", "alert('" + strErr + "');", true);
                ScriptManager.RegisterStartupScript(this.UpdatePanel1, typeof(UpdatePanel), "隨便寫", "document.getElementById('" + txtAdjQty.ClientID + "').focus();", true);
                return;
            }

            #endregion

            DataRow dRow = Dt.NewRow();

            //ID和CODE暫自訂, 真正寫入CO時會重取
            int v_ID = tempID + 1;
            int v_CODE = tempID + 1;

            dRow["ID"] = v_ID;
            dRow["BarCode"] = this.txtBarCode.Text;
            dRow["item"] = SLP_SKU1.Text;
            dRow["locate_no"] = SLP_LocateSec1.Text.Substring(0, 1);
            dRow["locate_section"] = SLP_LocateSec1.Text;
            dRow["Locate_name"] = SLP_LocateSec1.Text + " " + SLP_LocateSec1.Name;
            dRow["period"] = SLP_ItemPeriod1.Text;
            if (SLP_SKU1.Name == string.Empty)
            {
                dRow["item_name"] = hid_ItemName.Value;
            }
            else
            {
                dRow["item_name"] = SLP_SKU1.Name;
            }
            dRow["onhd_qty"] = NowOnhdQty;
            dRow["adjust_qty"] = txtAdjQty.Text;
            dRow["cost"] = double.Parse(Item_Cost);
            Dt.Rows.Add(dRow);
            //}
            hid_ItemName.Value = "";
            txtBarCode.Text = "";
            //SLP_LocateSec1.Text = "";
            SLP_SKU1.Text = "";
            SLP_ItemPeriod1.Text = string.Empty;
            txtAdjQty.Text = "";

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

            Session[SessionIDName] = Dt;

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

        #endregion

    }
コード例 #3
0
ファイル: IVM112.aspx.cs プロジェクト: ChiangHanLung/PIC_VDS
    }//databind

    private void databind_Mst()
    {
        #region
        try
        {
            string SessionIDName = "IVM11_DTL_" + PageTimeStamp.Value;
            IVMModel.MaintainAdjustData BCO = new IVMModel.MaintainAdjustData(ConntionDB);
            ParameterList.Clear();
            if (Request.QueryString["ID"] != null)
            {
                ParameterList.Add(Request.QueryString["ID"].ToString());

                DataTable Dt = BCO.QueryAdjustMainByID(ParameterList);

                MasterDataBind(this.hid_Page_Status.Value, Dt);
            }
        }
        catch (Exception ex)
        {
            ErrorMsgLabel.Text = ex.Message;
        }
        #endregion
    }
コード例 #4
0
ファイル: IVM112.aspx.cs プロジェクト: ChiangHanLung/PIC_VDS
    }//UC_Delete

    private void UC_Save()
    {

        #region
        ErrorMsgLabel.Text = "";
        string MainID = string.Empty;
        string AdjustNO = string.Empty;
        ArrayList ErrList = new ArrayList();

        try
        {
            string SessionIDName = "IVM11_DTL_" + PageTimeStamp.Value;

            #region 檢查必要條件

            //檢查頁面上的Parameter是否都有資料

            if (SLP_User1.Text == string.Empty || SLP_SLPDate1.Text == string.Empty)
            {
                ErrorMsgLabel.Text = "請確認欄位都已填寫完成";
                return;
            }

            //檢查頁面上的DATATABLE資料都有齊全

            if (GridView1.Rows.Count == 0)
            {
                ErrorMsgLabel.Text = "尚未輸入調整單明細資料,新增失敗";
                return;
            }

            DataTable Dt = (DataTable)Session[SessionIDName];

            if (Dt == null ||Dt.Rows.Count == 0)
            {
                ErrorMsgLabel.Text = "尚未輸入調整單明細資料,新增失敗";
                return;
            }

            //變更DATATABLE 資料內容
            for (int i = 0; i < GridView1.Rows.Count; i++)
            {
                Label lblItem = (Label)GridView1.Rows[i].FindControl("lblItem");
                Label lblPeriod = (Label)GridView1.Rows[i].FindControl("lblPeriod");
                Label lblLocateSection = (Label)GridView1.Rows[i].FindControl("lblLocateSection");
                Label lblOnhdQty = (Label)GridView1.Rows[i].FindControl("lblOnhdQty");
                TextBox txtAdjustQty = (TextBox)GridView1.Rows[i].FindControl("SLP_Number").FindControl("TextBoxCode");

                for (int x = 0; x < Dt.Rows.Count; x++)
                {
                    string Item = Dt.Rows[x]["item"].ToString();
                    string Period = Dt.Rows[x]["period"].ToString();
                    string LocateSec = Dt.Rows[x]["locate_section"].ToString();

                    if (lblItem.Text == Item && lblPeriod.Text == Period && lblLocateSection.Text == LocateSec)
                    {
                        if (int.Parse(txtAdjustQty.Text) + int.Parse(lblOnhdQty.Text) >= 0)
                        {
                            Dt.Rows[x]["adjust_qty"] = txtAdjustQty.Text;
                        }
                        else
                        {
                            ScriptManager.RegisterStartupScript(this.UpdatePanel1, typeof(UpdatePanel), "隨便寫", "document.getElementById('" + txtAdjustQty.ClientID + "').focus();", true);
                            return;
                        }
                    }
                }
            }

            #endregion

            IVMModel.MaintainAdjustData BCO = new IVMModel.MaintainAdjustData(ConntionDB);

            //新增主檔所需PARAMETERLIST

            DropDownList ddl = (DropDownList)SLP_CodeFile1.FindControl("D1");

            ParameterList.Clear();
            ParameterList.Add(Session["UID"].ToString());
            ParameterList.Add(DateTime.Now.ToString("yyyyMMddHHmmss"));
            ParameterList.Add(ddl.SelectedValue);

            Dt.Columns.Remove("ROWNUM");
            Dt.Columns.Remove("id");
            Dt.Columns.Remove("BarCode");
            Dt.Columns.Remove("item_name");
            Dt.Columns.Remove("locate_name");
            Dt.Columns.Remove("onhd_qty");

            bool InsertOK = false;

            InsertOK = BCO.CreateAdjustData(ParameterList, Dt, null, out MainID, out AdjustNO, out ErrList);

            CraeteMainID = MainID;

            if (InsertOK)
            {
                //先把QueryID清空
                ArrayList IDList = new ArrayList();
                IDList.Add(MainID);
                Session["IVM11QueryID"] = IDList;

                Session[SessionIDName] = null;

                Response.Redirect(string.Format("IVM112.aspx?Code=IVM11&ID={0}&PageMode=1", MainID));
            }
            else
            {
                string strError = "";
                for(int i = 0; i < ErrList.Count;i++)
                {
                    if (i == ErrList.Count - 1)
                    {
                        strError += ErrList[i].ToString();
                    }
                    else
                    {
                        strError += ErrList[i].ToString() + ",";
                    }
                }
                //ScriptManager.RegisterStartupScript(this.UpdatePanel1, typeof(UpdatePanel), "IVM112", "alert('" + strError + "於指定儲位之庫存量不足');", true);
                ErrorMsgLabel.Text = strError + "於指定儲位之庫存量不足";

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

    }//UC_Save
コード例 #5
0
ファイル: IVM112.aspx.cs プロジェクト: ChiangHanLung/PIC_VDS
 public static string GetBarCodeData(string txtBarCodeText)
 {
     string item = string.Empty;
     string period = string.Empty;
     double Cost = 0;
     string ItemName = string.Empty;
     IVMModel.MaintainAdjustData BCO = new IVMModel.MaintainAdjustData(ConntionDB);
     BCO.GetBarCodeData(txtBarCodeText, out item, out period, out Cost, out ItemName);
     return item + "," + period + "," + Cost.ToString() + "," + ItemName;
 }
コード例 #6
0
ファイル: IVM111.aspx.cs プロジェクト: ChiangHanLung/PIC_VDS
    /// <summary>
    /// databind 繫結查詢資料到GridView1
    /// </summary>
    private void databind()
    {
        //抓取本頁初次登記的時間

        string SessionIDName = "IVM111_" + PageTimeStamp.Value;

        IVMModel.MaintainAdjustData BCO = new PIC.VDS2G.VSM.IVM.MaintainAdjustData(ConntionDB);

        DataTable Dt;
        ParameterList.Clear();
        ParameterList.Add(this.txtAdjustNo.Text);
        ParameterList.Add(this.SLP_SLPDate1.Text);
        ParameterList.Add(this.SLP_CodeFile1.Text);
        ParameterList.Add(int.Parse(this.TextBoxRowCountLimit.Text));

        Dt = BCO.QueryMainByFind(ParameterList);

        if (Dt.Rows.Count == 0)
        {
            ErrorMsgLabel.Text = "查無資料";
            ScriptManager.RegisterStartupScript(Page, this.GetType(), "IVM111.aspx", "alert(' 查無資料 ');", true);
        }

        Session[SessionIDName] = Dt;
        GridView1.DataSource = Dt;

        ArrayList IDList = new ArrayList();

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

        Session["IVM11QueryID"] = IDList;
        

        //設定分頁大小
        GridView1.PageSize = (TextBoxPagesize.Text == "") ? 10 : (int.Parse(TextBoxPagesize.Text) < 0) ? 10 : int.Parse(TextBoxPagesize.Text);
        //

        GridView1.PageIndex = 0;
        GridView1.DataBind();
    }
コード例 #7
0
        /// <summary>
        /// 建立退貨單主檔
        /// </summary>
        /// <param name="ParameterList">0:UserID 1:ReturnDate(yyyy/MM/dd HH:mm:ss) 2:@IsAdj 3:退貨LocateSection 4:Vendor 5:ReturnNo 6:AdjustNo 7:UnTax_Total_Amt  8:Tax_Total_Amt 9:UnTax_ReMain_Amt 10:Tax_ReMain_Am 11:Tax_Amt</param>
        /// <param name="dtDetail">欄位 0:item 1:Period 2:tax_type 3:onhd_qty 4:return_qty 5:adjust_qty 6:cost 7:price</param>
        /// <param name="RootDBT">使用的交易 null代表無傳入交易系統可以自行產生</param>
        /// <param name="ReturnNo">退貨單號 10碼</param>
        /// <param name="MainID"> 主表單ID </param>
        /// <param name="AdjustNo">調整單號</param>
        /// <returns>是否成功</returns>
        
        public bool CreateReturnData(ArrayList ParameterList, DataTable dtDetail, DbTransaction RootDBT,
                                     out string ReturnNo, out string MainID, out string AdjustNo)
        {
            ReturnNo = "";
            MainID = "";
            AdjustNo = "";

            string AdjMainID = "";
            int PID = 0;
            bool IsRootTranscation = false;
            string UserID = ParameterList[0].ToString();
            string ReturnDate = ParameterList[1].ToString();
            string IsAdj = ParameterList[2].ToString();
            string LocateSection = ParameterList[3].ToString();
            string LocateNo = LocateSection.Substring(0,1);
            string Vendor = ParameterList[4].ToString();
            string ReasonNo = ParameterList[5].ToString();
            string AdjReason = ParameterList[6].ToString();

            string strReasonNO = "";

            ArrayList ErrorList = new ArrayList();

            try
            {
                //建立退貨主檔資料
                DBO.CreateReturnData db = new CreateReturnData(ref USEDB);
                DBO.UpdateReturnData dbu = new UpdateReturnData(ref USEDB);
                IVMDBO.MaintainAdjustData dbAdj = new IVMDBO.MaintainAdjustData(strConn);
                IVMDBO.MaintainStockInOut dbStock = 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


                if (IsAdj == "1") //建立調整單並建立出庫單
                {
                    ArrayList AdjustList = new ArrayList();
                    AdjustList.Add(UserID);
                    AdjustList.Add(ReturnDate);
                    AdjustList.Add(AdjReason);
                    AdjustList.Add(ReasonNo);

                    //轉換DataTable資料格式
                    DataTable DtAdjust = new DataTable();

                    //轉換DataTable資料格式
                    DtAdjust.Columns.Add("Locate_No", typeof(String));
                    DtAdjust.Columns.Add("Locate_Section", typeof(String));
                    DtAdjust.Columns.Add("Item", typeof(String));
                    DtAdjust.Columns.Add("Period", typeof(String));
                    DtAdjust.Columns.Add("Adjust_Qty", typeof(Int32));
                    DtAdjust.Columns.Add("Cost", typeof(Double));

                    for (int i = 0; i < dtDetail.Rows.Count; i++)
                    {
                        if (int.Parse(dtDetail.Rows[i]["Adjust_Qty"].ToString()) != 0)
                        {
                            DataRow dr = DtAdjust.NewRow();
                            dr["Locate_No"] = LocateNo;
                            dr["Locate_Section"] = LocateSection;
                            dr["Item"] = dtDetail.Rows[i][0].ToString();
                            dr["Period"] = dtDetail.Rows[i][1].ToString();
                            dr["Adjust_Qty"] = int.Parse(dtDetail.Rows[i][5].ToString());
                            dr["Cost"] = double.Parse(dtDetail.Rows[i][6].ToString());
                            DtAdjust.Rows.Add(dr);
                        }
                    }

                    //建立調整單
                    dbAdj.CreateAdjustData(AdjustList, DtAdjust, DBT, out AdjMainID, out AdjustNo, out ErrorList);

                }

                ArrayList ReturnMainList = new ArrayList();
                ReturnMainList.Add(UserID);
                ReturnMainList.Add(ReturnDate);
                ReturnMainList.Add(Vendor);
                ReturnMainList.Add(decimal.Parse(ParameterList[7].ToString()));
                ReturnMainList.Add(decimal.Parse(ParameterList[8].ToString()));
                ReturnMainList.Add(decimal.Parse(ParameterList[9].ToString()));
                ReturnMainList.Add(decimal.Parse(ParameterList[10].ToString()));
                ReturnMainList.Add(decimal.Parse(ParameterList[11].ToString()));

                db.CreateReturnMain(ReturnMainList, DBT, out PID,out ReturnNo);

                strReasonNO = ReturnNo;

                MainID = PID.ToString();

                //建立Detail資料

                ArrayList ReturnDetailList = new ArrayList();

                for (int i = 0; i < dtDetail.Rows.Count; i++)
                {
                    ReturnDetailList.Clear();
                    ReturnDetailList.Add(UserID);
                    ReturnDetailList.Add(ReturnDate);
                    ReturnDetailList.Add(PID);
                    ReturnDetailList.Add(dtDetail.Rows[i][0].ToString()); //item
                    ReturnDetailList.Add(dtDetail.Rows[i][1].ToString()); //Period
                    ReturnDetailList.Add(dtDetail.Rows[i][2].ToString()); //tax_type
                    ReturnDetailList.Add(dtDetail.Rows[i][3].ToString()); //onhd_qty
                    ReturnDetailList.Add(dtDetail.Rows[i][4].ToString()); //return_qty
                    ReturnDetailList.Add(dtDetail.Rows[i][5].ToString()); //adjust_qty
                    ReturnDetailList.Add(dtDetail.Rows[i][6].ToString()); //cost
                    ReturnDetailList.Add(dtDetail.Rows[i][7].ToString()); //price
                    db.CreateReturnDetl(ReturnDetailList, DBT, out PID);
                }

                //計算稅額
                ReturnMainList.Clear();
                ReturnMainList.Add(ReturnNo);
                ReturnMainList.Add(UserID);
                ReturnMainList.Add(ReturnDate);

                dbu.UpdateReturnMainTax(ReturnMainList, DBT);

                //建立出庫單

                ArrayList StockList = new ArrayList();
                StockList.Add("1");
                StockList.Add("S4");
                StockList.Add(AdjustNo);
                StockList.Add(strReasonNO);
                StockList.Add(UserID);

                DataTable DtStock = new DataTable();
                DtStock.Columns.Add("Locate_No", typeof(String));
                DtStock.Columns.Add("Locate_Section", typeof(String));
                DtStock.Columns.Add("Item", typeof(String));
                DtStock.Columns.Add("Period", typeof(String));
                DtStock.Columns.Add("InOut_Qty", typeof(Int32));
                DtStock.Columns.Add("Cost", typeof(Double));

                for (int i = 0; i < dtDetail.Rows.Count; i++)
                {
                    DataRow dr = DtStock.NewRow();
                    dr["Locate_No"] = LocateNo;
                    dr["Locate_Section"] = LocateSection;
                    dr["Item"] = dtDetail.Rows[i][0].ToString();
                    dr["Period"] = dtDetail.Rows[i][1].ToString();
                    dr["InOut_Qty"] = int.Parse(dtDetail.Rows[i][4].ToString());
                    dr["Cost"] = double.Parse(dtDetail.Rows[i][6].ToString());
                    DtStock.Rows.Add(dr);
                }

                dbStock.CreateStockOut(StockList, DtStock, DBT);

                db.UpdateMainAdjustNo(MainID, AdjustNo, DBT);

                #region 交易成功

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

            }
            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
            }
        }