コード例 #1
0
        protected void BindData()
        {
            try
            {
                var dal = ProductDal.Instance;
                List <MasProduct> lst = new List <MasProduct>();

                MasProduct ModelSer = new MasProduct();

                ModelSer.ProductCode = txtCode.Text;
                ModelSer.ProductName = txtName.Text;
                lst = dal.GetSearchProduct(ModelSer);

                if (lst != null && lst.Count > 0)
                {
                    gv.DataSource = lst;
                }
                else
                {
                    gv.DataSource = null;
                }

                gv.DataBind();
            }
            catch (Exception ex)
            {
                SendMailError(ex.Message, System.Reflection.MethodBase.GetCurrentMethod());
            }
        }
コード例 #2
0
        protected void imgbtnEdit_Click(object sender, ImageClickEventArgs e)
        {
            List <MasProduct> lst = (List <MasProduct>)Session["DetailProdcut"];
            ImageButton       imb = (ImageButton)sender;

            if (imb != null)
            {
                Int32 id = ToInt32(imb.CommandArgument);
                //Int32 PackageDetailID = ToInt32(imb.CommandName);
                MasProduct Data = lst.FirstOrDefault(x => x.ProductID == id);

                hddProductID.Value  = Data.ProductID.ToString();
                txtProductCode.Text = Data.ProductCode;
                txtProductName.Text = Data.ProductName;
                //txtProductSellPrice.Text = Data.SellPrice.ToString("#,###0.00");
                txtProductAmount.Text = Data.Amount.ToString();
                ChkCanChange.Checked  = Data.CanChange == "Change" ? true : false;
                ChkIsFree.Checked     = Data.IsFree == "Y" ? true : false;

                //ModelDataAdd.CanChange = ChkCanChange.Checked == true ? "Change" : "Fix";
                hddProductMode.Value     = "Edit";
                hddPackageDetailID.Value = imb.CommandName;
            }

            ModalPopupExtender4.Show();
        }
コード例 #3
0
        protected void imgbtnDelete_Click(object sender, ImageClickEventArgs e)
        {
            try
            {
                var         dal = ProductDal.Instance;
                ImageButton imb = (ImageButton)sender;
                if (imb != null)
                {
                    MasProduct ModelData = new MasProduct();
                    string     objCode   = imb.CommandArgument;
                    ModelData.ProductCode = objCode;
                    ModelData.ProductID   = Convert.ToInt32(objCode);
                    ModelData.Active      = "N";
                    ModelData.CreatedBy   = GetUsername();
                    ModelData.DMLFlag     = "D";
                    dal.InsUpdDelMasProduct(ModelData);

                    BindData();
                }
                else
                {
                    SendMailError("imb is null", System.Reflection.MethodBase.GetCurrentMethod());
                }
            }
            catch (Exception ex)
            {
                ShowMessageBox("เกิดข้อผิดพลาด กรุณาติดต่อผู้ดูแลระบบ.");
                SendMailError(ex.Message, System.Reflection.MethodBase.GetCurrentMethod());
            }
        }
コード例 #4
0
        protected void imgbtnChooseItem_Click(object sender, ImageClickEventArgs e)
        {
            var         dal = ProductDal.Instance;
            ImageButton imb = (ImageButton)sender;

            if (imb != null)
            {
                //int rowIndex = Convert.ToInt32(imb.CommandArgument);
                int         objCode = ToInt32(imb.CommandArgument);
                HiddenField hdd     = (HiddenField)gvItemSearch.Rows[objCode].FindControl("hddItemID");
                if (hdd != null)
                {
                    int        pid       = ToInt32(hdd.Value);
                    MasProduct ModelData = new MasProduct();
                    ModelData = dal.GetSearchProductID(pid);
                    if (ModelData.ProductName != null)
                    {
                        hddProductID.Value  = ModelData.ProductID.ToString();
                        txtProductCode.Text = ModelData.ProductCode;
                        txtProductName.Text = ModelData.ProductName;
                        //txtProductSellPrice.Text = ModelData.SellPrice.ToString("#,###0.00");
                    }
                }
            }

            ModalPopupExtender4.Show();
        }
