示例#1
0
 private string GetLocateQty(string Item, string Period, string LocateSec)
 {
     int OnHd_Qty = 0;
     IVMModel.MaintainRemoveByPick BCOIVM = new IVMModel.MaintainRemoveByPick(ConntionDB);
     bool getSuccess = BCOIVM.GetStockQtyByLocateSec(Item, Period, LocateSec, out OnHd_Qty);
     if (getSuccess == false)
     {
         return "0";
     }
     else
     {
         return OnHd_Qty.ToString();
     }
 }
        //如果FunctionNo = 6 or 8,需要再額外判斷移轉單資料是否需要分成兩筆,分完之後要合併重複的資料

        private DataTable SplitSectionSecData(DataTable Dt)
        {
            try
            {

                ArrayList ParameterList = new ArrayList();

                DataTable DtResult = MakeNewDataTable();

                DataTable dtTemp1 = MakeNewDataTable();
                DataTable dtTemp2 = MakeNewDataTable();

                for (int i = 0; i < Dt.Rows.Count; i++)
                {
                    string BSec = Dt.Rows[i]["BLocate_Section"].ToString();
                    string ESec = Dt.Rows[i]["ELocate_Section"].ToString();
                    string Item = Dt.Rows[i]["Item"].ToString();
                    string Period = Dt.Rows[i]["Period"].ToString();
                    string PickQty = Dt.Rows[i]["Real_Pick_Qty"].ToString();
                    string Cost = Dt.Rows[i]["Cost"].ToString();

                    DBO.MaintainRemoveByPick BCOIVM = new DBO.MaintainRemoveByPick(strConn);
                    ParameterList.Clear();
                    ParameterList.Add(ESec.Substring(0, 1));
                    ParameterList.Add("1");
                    string LocateSec = BCOIVM.GetLocateSecByAttr(ParameterList);

                    if (BSec.Substring(0, 1) == ESec.Substring(0, 1) || LocateSec == ESec) //同儲區移動或移到暫存儲位的
                    {
                        DataRow dr = dtTemp1.NewRow();
                        dr["BLocate_Section"] = BSec;
                        dr["ELocate_Section"] = ESec;
                        dr["Item"] = Item;
                        dr["Period"] = Period;
                        dr["Real_Pick_Qty"] = PickQty;
                        dr["Cost"] = Cost;
                        dtTemp1.Rows.Add(dr);
                    }
                    else //跨儲區移動
                    {
                        //先移到暫存區
                        DataRow dr = dtTemp1.NewRow();
                        dr["BLocate_Section"] = BSec;
                        dr["ELocate_Section"] = LocateSec;
                        dr["Item"] = Item;
                        dr["Period"] = Period;
                        dr["Real_Pick_Qty"] = PickQty;
                        dr["Cost"] = Cost;
                        dtTemp1.Rows.Add(dr);
                        //從暫存區移到正式儲區
                        DataRow dr2 = dtTemp2.NewRow();
                        dr2["BLocate_Section"] = LocateSec;
                        dr2["ELocate_Section"] = ESec;
                        dr2["Item"] = Item;
                        dr2["Period"] = Period;
                        dr2["Real_Pick_Qty"] = PickQty;
                        dr2["Cost"] = Cost;
                        dtTemp2.Rows.Add(dr2);
                    }

                }

                //先處理同儲區移轉及搬到暫存區的資料
                for (int a = 0; a < dtTemp1.Rows.Count; a++)
                {
                    DataRow drResult = DtResult.NewRow();
                    drResult["BLocate_Section"] = dtTemp1.Rows[a]["BLocate_Section"].ToString();
                    drResult["ELocate_Section"] = dtTemp1.Rows[a]["ELocate_Section"].ToString();
                    drResult["Item"] = dtTemp1.Rows[a]["Item"].ToString();
                    drResult["Period"] = dtTemp1.Rows[a]["Period"].ToString();
                    drResult["Real_Pick_Qty"] = dtTemp1.Rows[a]["Real_Pick_Qty"].ToString();
                    drResult["Cost"] = dtTemp1.Rows[a]["Cost"].ToString();
                    DtResult.Rows.Add(drResult);
                }


                //再處理暫存區到正式儲區資料
                for (int b = 0; b < dtTemp2.Rows.Count; b++)
                {
                    DataRow drResult = DtResult.NewRow();
                    drResult["BLocate_Section"] = dtTemp2.Rows[b]["BLocate_Section"].ToString();
                    drResult["ELocate_Section"] = dtTemp2.Rows[b]["ELocate_Section"].ToString();
                    drResult["Item"] = dtTemp2.Rows[b]["Item"].ToString();
                    drResult["Period"] = dtTemp2.Rows[b]["Period"].ToString();
                    drResult["Real_Pick_Qty"] = dtTemp2.Rows[b]["Real_Pick_Qty"].ToString();
                    drResult["Cost"] = dtTemp2.Rows[b]["Cost"].ToString();
                    DtResult.Rows.Add(drResult);
                }

                //把dtTemp1 dtTemp2資源釋放

                dtTemp1 = null;
                dtTemp2 = null;

                //合併並計算重複的資料

                DataTable DtResult2 = MakeNewDataTable();

                for (int i = 0; i < DtResult.Rows.Count; i++)
                {
                    string BLocate_Section = DtResult.Rows[i][0].ToString();
                    string ELocate_Section = DtResult.Rows[i][1].ToString();
                    string Item = DtResult.Rows[i][2].ToString();
                    string Period = DtResult.Rows[i][3].ToString();
                    string Real_Pick_Qty = DtResult.Rows[i][4].ToString();
                    string Cost = DtResult.Rows[i][5].ToString(); 

                    bool HaveSec = false;
                    int U = -1;

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

                    if (HaveSec == true)
                    {
                        DtResult2.Rows[U]["Real_Pick_Qty"] = int.Parse(DtResult2.Rows[U]["Real_Pick_Qty"].ToString()) + int.Parse(Real_Pick_Qty);
                        DtResult2.Rows[U]["Cost"] = decimal.Parse(DtResult2.Rows[U]["Cost"].ToString()) + decimal.Parse(Cost);
                    }
                    else
                    {
                        DataRow drResult2 = DtResult2.NewRow();
                        drResult2["BLocate_Section"] = BLocate_Section;
                        drResult2["ELocate_Section"] = ELocate_Section;
                        drResult2["Item"] = Item;
                        drResult2["Period"] = Period;
                        drResult2["Real_Pick_Qty"] = Real_Pick_Qty;
                        drResult2["Cost"] = Cost;
                        DtResult2.Rows.Add(drResult2);
                    }
                }

                DtResult = null;

                return DtResult2;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
示例#3
0
    private void dataBind()
    {
        string strErr = "";
        string PickNo = txtPickNo.Text;
        int FunNo = 0;
        string RemoveNo = "";
        string RemoveReason = "";
        string RemoveDate = "";
        string UpdateID = "";
        string UpdateDate = "";
        string Result = "";
        int MainID = -1;
        string UpdateTime = "";

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

            IVMModel.MaintainRemoveByPick BCO = new IVMModel.MaintainRemoveByPick(ConntionDB);
            DataTable dtResult = BCO.QueryByPick(PickNo, out FunNo, out RemoveNo, out RemoveReason, out RemoveDate, out UpdateID, out UpdateDate, out Result, out MainID, out UpdateTime);

            GetFunctionName(FunNo.ToString());

            this.SLPUser.Text = UpdateID;
            this.txtUpDate.ReadOnly = false;
            this.txtUpDate.Text = UpdateDate;
            this.txtUpDate.ReadOnly = true;
            this.txtRemoveDate.Text = RemoveDate;
            if (txtRemoveDate.Text == "9999/12/31")
                txtRemoveDate.Text = DateTime.Now.ToString("yyyy/MM/dd");
            this.txtRemoveDate.ReadOnly = true;
            this.hid_ID.Value = MainID.ToString();
            this.hid_UpdateTime.Value = UpdateTime;
            
            if (this.SLPUser.Text == "x")
            {
                SLPUser.Text = "";
            }

            if (this.txtUpDate.Text == "x")
            {
                this.txtUpDate.Text = "";
            }

            if (RemoveReason != "NULL")
            {
                this.SLPReason.Text = RemoveReason;
            }
            else
            {
                DropDownList ddl = (DropDownList)this.SLPReason.FindControl("D1");
                ddl.SelectedIndex = 0;
            }

            if (RemoveNo != "NULL") //NULL代表還沒建過過移轉單
            {
                //建過了
                txtRemoveNo.Text = RemoveNo;
            }
            else
            {
                //還沒建過
                txtRemoveNo.Text = "";
            }

            pFunNo = FunNo.ToString();

            hid_Fun.Value = FunNo.ToString();

            if (Result == "0")
            {
                strErr = "查無此揀貨單號";
                GridView1.DataBind();
                btnEdit.Enabled = false;
                ErrorMsgLabel.Text = strErr;
                return;
            }
            else if (Result == "1")
            {
                strErr = "手開單無法修改,請直接建立移轉單";
                if (txtRemoveNo.Text != string.Empty)
                    strErr = "";
                GridView1.DataBind();
                btnEdit.Enabled = false;
                ErrorMsgLabel.Text = strErr;
                return;
            }

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

            GridView1.PageIndex = 0;
            GridView1.DataBind();

            //資料寫到前端
            MasterOLDData.InnerHtml = dtResult.DataSet.GetXml();

            if (this.hid_Page_Status.Value == "VIEW")
            {
                //this.GridView1.Columns[6].Visible = false;
                this.GridView1.Columns[9].Visible = false;
                this.GridView1.Columns[12].Visible = false;
                this.GridView1.Columns[13].Visible = false;
                //this.btnEdit.Enabled = true;
                //this.btnRemove.Enabled = true;
                //this.SLPReason.Enabled = true;
            }
            else if (this.hid_Page_Status.Value == "EDIT")
            {
                //this.GridView1.Columns[6].Visible = false;
                this.GridView1.Columns[9].Visible = false;
                //this.GridView1.Columns[13].Visible = false;

                if (pFunNo == "0" || pFunNo == "3" || pFunNo == "7" || pFunNo == "8")
                {
                    this.GridView1.Columns[12].Visible = false;

                }
            }

        }
        catch (Exception ex)
        {

            this.ErrorMsgLabel.Text =  ex.ToString();
        }
    }
示例#4
0
 public static string GetLocateSecByAttr(string LocateNo,string strAttr,string Item,string Period)
 {
     int OnHd_Qty = 0;
     IVMModel.MaintainRemoveByPick BCOIVM = new IVMModel.MaintainRemoveByPick(ConntionDB);
     ParameterList.Clear();
     ParameterList.Add(LocateNo);
     ParameterList.Add(strAttr);
     string LocateSec = BCOIVM.GetLocateSecByAttr(ParameterList);
     bool getSuccess = BCOIVM.GetStockQtyByLocateSec(Item, Period, LocateSec, out OnHd_Qty);
     if (getSuccess == false)
     {
         return LocateSec + "|" + "0";
     }
     else
     {
         return LocateSec + "|" + OnHd_Qty.ToString();
     } 
 }
示例#5
0
    protected void btnRemove_Click(object sender, EventArgs e)
    {
        try
        {
            //檢查資料是否完整

            DropDownList ddlReason = (DropDownList)this.SLPReason.FindControl("D1");

            if (ddlReason.SelectedIndex == 0)
            {
                ErrorMsgLabel.Text = "請選擇移轉原因";
                return;
            }

            if (pFunNo != "6")
            {

                DataSet Ds = new DataSet();

                if (MasterOLDData.InnerHtml != "")
                {
                    System.IO.StringReader sr = new System.IO.StringReader(MasterOLDData.InnerHtml);
                    Ds.ReadXml(sr);
                }

                if (Ds.Tables.Count == 0)
                {
                    ErrorMsgLabel.Text = "無資料可供產生移轉單";
                    return;
                }
                else
                {
                    for (int i = 0; i < Ds.Tables[0].Rows.Count; i++)
                    {
                        string FID = Ds.Tables[0].Rows[i]["FatherID"].ToString();
                        string BLocateSec = Ds.Tables[0].Rows[i]["Blocate_Section"].ToString();
                        string ELocateSec = Ds.Tables[0].Rows[i]["Elocate_Section"].ToString();
                        string PickQty = Ds.Tables[0].Rows[i]["real_pick_qty"].ToString();

                        if (FID == string.Empty || BLocateSec.Length != 6 || ELocateSec.Length != 6 || PickQty == string.Empty)
                        {
                            ErrorMsgLabel.Text = "資料輸入不完整";
                            return;
                        }
                    }
                }
            }

            string strErr = "";

            if (hidPickNo.Value != txtPickNo.Text)
            {
                strErr = "揀貨單號已被異動,請重新查詢揀貨資料";
                ErrorMsgLabel.Text = strErr;
                return;
            }

            string UserID = Session["UID"].ToString();
            string RemoveDate = DateTime.Now.ToString("yyyyMMddHHmmss");
            string UpdateTime = this.hid_UpdateTime.Value;
            string RemoveReason = SLPReason.Text;
            string PickNo = txtPickNo.Text;
            string RemoveNo = "";
            string strError = "";

            bool IsOK = false;

            if (pFunNo == string.Empty)
            {
                strErr = "無法判斷揀貨單類別,建立失敗";
                ErrorMsgLabel.Text = strErr;
                return;
            }

            ArrayList ErrorList = new ArrayList();

            IVMModel.MaintainRemoveByPick BCO = new IVMModel.MaintainRemoveByPick(ConntionDB);
            //IsOK = BCO.CreateRemoveByPick(UserID, RemoveDate, RemoveReason,pFunNo, PickNo,UpdateTime, null,out RemoveNo, out ErrorList);
            IsOK = BCO.CreateRemoveByPickNo(UserID, RemoveDate, RemoveReason, PickNo, UpdateTime, null, out RemoveNo, out strError);

            if (IsOK == true)
            {
                txtRemoveNo.Text = RemoveNo;
                Response.Redirect(string.Format("IVM161.aspx?Code=IVM16&PageMode=1&PickNo={0}", txtPickNo.Text));
            }
            else
            {
                //string strError = string.Empty;
                //ArrayList SignList = new ArrayList();
                //for (int i = 0; i < ErrorList.Count; i++)
                //{
                //    string ErrorSec = ErrorList[i].ToString();
                //    bool haveErr = false;
                //    for (int j = 0; j < SignList.Count; j++)
                //    {
                        
                //        if (ErrorSec == SignList[j].ToString()) 
                //        {
                //            haveErr = true;
                //        }
                //    } 
                //    if (haveErr == false)
                //    {
                //        SignList.Add(ErrorSec);
                //    }
                //}

                //for (int i = 0; i < SignList.Count; i++)
                //{
                //    if (i == SignList.Count - 1)
                //    {
                //        strError += SignList[i].ToString();
                //    }
                //    else
                //    {
                //        strError += SignList[i].ToString() + ",";
                //    }
                //}

                strErr = "建立移轉單失敗,由於" + strError +".";
                ErrorMsgLabel.Text = strErr;
                return;
            }


        }
        catch (Exception ex)
        {

            this.ErrorMsgLabel.Text = ex.ToString();
        }
    }
示例#6
0
    protected void btnSave_Click(object sender, EventArgs e)
    {
        bool IsOK = false;
        
        string ErroeLog = "";

        try
        {

            //UpdateGridView();

            DataSet Ds= new DataSet();

            if (MasterOLDData.InnerHtml != "")
            {
                System.IO.StringReader sr = new System.IO.StringReader(MasterOLDData.InnerHtml);
                Ds.ReadXml(sr);
            }

            bool Change = false;

            for(int i = 0 ;i<Ds.Tables[0].Rows.Count;i++)
            {
                string IsChange = Ds.Tables[0].Rows[i]["isChange"].ToString();
                if(IsChange == "New" || IsChange == "Y")
                {
                    Change = true;
                }
            }

            if(Change == false)
            {
                string strErr = "請更新資料後再進行儲存";
                ErrorMsgLabel.Text = strErr;
                return;
            }

            DataTable dtUpdate = Ds.Tables[0];

            string PickNo = Request.QueryString["PickNo"].ToString();
            string MainID = this.hid_ID.Value;
            string USERID = Session["UID"].ToString();
            string UpdateDate = DateTime.Now.ToString("yyyyMMddHHmmss");
            string UpdateTime = hid_UpdateTime.Value;
            IVMModel.MaintainRemoveByPick BCO = new IVMModel.MaintainRemoveByPick(ConntionDB);

            IsOK = BCO.DoUpdate(MainID,USERID,UpdateDate,UpdateTime,dtUpdate,null,out ErroeLog);

            if (IsOK == false)
            {
                string strErr = ErroeLog;
                ErrorMsgLabel.Text = strErr;
                return;
            }

            Response.Redirect(string.Format("IVM161.aspx?Code=IVM16&PageMode=1&PickNo={0}", PickNo));

        }
        catch (Exception ex)
        {

            this.ErrorMsgLabel.Text =  ex.ToString();
        }
    }
示例#7
0
 public static string GetLocateByAttr(string ELocateNo)
 {
     string LocateSection = "";
     //INVModel.MaintainStockTmpLocate BCO = new INVModel.MaintainStockTmpLocate(ConntionDB);
     IVMModel.MaintainRemoveByPick BCO = new IVMModel.MaintainRemoveByPick(ConntionDB);
     ParameterList.Clear();
     ParameterList.Add(ELocateNo);
     ParameterList.Add("1");
     LocateSection = BCO.GetLocateSecByAttr(ParameterList);
     return LocateSection;
 }
示例#8
0
 public static string GetTempLocate(string InSec)
 {
     try
     {
         IVMModel.MaintainRemoveByPick BCOStock = new IVMModel.MaintainRemoveByPick(ConntionDB);
         ParameterList.Clear();
         ParameterList.Add(InSec);
         ParameterList.Add("1");
         string InLocateSec = BCOStock.GetLocateSecByAttr(ParameterList);
         return InLocateSec;
     }
     catch
     {
         return "000000";
     }
 }
 protected void btnQuery_Click(object sender, EventArgs e)
 {
     IVMModel.MaintainRemoveByPick BCOIVM = new IVMModel.MaintainRemoveByPick(ConnectionDB);
     DataTable dtResult = BCOIVM.GetStockQtyByItem(lblItem.Text, lblPeriod.Text);
     this.GridView1.DataSource = dtResult;
     this.GridView1.DataBind();
 }