Ejemplo n.º 1
0
    protected void btn_Save_Click(object sender, EventArgs e)
    {
        try
        {
            string par_AcceptDate = this.SLP_AcceptDate.Text;
            string par_ChanNo = this.ddlChanNo.SelectedValue;
            string par_Store = this.ddlStore.SelectedValue;

            string par_CREATEUID = Session["UID"].ToString();

            #region 檢查

            if (par_ChanNo.Trim() == string.Empty)
            {
                throw new Exception("通路未設定!!");
            }

            if (par_Store.Trim() == string.Empty)
            {
                throw new Exception("廠商門市未設定!!");
            }

            if (this.txt_PageStatus.Text != "QUERY" && (this.SLP_SKU.Text != string.Empty || this.SLP_Period.Text != string.Empty))
            {
                QueryItemDataUpdate();
                throw new Exception("明細資料在編輯狀態,不可儲存!!");
            }

            #endregion

            #region 建立移轉單

            if (Request["formtype"] == "1")//由驗收單畫面連過來
            {

                //檢查是否需要建移轉單
                //如果[出庫儲位庫存量] < [進貨數量],要建移轉單
                if (checkNeedRemove())
                {
                    string strOutLS = string.Empty;
                    string strInLS = string.Empty;

                    if (CheckForRemove(out strOutLS, out strInLS))
                    {
                        string strMainID = string.Empty;
                        string strRemoveNo = string.Empty;
                        ArrayList ErrList = new ArrayList();
                        bool result = false;

                        DataTable Dt_Detail = MakeDetailTable(strOutLS, strInLS);

                        ParameterList.Clear();
                        ParameterList.Add(par_CREATEUID);
                        ParameterList.Add(par_AcceptDate);
                        ParameterList.Add("M3");

                        PIC.VDS2G.VSM.IVM.MaintainRemoveData bco = new PIC.VDS2G.VSM.IVM.MaintainRemoveData(ConntionDB);
                        result = bco.CreateRemoveData(ParameterList, Dt_Detail, null, out strMainID, out strRemoveNo, out ErrList);

                        if (result == false)
                        {
                            throw new Exception("無足夠儲位,無法建立移轉單");
                        }
                    }
                    else
                    {
                        throw new Exception("查無儲格資料,無法建立移轉單");
                    }
                }
            }

            #endregion

            ParameterList.Clear();
            ParameterList.Add(GetValueSetParameter(par_AcceptDate, "string"));
            ParameterList.Add(GetValueSetParameter(par_ChanNo, "string"));
            ParameterList.Add(GetValueSetParameter(par_Store, "string"));
            ParameterList.Add(GetValueSetParameter(par_CREATEUID, "string"));

            string sAssignNo = "";
            string sAcceptNo = "";
            string sOutNo = "";

            string SessionIDName = "VGI022_" + PageTimeStamp.Value;

            DataTable dt = (DataTable)Session[SessionIDName];
            if (dt.Rows.Count == 0)
            {
                throw new Exception("無明細項目資料!!");
            }

            MaintainAssign BCO = new MaintainAssign(ConntionDB);

            BCO.CreateAssign(ParameterList, null, dt, out sAssignNo, out sAcceptNo, out sOutNo);

            this.txt_AssignNo.Text = sAssignNo;
            this.txt_AcceptNo.Text = sAcceptNo;
            this.txt_OutNo.Text = sOutNo;

            IDList.Clear();

            if (Session["VGI02QueryID"] != null)
            {

                IDList = (ArrayList)Session["VGI02QueryID"];
                IDList.Clear();
            }

            Response.Redirect("VGI022.aspx?ID=" + txt_AssignNo.Text + "&mode=VIEW&Code=VGI02", false);

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


        #region 存檔後狀態設定

        //        this.hid_PageStatus.Value = "VIEW";
        //        this.txt_PageStatus.Text = "VIEW";
        //        SetPageStatus();

        #endregion

    }
Ejemplo n.º 2
0
    private void SaveForm()
    {

        string MainID = string.Empty;
        string RemoveNO = string.Empty;
        ArrayList ErrList = new ArrayList();

        string SessionIDName = "IVM10_DTL_" + PageTimeStamp.Value;

        try
        {

            #region 確認必要欄位都已填寫

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


            //檢查頁面上的DATATABLE資料都有齊全
            if (GridView1.Rows.Count == 0)
            {
                ErrorMsgLabel.Text = "尚未輸入移轉單明細資料,新增失敗";
                UpdatePanel6.Update();
                return;
            }

            //DataSet Ds = new DataSet();
            //System.IO.StringReader sr = new System.IO.StringReader(MasterOLDData.InnerHtml);
            //Ds.ReadXml(sr);

            //if (Ds.Tables.Count == 0 || Ds.Tables[0].Rows.Count == 0)
            //{
            //    ErrorMsgLabel.Text = "尚未輸入移轉單明細資料,新增失敗";
            //    return;
            //}

            DataTable Dt = (DataTable)Session[SessionIDName];

            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 lblSecOut = (Label)GridView1.Rows[i].FindControl("lblSecOut");
                Label lblSecIn = (Label)GridView1.Rows[i].FindControl("lblSecIn");
                TextBox txtRemove_Qty = (TextBox)GridView1.Rows[i].FindControl("txtRemove_Qty");

                int AdjQty = 0;

                if (int.TryParse(txtRemove_Qty.Text, out AdjQty) == true)
                {
                    if (AdjQty == 0)
                    {
                        ErrorMsgLabel.Text = "新增失敗,請檢查明細區移轉數量是否為零";
                        UpdatePanel6.Update();
                        return;
                    }
                }
                else
                {
                    ErrorMsgLabel.Text = "新增失敗,請檢查明細區移轉數量是否為非零整數";
                    UpdatePanel6.Update();
                    return;
                }

                for (int x = 0; x < Dt.Rows.Count; x++)
                {
                    if (Dt.Rows[x]["item"].ToString() == lblItem.Text && Dt.Rows[x]["period"].ToString() == lblPeriod.Text &&
                       Dt.Rows[x]["Out_locate_section"].ToString() == lblSecOut.Text && Dt.Rows[x]["In_locate_section"].ToString() == lblSecIn.Text)
                    {
                        Dt.Rows[x]["remove_qty"] = txtRemove_Qty.Text;
                    }
                }
            }

            #endregion

            //新增主檔所需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);

            DataTable DtCreate = Dt.Copy();

            //Ds.Tables[0].Columns.Remove("ROWNUM");
            //Dt.Columns.Remove("Out_locate_no");
            DtCreate.Columns.Remove("Out_Locate_Name");
            //Dt.Columns.Remove("In_locate_no");
            DtCreate.Columns.Remove("In_Locate_Name");
            DtCreate.Columns.Remove("item_name");
            DtCreate.Columns.Remove("onhd_qty");
            DtCreate.Columns.Remove("id");

            bool InsertOK = false;

            IVMModel.MaintainRemoveData DataCreate = new IVMModel.MaintainRemoveData(ConntionDB);
            InsertOK = DataCreate.CreateRemoveData(ParameterList, DtCreate, null, out MainID, out RemoveNO, out ErrList);

            if (InsertOK)
            {
                txtRemoveNo.Text = RemoveNO;
                databind();
                GetPageDefault();
                Session[SessionIDName] = null;

                ArrayList IDList = new ArrayList();
                IDList.Add(MainID);

                Session["IVM10QueryID"] = IDList;

                Response.Redirect(string.Format("IVM102.aspx?ID={0}&PageMode=1&Code=IVM10", 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 + "於指定儲位(或儲區)庫存不足";
                UpdatePanel6.Update();
                return;
            }
        }
        catch (Exception ex)
        {
            ErrorMsgLabel.Text = ex.Message;
            UpdatePanel6.Update();
        }
    #endregion
    }
Ejemplo n.º 3
0
        /// <summary>
        /// 依照揀貨單號建立移轉單
        /// </summary>
        /// <param name="UserID"></param>
        /// <param name="RemoveDate"></param>
        /// <param name="RemoveReason"></param>
        /// <param name="PickNo"></param>
        /// <param name="RootDBT"></param>
        /// <param name="RemoveNo"></param>
        /// <param name="ErrorList"></param>
        /// <returns></returns>
        public bool CreateRemoveByPick(string UserID, string RemoveDate, string RemoveReason, string FunNo, string PickNo,string UpdateTime, DbTransaction RootDBT, out string RemoveNo, out ArrayList ErrorList)
        {
            RemoveNo = string.Empty;

            string MainID = string.Empty;

            bool IsOK = false;

            bool IsRootTranscation = false;

            ArrayList ParameterList = new ArrayList();

            ArrayList ItemQtyList = new ArrayList();

            try
            {
                IsRootTranscation = (RootDBT == null) ? true : false;

                #region 啟動交易或指定RootTranscation

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

                #endregion


                DBO.VDS_IVM16_DBO BCOIVM = new DBO.VDS_IVM16_DBO(ref USEDB);

                ParameterList.Clear();
                ParameterList.Add(PickNo);
                DataTable dtCreate = BCOIVM.GetRemoveDataByPick(ParameterList);

                DBO.MaintainRemoveData BCO = new DBO.MaintainRemoveData(strConn);

                ParameterList.Clear();
                ParameterList.Add(UserID);
                ParameterList.Add(RemoveDate);
                ParameterList.Add(RemoveReason);

                if (FunNo == "8" || FunNo == "6")
                {
                    //拆開之前判斷有沒有空間
                    //建立新的DATATABLE儲存SUMMARY的移出儲位及儲位數量
                    DataTable dtSpace = new DataTable();
                    dtSpace.Columns.Add("OutLocateSection");
                    dtSpace.Columns.Add("InLocateSection"); //充數欄位
                    dtSpace.Columns.Add("Item");
                    dtSpace.Columns.Add("Period");
                    dtSpace.Columns.Add("Remove_Qty");

                    //計算移出欄位數量,並加總

                    for (int i = 0; i < dtCreate.Rows.Count; i++)
                    {
                        string OutLocateSection = dtCreate.Rows[i][0].ToString();
                        string InLocateSection = "";
                        string Item = dtCreate.Rows[i][2].ToString();
                        string Period = dtCreate.Rows[i][3].ToString();
                        string RemoveQty = dtCreate.Rows[i][4].ToString();

                        bool HaveSec = false;
                        int U = -1;

                        for (int x = 0; x < dtSpace.Rows.Count; x++)
                        {
                            if (OutLocateSection == dtSpace.Rows[x]["OutLocateSection"].ToString() &&
                               Item == dtSpace.Rows[x]["Item"].ToString() &&
                               Period == dtSpace.Rows[x]["Period"].ToString())
                            {
                                HaveSec = true;
                                U = x;
                            }
                        }

                        if (HaveSec == true)
                        {
                            dtSpace.Rows[U]["Remove_Qty"] = int.Parse(dtSpace.Rows[U]["Remove_Qty"].ToString()) + int.Parse(RemoveQty);
                        }
                        else
                        {
                            DataRow drSpace = dtSpace.NewRow();
                            drSpace["OutLocateSection"] = OutLocateSection;
                            drSpace["InLocateSection"] = InLocateSection;
                            drSpace["Item"] = Item;
                            drSpace["Period"] = Period;
                            drSpace["Remove_Qty"] = RemoveQty;
                            dtSpace.Rows.Add(drSpace);
                        }
                    }

                    bool HaveSpace = BCO.CheckSpace(dtSpace, out ErrorList, out ItemQtyList);

                    if (HaveSpace == true)
                    {
                        ParameterList.Add("Y");
                        DataTable dtResult = SplitSectionSecData(dtCreate);
                        IsOK = BCO.CreateRemoveData(ParameterList, dtResult, DBT, out MainID, out RemoveNo, out ErrorList);
                    }
                    else
                    {
                        IsOK = false;
                    }
                }
                else
                {
                    IsOK = BCO.CreateRemoveData(ParameterList, dtCreate, DBT, out MainID, out RemoveNo, out ErrorList);
                }

                if (IsOK == false)
                {
                    return false;
                }

                ParameterList.Clear();
                ParameterList.Add(UserID);
                ParameterList.Add(PickNo);
                ParameterList.Add(RemoveNo);
                ParameterList.Add(RemoveDate);
                ParameterList.Add(UpdateTime);
                BCOIVM.UpdateRemoveNoByPickNo(ParameterList, 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
            }
        }
Ejemplo n.º 4
0
    // 存檔
    protected void btnSave_Click(object sender, EventArgs e)
    {
        try
        {
            string MainID = string.Empty;
            string RemoveNO = string.Empty;
            ArrayList ErrList = new ArrayList();

            string SessionIDName = "IVM391_" + PageTimeStamp.Value;

            if (gv_Detail.Rows.Count <= 0 || Session["IVM391_" + PageTimeStamp.Value] == null)
            {
                ShowErr("請輸入資料~");
                return;
            }
            else
            {
                DataTable Dt = (DataTable)Session["IVM391_" + PageTimeStamp.Value];

                //新增主檔所需PARAMETERLIST

                ParameterList.Clear();
                ParameterList.Add(Session["UID"].ToString());
                ParameterList.Add(DateTime.Now.ToString("yyyyMMddHHmmss"));
                ParameterList.Add("M3"); //固定為一般庫存出貨移轉

                DataTable DtCreate = new DataTable();
                DtCreate.Columns.Add("OUT_LOCATE_NO");
                DtCreate.Columns.Add("OUT_LOCATE_SECTION");
                DtCreate.Columns.Add("IN_LOCATE_NO");
                DtCreate.Columns.Add("IN_LOCATE_SECTION");
                DtCreate.Columns.Add("ITEM");
                DtCreate.Columns.Add("PERIOD");
                DtCreate.Columns.Add("REMOVE_QTY");
                DtCreate.Columns.Add("COST");

                for(int i=0;i < Dt.Rows.Count;i++)
                {
                    int REV_QTY = Convert.ToInt32(Dt.Rows[i]["REV_QTY"]);
                    int RTN_QTY = Convert.ToInt32(Dt.Rows[i]["RTN_QTY"]);

                    if (REV_QTY > 0)
                    {
                        DataRow drc = DtCreate.NewRow();
                        drc["OUT_LOCATE_NO"] = Dt.Rows[i]["OUTSECTION"].ToString().Substring(0, 1);
                        drc["OUT_LOCATE_SECTION"] = Dt.Rows[i]["OUTSECTION"].ToString();
                        drc["IN_LOCATE_NO"] = Dt.Rows[i]["INSECTION"].ToString().Substring(0, 1);
                        drc["IN_LOCATE_SECTION"] = Dt.Rows[i]["INSECTION"].ToString();
                        drc["ITEM"] = Dt.Rows[i]["ITEM"].ToString();
                        drc["PERIOD"] = Dt.Rows[i]["PERIOD"].ToString();
                        drc["REMOVE_QTY"] = Dt.Rows[i]["REV_QTY"].ToString();
                        drc["COST"] = Dt.Rows[i]["COST"].ToString();

                        DtCreate.Rows.Add(drc);
                    }

                    if (RTN_QTY > 0)
                    {
                        DataRow drc = DtCreate.NewRow();
                        drc["OUT_LOCATE_NO"] = Dt.Rows[i]["OUTSECTION"].ToString().Substring(0, 1);
                        drc["OUT_LOCATE_SECTION"] = Dt.Rows[i]["OUTSECTION"].ToString();
                        drc["IN_LOCATE_NO"] = Dt.Rows[i]["RTNSECTION"].ToString().Substring(0, 1);
                        drc["IN_LOCATE_SECTION"] = Dt.Rows[i]["RTNSECTION"].ToString();
                        drc["ITEM"] = Dt.Rows[i]["ITEM"].ToString();
                        drc["PERIOD"] = Dt.Rows[i]["PERIOD"].ToString();
                        drc["REMOVE_QTY"] = Dt.Rows[i]["RTN_QTY"].ToString();
                        drc["COST"] = Dt.Rows[i]["COST"].ToString();

                        DtCreate.Rows.Add(drc);                    
                    }
                }

                bool InsertOK = false;

                IVMModel.MaintainRemoveData DataCreate = new IVMModel.MaintainRemoveData(ConntionDB);
                InsertOK = DataCreate.CreateRemoveData(ParameterList, DtCreate, null, out MainID, out RemoveNO, out ErrList);

                if (InsertOK)
                {
                    lblRemoveNo.Text = RemoveNO;

                    SetPageDefault();
                }
                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() + ",";
                        }
                    }

                    ShowErr(strError + "於指定儲位(或儲區)庫存不足");
                    return;
                }

            }
        }
        catch (Exception ex)
        {
            ShowErr("儲存出現異常,請洽系統人員處理");
        }
    }