コード例 #5
0
ファイル: ProductDal.cs プロジェクト: Champpy/Prowelding
        public string InsUpdDelMasProductHeadQ(MasProduct item)
        {
            string err = "";

            try
            {
                List <SqlParameter> paramI = new List <SqlParameter>();
                paramI.Add(new SqlParameter()
                {
                    ParameterName = "ProductID", Value = item.ProductID, DbType = DbType.Int32
                });
                paramI.Add(new SqlParameter()
                {
                    ParameterName = "ProductCode", Value = item.ProductCode
                });
                paramI.Add(new SqlParameter()
                {
                    ParameterName = "ProductName", Value = item.ProductName
                });
                paramI.Add(new SqlParameter()
                {
                    ParameterName = "PurchasePrice", Value = item.PurchasePrice, DbType = DbType.Double
                });
                paramI.Add(new SqlParameter()
                {
                    ParameterName = "SellPrice", Value = item.SellPrice, DbType = DbType.Double
                });
                paramI.Add(new SqlParameter()
                {
                    ParameterName = "Active", Value = item.Active, DbType = DbType.String
                });
                paramI.Add(new SqlParameter()
                {
                    ParameterName = "CreatedBy", Value = item.CreatedBy, DbType = DbType.String
                });
                paramI.Add(new SqlParameter()
                {
                    ParameterName = "UnitID", Value = item.UnitID, DbType = DbType.Int32
                });
                paramI.Add(new SqlParameter()
                {
                    ParameterName = "TypeID", Value = item.TypeID, DbType = DbType.Int32
                });
                paramI.Add(new SqlParameter()
                {
                    ParameterName = "Remaining", Value = item.Remaining, DbType = DbType.Int32
                });
                paramI.Add(new SqlParameter()
                {
                    ParameterName = "DMLFlag", Value = item.DMLFlag
                });

                conn.ExcuteNonQueryNClose("InsUpdDelMasProductHeadQ", paramI, out err);
            }
            catch (Exception ex)
            {
                err = ex.Message;
            }
            return(err);
        }
コード例 #6
0
        private Int32 GetProductIDSerialByPackageHeaderID(Int32 PackageHeaderID)
        {
            Int32 result = 0;

            try
            {
                #region Get Product ID
                MasPackageHeader mph = new MasPackageHeader()
                {
                    PackageHeaderID = PackageHeaderID
                };
                var bal = PackageDal.Instance;
                List <MasProduct> lstProduct = bal.GetSearchPackageDetail(mph);
                if (lstProduct != null && lstProduct.Count > 0)
                {
                    MasProduct mp = lstProduct.FirstOrDefault(w => w.ProductSN.ToLower().Equals("y"));
                    if (mp != null)
                    {
                        result = mp.ProductID;
                    }
                }
                #endregion
            }
            catch (Exception ex)
            {
            }
            return(result);
        }
コード例 #7
0
        private void SaveProductDetail()
        {
            List <MasProduct> lst          = (List <MasProduct>)Session["DetailProdcut"];
            MasProduct        ModelDataAdd = new MasProduct();

            //if (hddProductMode.Value == "Add")
            //{
            //    if (lst.Where(x => x.ProductCode == txtProductCode.Text).ToList().Count > 0)
            //    {
            //        ShowMessageBox("รหัสสินค้านี้ มีอยู่ใน list แล้ว!!!");
            //        ModalPopupExtender4.Show();
            //        return;
            //    }
            //}

            if (hddProductMode.Value != "Add")
            {
                Int32 id = ToInt32(hddPackageDetailID.Value);
                ModelDataAdd = lst.FirstOrDefault(x => x.PackageDetailID == id);
            }

            if (ModelDataAdd == null)
            {
                ModelDataAdd = new MasProduct();
            }

            ModelDataAdd.ProductID   = Convert.ToInt32(hddProductID.Value);
            ModelDataAdd.ProductCode = txtProductCode.Text;
            ModelDataAdd.ProductName = txtProductName.Text;
            //ModelDataAdd.SellPrice = Convert.ToDouble(txtProductSellPrice.Text);
            ModelDataAdd.Amount    = Convert.ToInt32(txtProductAmount.Text);
            ModelDataAdd.CanChange = ChkCanChange.Checked == true ? "Change" : "Fix";
            ModelDataAdd.IsFree    = ChkIsFree.Checked == true ? "Y" : "N";
            ModelDataAdd.DMLFlag   = "I";
            ModelDataAdd.Active    = "Y";
            ModelDataAdd.CreatedBy = GetUsername();
            //chkCOD.Checked = string.IsNullOrEmpty(obj.COD) ? false : obj.COD.Equals("0") ? false : true;

            if (hddProductMode.Value == "Add")
            {
                ModelDataAdd.PackageDetailID = (lst.Count + 1) * -1;
                lst.Add(ModelDataAdd);
            }
            //else if (hddProductMode.Value == "Edit")
            //{
            //    Int32 pdID = ToInt32(hddPackageDetailID.Value);
            //}
            CleartxtDetail();

            Session["DetailProdcut"] = lst;
            BindDataGrid();
        }
