Beispiel #1
0
    protected void btnUpdateData_Click(object sender, EventArgs e)
    {
        try
        {

            string ErrMsg;
            string Resault;
            int Qty;

            if (int.TryParse(this.txtRevQty.Text, out Qty) == false || int.TryParse(this.txtRtnQty.Text, out Qty)==false)
            {
                ShowErr("上架/廠退數量格式錯誤");
                return;
            }

            //判斷數量是否正確
            //判斷是否大於安全庫存數量及是否超過移出庫存量
            int RevQty = Convert.ToInt32(txtRevQty.Text.Trim());
            int RtnQty = Convert.ToInt32(txtRtnQty.Text.Trim());
            int SafeQty = Convert.ToInt32(lblSafeQty.Text);
            int Onhd_OutQty = Convert.ToInt32(lblOnhdQtyOut.Text);
            int Onhd_InQty = Convert.ToInt32(lblOnhdQtyIn.Text);

            if (RevQty + RtnQty > Onhd_OutQty)
            {
                ShowErr("超過移出儲位庫存量");
                return;
            }

            if (lblNonStock.Text == "1" && RtnQty==0)
            {
                ShowErr("廠退數量不可為0");
                return;            
            }
            else if (lblNonStock.Text == "0")
            {
                if (RevQty == 0)
                {
                    ShowErr("上架數量不可為0");
                    return;
                }

                if (RevQty + Onhd_InQty > SafeQty && hidSafeFlg.Value == "1")
                {
                    ShowErr("超過安全庫存量");
                    return;
                }

                //判斷儲位是否正確
                if (slpInSection.Text1 != "D")
                {
                    ShowErr("不可輸入D以外儲區");
                    return;
                }

                IVMModel.VDS_IVM39_BCO dbo = new IVMModel.VDS_IVM39_BCO(ConntionDB);

                ParameterList.Clear();
                ParameterList.Add(slpITEM.Text);
                ParameterList.Add(txtPeriod.Text);
                ParameterList.Add(slpInSection.Text);

                dbo.CheckLocate(ParameterList, out Resault, out ErrMsg);

                if (Resault == "0")
                {
                    ShowErr(ErrMsg);
                    return;
                }
            }

            //更新
            DataTable dt = new DataTable();
            string SessionIDName = "IVM391_" + PageTimeStamp.Value;
            dt = (DataTable)Session[SessionIDName];
            DataRow dr = dt.Select("BARCODE = '" + lblPreBarcode.Text.Trim() + "'")[0];

            dr["INSECTION"] = slpInSection.Text;
            dr["REV_QTY"] = txtRevQty.Text;
            dr["RTN_QTY"] = txtRtnQty.Text;

            lblInSection.Text = slpInSection.Text;
            
            int Sort_ID = Convert.ToInt32(dt.Compute("max(Sort_ID)", "")) + 1;
            dr["Sort_ID"] = Sort_ID.ToString();

            dr.AcceptChanges();

            Session[SessionIDName] = dt;
            gv_Detail.DataSource = dt;
            gv_Detail.DataBind();

            UpdatePanel1.Update();


            //成功
            txtRevQty.ReadOnly = true;
            txtRevQty.CssClass = "readtxtbox";
            txtRtnQty.ReadOnly = true;
            txtRtnQty.CssClass = "readtxtbox";
            slpInSection.Text = "";
            slpInSection.Visible = false;
            lblInSection.Visible = true;
            txtBarCode.ReadOnly = false;
            txtBarCode.Text = "";
            txtBarCode.CssClass = "";
            Focus(txtBarCode.ClientID);

            btnUpdateData.Visible = false;
            btnCanCelUpdate.Visible = false;

        }
        catch
        {

        }
    }
Beispiel #2
0
    protected void btnCheck_Click(object sender, EventArgs e)
    {
        ErrorMsgLabel.Text = "";

        bool IsOk = false;

        int i = this.txtBarCode.Text.Trim().Length;

        if (i != 8 && i != 10 && i != 12 && i != 13 && i != 15 && i != 18)
        {
            ShowErr("條碼長度不正確");
            return;
        }

        if (lblPreBarcode.Text.Trim() != "")
        {

            if (lblPreBarcode.Text == txtBarCode.Text.Trim())
            {
                if (CheckQty())
                {
                    SetGV("InsertExistOnTop");
                    IsOk = true;
                }
                else
                    return;
            }
            else
            {
                ClearData();
            }
        }

        if (!IsOk)
        {

            DataTable dt_s = new DataTable();

            dt_s = CheckInGV();

            //如果條碼存在GridView中,則取出GridView的資料
            if (dt_s != null)
            {
                SetTopData(dt_s);

                if (CheckQty())
                {
                    SetGV("InsertExistOnGV");
                    IsOk = true;
                }
                else
                    return;
            }
            else
            {
                try
                {
                    IVMModel.VDS_IVM39_BCO dbo = new IVMModel.VDS_IVM39_BCO(ConntionDB);

                    DataTable dt_i = dbo.QueryITEM(txtBarCode.Text.Trim(),lblOutSection.Text);

                    if (dt_i.Rows.Count == 1)
                    {
                        if (dt_i.Rows[0]["ERRMSG"].ToString() == "")
                        {
                            SetTopData(dt_i);
                            SetGV("NEW");
                        }
                        else
                        {
                            SetTopData(dt_i);
                            lblPreBarcode.Text = "";
                            ShowErr(dt_i.Rows[0]["ERRMSG"].ToString());
                            return;
                        }
                    }
                    else
                    {
                        ShowErr("條碼找不到資料或找到多筆資料");
                        return;
                    }

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

        txtBarCode.Text = "";
        Focus(txtBarCode.ClientID);

    }