Example #1
0
        public List <TransProductSerial> GetSearchTransProductSerial(string ProductName, string SerialNumber)
        {
            List <TransProductSerial> lst = new List <TransProductSerial>();

            try
            {
                List <SqlParameter> param = new List <SqlParameter>();
                param.Add(new SqlParameter()
                {
                    ParameterName = "ProductName", Value = ProductName
                });
                param.Add(new SqlParameter()
                {
                    ParameterName = "SerialNumber", Value = SerialNumber
                });
                DataSet ds = conn.GetDataSet("GetSearchTransProductSerial", param);
                if (ds != null && ds.Tables.Count > 0 && ds.Tables[0] != null)
                {
                    TransProductSerial o = new TransProductSerial();
                    foreach (DataRow dr in ds.Tables[0].Rows)
                    {
                        o              = new TransProductSerial();
                        o.ProductName  = dr["ProductName"].ToString();
                        o.SerialNumber = dr["SerialNumber"].ToString();
                        o.Status       = dr["Status"].ToString();
                        lst.Add(o);
                    }
                }
            }
            catch (Exception ex)
            {
            }
            return(lst);
        }
Example #2
0
        protected void imgbtnDeleteSN_Click(object sender, ImageClickEventArgs e)
        {
            try
            {
                ImageButton        imb = (ImageButton)sender;
                List <StockDetail> lst = new List <StockDetail>();
                if (Session["StockDetailHeadQ"] != null && imb != null)
                {
                    lst = (List <StockDetail>)Session["StockDetailHeadQ"];
                    int productID = ToInt32(hddm5Index.Value);
                    productID = GetProductIDSerialByPackageHeaderID(productID);
                    StockDetail o = lst.FirstOrDefault(w => w.ProductID.Equals(productID));
                    if (o != null)
                    {
                        TransProductSerial tps = o.lstSerial.FirstOrDefault(w => w.SerialNumber.Equals(imb.CommandName));
                        if (tps != null)
                        {
                            o.lstSerial.Remove(tps);
                        }

                        //Binding
                        BindGridSerial(o.lstSerial, productID);

                        //Save Session
                        Session["StockDetailHeadQ"] = lst;
                    }
                    else
                    {
                        List <TransProductSerial> lstSN = new List <TransProductSerial>();
                        if (Session["StockDetailHeadQSerial"] != null)
                        {
                            lstSN = (List <TransProductSerial>)Session["StockDetailHeadQSerial"];
                        }

                        lstSN.RemoveAll(w => w.ProductID.Equals(productID));

                        //Binding
                        BindGridSerial(null, productID);
                    }
                }
                else
                {
                    ShowMessageBox("Session Timeout. !!", this, "../Index.aspx");
                }


                ModalPopupExtender6.Show();
            }
            catch (Exception ex)
            {
            }
        }
Example #3
0
        protected void btnM6Add_Click(object sender, EventArgs e)
        {
            try
            {
                //Validate
                if (string.IsNullOrEmpty(txtM6SN.Text))
                {
                    ShowMessageBox("Add Serial Number First. !!!");
                    ModalPopupExtender6.Show();
                    return;
                }

                string   strTmp = txtM6SN.Text + ",";
                string[] ArrSN  = strTmp.Split(',');
                if (ArrSN != null && ArrSN.Length > 0)
                {
                    Int32 cnt = ArrSN.Where(w => !string.IsNullOrEmpty(w)).Count();
                    //Validate
                    if (cnt == 0)
                    {
                        ShowMessageBox("Add Serial Number First. !!!");
                        ModalPopupExtender6.Show();
                        return;
                    }
                    ArrSN = ArrSN.Where(w => !string.IsNullOrEmpty(w)).ToArray();
                    Int32 PackageHeaderID = ToInt32(hddm5Index.Value);
                    Int32 ProductID       = GetProductIDSerialByPackageHeaderID(PackageHeaderID);

                    Int32 Amt = ToInt32(txtm5Amount.Text);
                    TransProductSerial        tps = new TransProductSerial();
                    List <TransProductSerial> lst = new List <TransProductSerial>();
                    List <TransProductSerial> tmp = new List <TransProductSerial>();
                    if (Session["StockDetailHeadQSerial"] != null)
                    {
                        lst = (List <TransProductSerial>)Session["StockDetailHeadQSerial"];
                    }

                    #region Validate
                    //Check Amount
                    if (Amt <= lst.Count(w => w.ProductID.Equals(ProductID)) || Amt < lst.Count(w => w.ProductID.Equals(ProductID)) + cnt)
                    {
                        ShowMessageBox("Serial Number Too much.");
                        ModalPopupExtender6.Show();
                        return;
                    }
                    #endregion

                    //Pass All Validate
                    foreach (string arrsn in ArrSN)
                    {
                        //Check S/N Duplicate --> Lst
                        tps = lst.FirstOrDefault(w => w.ProductID.Equals(ProductID) && w.SerialNumber.Trim().Equals(arrsn.Trim()));
                        if (tps != null)
                        {
                            ShowMessageBox("Serial Number is duplicate. --> S/N : " + arrsn);
                            ModalPopupExtender6.Show();
                            return;
                        }

                        //Check S/N Duplicate --> tmp
                        tps = tmp.FirstOrDefault(w => w.ProductID.Equals(ProductID) && w.SerialNumber.Trim().Equals(arrsn.Trim()));
                        if (tps != null)
                        {
                            ShowMessageBox("Serial Number is duplicate. --> S/N : " + arrsn);
                            ModalPopupExtender6.Show();
                            return;
                        }

                        tps              = new TransProductSerial();
                        tps.ProductID    = ProductID;
                        tps.SerialNumber = arrsn.Trim();
                        tmp.Add(tps);
                    }
                    lst.AddRange(tmp);
                    BindGridSerial(lst, ProductID);


                    //Clear Txt
                    txtM6SN.Text = "";

                    //Save Session
                    Session["StockDetailHeadQSerial"] = lst;
                }


                ModalPopupExtender6.Show();
            }
            catch (Exception ex)
            {
            }
        }
Example #4
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)
            {
            }
        }