コード例 #8
0
        protected void imgbtnEdit_Click(object sender, ImageClickEventArgs e)
        {
            var dal = ProductDal.Instance;

            try
            {
                ImageButton imb = (ImageButton)sender;

                if (imb != null)
                {
                    Int32 obj = ToInt32(imb.CommandArgument);
                    //BindDDL();

                    MasProduct ModelData = dal.GetSearchProductID(obj);
                    if (ModelData != null)
                    {
                        hddID.Value           = imb.CommandArgument;
                        txtMCode.Text         = ModelData.ProductCode;
                        txtMName.Text         = ModelData.ProductName;
                        ddlUnit.SelectedIndex = ToInt32(ddlUnit.Items.FindByValue(ModelData.UnitID.ToString()).Value);
                        ddlType.SelectedIndex = ToInt32(ddlType.Items.FindByValue(ModelData.TypeID.ToString()).Value);
                        //ddlUnit.Items.FindByValue(ModelData.UnitID.ToString()).Selected = true;
                        //ddlType.Items.FindByValue(ModelData.TypeID.ToString()).Selected = true;
                        chkSN.Checked = ModelData.ProductSN == "Y" ? true : false;
                        //ddlUnit.SelectedIndex = ddlUnit.Items.FindByValue().Selected;
                        //txtMPurchasePrice.Text = ModelData.PurchasePrice.ToString("###,##0");
                        //txtMPrice.Text = ModelData.SellPrice.ToString("###,##0");
                        ModalPopupExtender1.Show();
                        hddMode.Value    = "Edit";
                        txtMCode.Enabled = false;
                    }
                    else
                    {
                        SendMailError("obj is null, objID = " + imb.CommandArgument, System.Reflection.MethodBase.GetCurrentMethod());
                    }
                }
                else
                {
                    SendMailError("imb is null", System.Reflection.MethodBase.GetCurrentMethod());
                }
            }
            catch (Exception ex)
            {
                ShowMessageBox("เกิดข้อผิดพลาด กรุณาติดต่อผู้ดูแลระบบ.");
                SendMailError(ex.Message, System.Reflection.MethodBase.GetCurrentMethod());
            }
        }
コード例 #9
0
ファイル: ProductDal.cs プロジェクト: Champpy/Prowelding
        public List <MasProduct> GetSearchProductHeadQ(MasProduct item)
        {
            List <MasProduct> lst = new List <MasProduct>();

            try
            {
                List <SqlParameter> param = new List <SqlParameter>();

                param.Add(new SqlParameter()
                {
                    ParameterName = "ProductCode", Value = item.ProductCode
                });
                param.Add(new SqlParameter()
                {
                    ParameterName = "ProductName", Value = item.ProductName
                });

                DataSet ds = conn.GetDataSet("GetSearchProductAll", param);

                if (ds != null && ds.Tables.Count > 0 && ds.Tables[0] != null)
                {
                    MasProduct o = new MasProduct();
                    foreach (DataRow dr in ds.Tables[0].Rows)
                    {
                        o                = new MasProduct();
                        o.ProductID      = Convert.ToInt32(dr["ProductID"].ToString());
                        o.ProductCode    = dr["ProductCode"].ToString();
                        o.ProductName    = dr["ProductName"].ToString();
                        o.Remaining      = Convert.ToInt32(dr["Remaining"].ToString());
                        o.RemainingHeadQ = Convert.ToInt32(dr["RemainingHeadQ"].ToString());
                        o.Active         = dr["Active"].ToString();
                        o.PurchasePrice  = Convert.ToDouble(dr["PurchasePrice"].ToString());
                        o.SellPrice      = Convert.ToDouble(dr["SellPrice"].ToString());
                        o.CreatedBy      = dr["CreatedBy"].ToString();
                        o.CreatedDate    = Convert.ToDateTime(dr["CreatedDate"].ToString());
                        o.UpdatedBy      = dr["UpdatedBy"].ToString();
                        o.UpdatedDate    = Convert.ToDateTime(dr["UpdatedDate"].ToString());

                        lst.Add(o);
                    }
                }
            }
            catch (Exception ex)
            {
            }
            return(lst);
        }
コード例 #10
0
        public List <MasProduct> GetSearchPackageDetail(MasPackageHeader ModelSer)
        {
            MasProduct        item    = new MasProduct();
            List <MasProduct> lstData = new List <MasProduct>();

            try
            {
                List <SqlParameter> param = new List <SqlParameter>();
                param.Add(new SqlParameter()
                {
                    ParameterName = "PackageHeaderID", Value = ModelSer.PackageHeaderID, DbType = DbType.String
                });

                DataSet ds = conn.GetDataSet("GetSearchPackageDetail", param);

                if (ds != null && ds.Tables.Count > 0 && ds.Tables[0] != null)
                {
                    foreach (DataRow dr in ds.Tables[0].Rows)
                    {
                        item                 = new MasProduct();
                        item.ProductID       = string.IsNullOrEmpty(dr["ProductID"].ToString()) ? 0 : Convert.ToInt32(dr["ProductID"].ToString());
                        item.ProductCode     = dr["ProductCode"].ToString();
                        item.ProductName     = dr["ProductName"].ToString();
                        item.Amount          = string.IsNullOrEmpty(dr["Amount"].ToString()) ? 0 : Convert.ToInt32(dr["Amount"].ToString());
                        item.Active          = dr["Active"].ToString();
                        item.SellPrice       = string.IsNullOrEmpty(dr["SellPrice"].ToString()) ? 0 : Convert.ToDouble(dr["SellPrice"].ToString());
                        item.CreatedBy       = dr["CreatedBy"].ToString();
                        item.CreatedDate     = Convert.ToDateTime(dr["CreatedDate"].ToString());
                        item.UpdatedBy       = dr["UpdatedBy"].ToString();
                        item.UpdatedDate     = Convert.ToDateTime(dr["UpdatedDate"].ToString());
                        item.CanChange       = dr["CanChange"].ToString() == "Y" ? "Change" : "Fix";
                        item.DMLFlag         = "I";
                        item.ProductSN       = dr["ProductSN"].ToString();
                        item.IsFree          = dr["IsFree"].ToString();
                        item.PackageDetailID = string.IsNullOrEmpty(dr["PackageDetailID"].ToString()) ? 0 : Convert.ToInt32(dr["PackageDetailID"].ToString());
                        lstData.Add(item);
                    }
                }
            }
            catch (Exception ex)
            {
            }
            return(lstData);
        }
コード例 #11
0
ファイル: ProductDal.cs プロジェクト: Champpy/Prowelding
        public MasProduct GetSearchProductID(Int32 ProductID)
        {
            MasProduct item = new MasProduct();

            try
            {
                List <SqlParameter> param = new List <SqlParameter>();
                param.Add(new SqlParameter()
                {
                    ParameterName = "ProductID", Value = ProductID, DbType = DbType.Int32
                });

                DataSet ds = conn.GetDataSet("GetProductByID", param);
                if (ds != null && ds.Tables.Count > 0 && ds.Tables[0] != null)
                {
                    foreach (DataRow dr in ds.Tables[0].Rows)
                    {
                        item.ProductID     = Convert.ToInt32(dr["ProductID"].ToString());
                        item.ProductCode   = dr["ProductCode"].ToString();
                        item.ProductName   = dr["ProductName"].ToString();
                        item.Active        = dr["Active"].ToString();
                        item.PurchasePrice = string.IsNullOrEmpty(dr["PurchasePrice"].ToString()) ? 0 : Convert.ToDouble(dr["PurchasePrice"].ToString());
                        item.SellPrice     = string.IsNullOrEmpty(dr["SellPrice"].ToString()) ? 0 : Convert.ToDouble(dr["SellPrice"].ToString());
                        item.CreatedBy     = dr["CreatedBy"].ToString();
                        item.CreatedDate   = Convert.ToDateTime(dr["CreatedDate"].ToString());
                        item.UpdatedBy     = dr["UpdatedBy"].ToString();
                        item.UpdatedDate   = Convert.ToDateTime(dr["UpdatedDate"].ToString());
                        item.UnitID        = string.IsNullOrEmpty(dr["UnitID"].ToString()) ? 0 : Convert.ToInt32(dr["UnitID"].ToString());
                        item.TypeID        = string.IsNullOrEmpty(dr["TypeID"].ToString()) ? 0 : Convert.ToInt32(dr["TypeID"].ToString());
                        item.ProductSN     = dr["ProductSN"].ToString();

                        break;
                    }
                }
            }
            catch (Exception ex)
            {
            }
            return(item);
        }
コード例 #12
0
ファイル: ProductDal.cs プロジェクト: Champpy/Prowelding
        public MasProduct ValidateProductData(string ProductCode, string ProductName, int ProductID)
        {
            MasProduct item = new MasProduct();

            try
            {
                List <SqlParameter> param = new List <SqlParameter>();
                param.Add(new SqlParameter()
                {
                    ParameterName = "ProductID", Value = ProductID, DbType = DbType.Int32
                });
                param.Add(new SqlParameter()
                {
                    ParameterName = "ProductCode", Value = ProductCode, DbType = DbType.String
                });
                param.Add(new SqlParameter()
                {
                    ParameterName = "ProductName", Value = ProductName, DbType = DbType.String
                });

                DataSet ds = conn.GetDataSet("ValidateProductData", param);
                if (ds != null && ds.Tables.Count > 0 && ds.Tables[0] != null)
                {
                    foreach (DataRow dr in ds.Tables[0].Rows)
                    {
                        item.CHK_PRODUCT_CODE = Convert.ToInt32(dr["CHK_PRODUCT_CODE"].ToString());
                        item.CHK_PRODUCT_NAME = Convert.ToInt32(dr["CHK_PRODUCT_NAME"].ToString());
                        item.CHK_CODE_NAME    = Convert.ToInt32(dr["CHK_CODE_NAME"].ToString());
                    }
                }
            }
            catch (Exception ex)
            {
            }
            return(item);
        }
コード例 #13
0
        protected void btnModalSave_Click(object sender, EventArgs e)
        {
            try
            {
                var dal = ProductDal.Instance;

                if (txtMName.Text == "")
                {
                    ShowMessageBox("กรุณาระบุ สินค้า !!!");
                    ModalPopupExtender1.Show();
                    return;
                }

                //MasProduct ModelData = dal.GetSearchProductCode(txtMCode.Text.Trim());
                MasProduct ModelData = dal.ValidateProductData(txtMCode.Text.Trim(), txtMName.Text.Trim(), ToInt32(hddID.Value));

                if (ModelData.CHK_CODE_NAME == 1)
                {
                    ShowMessageBox("รหัสสินค้าและชื่อสินค้า ห้ามเหมือนกัน !!!");
                    ModalPopupExtender1.Show();
                    return;
                }

                if (ModelData.CHK_PRODUCT_CODE == 1)
                {
                    ShowMessageBox("รหัสสินค้า นี้ซ้ำ !!!");
                    ModalPopupExtender1.Show();
                    return;
                }
                else if (ModelData.CHK_PRODUCT_CODE == 2)
                {
                    ShowMessageBox("รหัสสินค้านี้ซ้ำกับชื่อสินค้าอื่น !!!");
                    ModalPopupExtender1.Show();
                    return;
                }

                if (ModelData.CHK_PRODUCT_NAME == 1)
                {
                    ShowMessageBox("ชื่อสินค้า นี้ซ้ำ !!!");
                    ModalPopupExtender1.Show();
                    return;
                }
                else if (ModelData.CHK_PRODUCT_NAME == 2)
                {
                    ShowMessageBox("ชื่อสินค้านี้ซ้ำกับรหัสสินค้าอื่น !!!");
                    ModalPopupExtender1.Show();
                    return;
                }

                //if (ModelData.ProductCode != null && hddMode.Value == "Add")
                //{
                //    ShowMessageBox("รหัสสินค้า นี้ซ้ำ !!!");
                //    ModalPopupExtender1.Show();
                //    return;
                //}

                MasProduct o = new MasProduct();
                if (hddMode.Value == "Add") // Add
                {
                    o                = new MasProduct();
                    o.ProductCode    = txtMCode.Text;
                    o.ProductName    = txtMName.Text;
                    o.UnitID         = ToInt32(ddlUnit.SelectedItem.Value);
                    o.TypeID         = ToInt32(ddlType.SelectedItem.Value);
                    o.Remaining      = 0;
                    o.RemainingHeadQ = 0;
                    o.ProductSN      = chkSN.Checked ? "Y" : "N";
                    //o.PurchasePrice = ToDoudle(txtMPurchasePrice.Text);
                    //o.SellPrice = ToDoudle(txtMPrice.Text);
                    o.Active      = "Y";
                    o.CreatedBy   = GetUsername();
                    o.CreatedDate = DateTime.Now;
                    o.DMLFlag     = "I".ToUpper();


                    dal.InsUpdDelMasProduct(o);
                }
                else //Edit
                {
                    o                = new MasProduct();
                    o.ProductID      = ToInt32(hddID.Value);
                    o.ProductCode    = txtMCode.Text;
                    o.ProductName    = txtMName.Text;
                    o.UnitID         = ToInt32(ddlUnit.SelectedItem.Value);
                    o.TypeID         = ToInt32(ddlType.SelectedItem.Value);
                    o.Remaining      = 0;
                    o.RemainingHeadQ = 0;
                    o.ProductSN      = chkSN.Checked ? "Y" : "N";
                    //o.PurchasePrice = ToDoudle(txtMPurchasePrice.Text);
                    //o.SellPrice = ToDoudle(txtMPrice.Text);
                    o.Active      = "Y";
                    o.CreatedBy   = GetUsername();
                    o.CreatedDate = DateTime.Now;
                    o.DMLFlag     = "U".ToUpper();

                    dal.InsUpdDelMasProduct(o);
                }

                txtMCode.Enabled = true;
                BindData();
                ShowMessageBox("บันทึกข้อมูลสำเร็จ.");
            }
            catch (Exception ex)
            {
                ShowMessageBox("เกิดข้อผิดพลาด กรุณาติดต่อผู้ดูแลระบบ.");
                SendMailError(ex.Message, System.Reflection.MethodBase.GetCurrentMethod());
            }
        }
コード例 #14
0
        protected void btnModalSave_Click(object sender, EventArgs e)
        {
            try
            {
                var dal = ProductDal.Instance;

                if (txtMName.Text == "")
                {
                    ShowMessageBox("กรุณาระบุ สินค้า !!!");
                    ModalPopupExtender1.Show();
                    return;
                }

                MasProduct ModelData = dal.GetSearchProductCode(txtMCode.Text.Trim());

                if (ModelData.ProductCode != null && hddMode.Value == "Add")
                {
                    ShowMessageBox("รหัสสินค้า นี้ซ้ำ !!!");
                    ModalPopupExtender1.Show();
                    return;
                }

                MasProduct o = new MasProduct();
                if (hddMode.Value == "Add") // Add
                {
                    o             = new MasProduct();
                    o.ProductCode = txtMCode.Text;
                    o.ProductName = txtMName.Text;
                    //o.PurchasePrice = ToDoudle(txtMPurchasePrice.Text);
                    //o.SellPrice = ToDoudle(txtMPrice.Text);
                    o.Active      = "Y";
                    o.CreatedBy   = GetUsername();
                    o.CreatedDate = DateTime.Now;
                    o.DMLFlag     = "I".ToUpper();


                    dal.InsUpdDelMasProductHeadQ(o);
                }
                else //Edit
                {
                    o             = new MasProduct();
                    o.ProductID   = ToInt32(hddID.Value);
                    o.ProductCode = txtMCode.Text;
                    o.ProductName = txtMName.Text;
                    //o.PurchasePrice = ToDoudle(txtMPurchasePrice.Text);
                    //o.SellPrice = ToDoudle(txtMPrice.Text);
                    o.Active      = "Y";
                    o.CreatedBy   = GetUsername();
                    o.CreatedDate = DateTime.Now;
                    o.DMLFlag     = "U".ToUpper();

                    dal.InsUpdDelMasProductHeadQ(o);
                }

                txtMCode.Enabled = true;
                BindData();
                ShowMessageBox("บันทึกข้อมูลสำเร็จ.");
            }
            catch (Exception ex)
            {
                ShowMessageBox("เกิดข้อผิดพลาด กรุณาติดต่อผู้ดูแลระบบ.");
                SendMailError(ex.Message, System.Reflection.MethodBase.GetCurrentMethod());
            }
        }
コード例 #15
0
        protected void btnM6Add_Click(object sender, EventArgs e)
        {
            try
            {
                //Validate
                if (string.IsNullOrEmpty(txtM6SN.Text))
                {
                    ShowMessageBox("Add Serial Number First. !!!");
                    return;
                }

                Int32 Amt       = ToInt32(txtm5Amount.Text);
                int   productID = ToInt32(hddM6ProductID.Value);
                List <StockDetail>        lst    = new List <StockDetail>();
                List <TransProductSerial> lstTPS = new List <TransProductSerial>();
                TransProductSerial        tps    = new TransProductSerial();
                if (Session["StockDetail"] != null)
                {
                    lst = (List <StockDetail>)Session["StockDetail"];
                    StockDetail o = lst.FirstOrDefault(w => w.ProductID.Equals(productID));
                    if (o != null)
                    {
                        if (o.lstSerial == null)
                        {
                            o.lstSerial = new List <TransProductSerial>();
                        }
                        else
                        {
                            if (o.Amount <= o.lstSerial.Count)
                            {
                                ShowMessageBox("Serial Number Too much.");
                                ModalPopupExtender6.Show();
                                return;
                            }
                        }

                        //Check S/N Duplicate
                        tps = o.lstSerial.FirstOrDefault(w => w.SerialNumber.Trim().Equals(txtM6SN.Text.Trim()));
                        if (tps != null)
                        {
                            ShowMessageBox("Serial Number is duplicate.");
                            ModalPopupExtender6.Show();
                            return;
                        }

                        tps              = new TransProductSerial();
                        tps.ProductID    = productID;
                        tps.SerialNumber = txtM6SN.Text.Trim();
                        o.lstSerial.Add(tps);

                        //Binding
                        BindGridSerial(o.lstSerial);
                    }
                    else
                    {
                        if (Session["StockProductList"] != null)
                        {
                            List <MasProduct> lstProduct = (List <MasProduct>)Session["StockProductList"];
                            if (lstProduct != null && lstProduct.Count > 0)
                            {
                                MasProduct pd = lstProduct.FirstOrDefault(w => w.ProductID.Equals(productID));
                                if (pd != null)
                                {
                                    lstTPS = new List <TransProductSerial>();

                                    tps              = new TransProductSerial();
                                    tps.ProductID    = productID;
                                    tps.SerialNumber = txtM6SN.Text.Trim();
                                    lstTPS.Add(tps);

                                    lst.Add(new StockDetail()
                                    {
                                        ProductID       = productID,
                                        ProductCode     = pd.ProductCode,
                                        ProductName     = pd.ProductName,
                                        ProductTypeID   = pd.TypeID,
                                        ProductTypeName = pd.TypeName,
                                        Amount          = Amt,
                                        lstSerial       = lstTPS,
                                    });

                                    //Binding
                                    BindGridSerial(lstTPS);
                                }
                            }
                        }
                    }
                }
                else
                {
                    if (Session["StockProductList"] != null)
                    {
                        List <MasProduct> lstProduct = (List <MasProduct>)Session["StockProductList"];
                        if (lstProduct != null && lstProduct.Count > 0)
                        {
                            MasProduct pd = lstProduct.FirstOrDefault(w => w.ProductID.Equals(productID));
                            if (pd != null)
                            {
                                lstTPS           = new List <TransProductSerial>();
                                tps              = new TransProductSerial();
                                tps.ProductID    = productID;
                                tps.SerialNumber = txtM6SN.Text.Trim();
                                lstTPS.Add(tps);

                                //Binding
                                BindGridSerial(lstTPS);

                                lst.Add(new StockDetail()
                                {
                                    ProductID       = productID,
                                    ProductCode     = pd.ProductCode,
                                    ProductName     = pd.ProductName,
                                    ProductTypeID   = pd.TypeID,
                                    ProductTypeName = pd.TypeName,
                                    Amount          = Amt,
                                    lstSerial       = lstTPS,
                                });
                            }
                        }
                    }
                }
                //Clear Txt
                txtM6SN.Text = "";

                //Save Session
                Session["StockDetail"] = lst;

                ModalPopupExtender6.Show();
            }
            catch (Exception ex)
            {
            }
        }
コード例 #16
0
        protected void btnm5OK_Click(object sender, EventArgs e)
        {
            try
            {
                Int32 Amt       = ToInt32(txtm5Amount.Text);
                Int32 ProductID = ToInt32(hddm5Index.Value);

                if (Session["StockProductList"] != null)
                {
                    List <MasProduct> lstProduct = (List <MasProduct>)Session["StockProductList"];
                    if (lstProduct != null && lstProduct.Count > 0)
                    {
                        MasProduct o = lstProduct.FirstOrDefault(w => w.ProductID.Equals(ProductID));
                        if (o != null)
                        {
                            if (o.ProductSN == "Y")
                            {
                                List <StockDetail> lst = new List <StockDetail>();
                                if (Session["StockDetail"] != null)
                                {
                                    lst = (List <StockDetail>)Session["StockDetail"];
                                }

                                StockDetail s = lst.FirstOrDefault(w => w.ProductID.Equals(ProductID));
                                if (s != null)
                                {
                                    s.lstSerial = new List <TransProductSerial>();
                                    s.Amount    = Amt;
                                }

                                ClearModal6();

                                lbM6Header.Text      = o.ProductName + " (" + Amt.ToString() + ")";
                                hddM6ProductID.Value = hddm5Index.Value;

                                ModalPopupExtender6.Show();
                            }
                            else
                            {
                                List <StockDetail> lst = new List <StockDetail>();
                                if (Session["StockDetail"] != null)
                                {
                                    lst = (List <StockDetail>)Session["StockDetail"];
                                }

                                StockDetail s = lst.FirstOrDefault(w => w.ProductID.Equals(ProductID));
                                if (s == null)
                                {
                                    lst.Add(new StockDetail()
                                    {
                                        ProductID       = ProductID,
                                        ProductCode     = o.ProductCode,
                                        ProductName     = o.ProductName,
                                        ProductTypeID   = o.TypeID,
                                        ProductTypeName = o.TypeName,
                                        Amount          = Amt,
                                    });
                                }
                                else // Found In List
                                {
                                    s.Amount = s.Amount + Amt;
                                }

                                Session["StockDetail"] = lst;
                                BindDataDetail();
                            }
                        }
                    }
                }
                else
                {
                    ShowMessageBox("Session Timeout. !!", this, "../Index.aspx");
                }


                #region Comment
                //List<StockDetail> lst = new List<StockDetail>();
                //if(Session["StockDetail"] != null)
                //    lst = (List<StockDetail>)Session["StockDetail"];

                //if(Session["StockProductList"] != null)
                //{
                //    List<MasProduct> lstProduct = (List<MasProduct>)Session["StockProductList"];
                //    if(lstProduct != null && lstProduct.Count > 0)
                //    {
                //        MasProduct o = lstProduct.FirstOrDefault(w => w.ProductID.Equals(ProductID));
                //        if(o != null)
                //        {
                //            StockDetail s = lst.FirstOrDefault(w => w.ProductID.Equals(ProductID));
                //            if(s == null)
                //            {
                //                lst.Add(new StockDetail()
                //                {
                //                    ProductID = ProductID,
                //                    ProductCode = o.ProductCode,
                //                    ProductName = o.ProductName,
                //                    ProductTypeID = o.TypeID,
                //                    ProductTypeName = o.TypeName,
                //                    Amount = Amt,
                //                });
                //            }
                //            else // Found In List
                //            {
                //                s.Amount = s.Amount + Amt;
                //            }

                //            Session["StockDetail"] = lst;
                //            BindDataDetail();
                //        }
                //    }
                //}
                //else
                //{
                //    //ShowMessageBox("Session Timeout. !!", this, "../Index.aspx");
                //}
                #endregion
            }
            catch (Exception ex)
            {
            }
        }