Esempio n. 1
0
        private void ShowDetail(int plnum, string matnr, int posnr, string lgort, string batch)
        {
            Detail objDetail = DetailBusiness.GetDetail(plnum, matnr, posnr);

            List <String> lstLgpro = new List <String>();

            lstLgpro.Add("BULK");
            lstLgpro.Add("FGWH");
            lstLgpro.Add("RMSA");
            cboLgpro.DataSource = lstLgpro;
            //cboLgpro.DropDownStyle = ComboBoxStyle.DropDownList;

            txtPlnum.Text = plnum.ToString();
            txtMatnr.Text = matnr;
            txtMaktx.Text = objDetail.maktx;
            nmCount.Value = decimal.Parse(objDetail.count.ToString());
            lblPosnr.Text = objDetail.posnr.ToString();

            nmCount.DecimalPlaces = 3;
            nmCount.Increment     = 0.001M;

            cboCharg.DataSource = BatchBusiness.GetBatchList2(plnum.ToString(), matnr);
            //cboCharg.DisplayMember = "Charg";
            //cboCharg.ValueMember = "Charg";
            //cboCharg.DropDownStyle = ComboBoxStyle.DropDownList;

            foreach (string item in lstLgpro)
            {
                if (item == objDetail.lgpro)
                {
                    cboLgpro.SelectedItem = item;
                }
            }

            try
            {
                if (batch != null || batch != "")
                {
                    cboCharg.SelectedValue = batch;
                }
            }
            catch (Exception ex)
            {
                batch = "";
            }
        }
Esempio n. 2
0
 public BaseController() : base()
 {
     loginBusiness    = new LoginBusiness(this.GetContext());
     batchBusiness    = new BatchBusiness(this.GetContext());
     cardBusiness     = new CardBusiness(this.GetContext());
     requestBusiness  = new RequestBusiness(this.GetContext());
     newsBusiness     = new NewsBusiness(this.GetContext());
     cusBusiness      = new CustomerBusiness(this.GetContext());
     rankBusiness     = new RankBusiness(this.GetContext());
     configBusiness   = new ConfigBusiness(this.GetContext());
     pointBusiness    = new PointBusiness(this.GetContext());
     warrantyBusiness = new WarrantyBusiness(this.GetContext());
     statisticBus     = new StatisticBusiness(this.GetContext());
     orderBus         = new OrderBusiness(this.GetContext());
     userBusiness     = new UserBusiness(this.GetContext());
     itemBusiness     = new ItemBusiness(this.GetContext());
     productsBusiness = new ItemBusiness(this.GetContext());
     notifyBusiness   = new NotifyBusiness(this.GetContext());
     shopBusiness     = new ShopBusiness(this.GetContext());
     agentBusiness    = new AgentBusiness(this.GetContext());
     vnpay            = new VNPay(this.GetContext());
 }
Esempio n. 3
0
        private void EditDetail()
        {
            //2 trường hợp:
            //Nếu thay đổi mà trùng charg và trùng erfmg thì báo là đã tồn tại 1 detail như thế
            //Còn không thì thay đổi hàng này
            #region lấy thông tin của Detail cần sửa
            double        count    = (double)nmCount.Value;
            int           plnum    = int.Parse(txtPlnum.Text);
            string        matnr    = txtMatnr.Text;
            string        charg    = "";
            int           posnr    = int.Parse(lblPosnr.Text);
            List <string> lstBatch = BatchBusiness.GetBatchList2(plnum.ToString(), matnr);
            if (lstBatch.Count == 0)
            {
                if (!String.IsNullOrEmpty(cboCharg.Text))
                {
                    MessageBox.Show("Không tồn tại batch tương ứng với Planned Order Detail này!", "Thông báo!");
                    return;
                }
                else
                {
                    charg = "";
                }
            }
            else
            {
                if (String.IsNullOrEmpty(cboCharg.Text))
                {
                    charg = "";
                }
                else
                {
                    int i = 0;
                    foreach (string item in lstBatch)
                    {
                        if (item == cboCharg.Text)
                        {
                            i++;
                        }
                    }

                    if (i == 0)
                    {
                        MessageBox.Show("Không tồn tại batch tương ứng với Planned Order Detail này!", "Thông báo!");
                        return;
                    }
                    else
                    {
                        charg = cboCharg.Text;
                    }
                }
            }
            string lgpro     = cboLgpro.SelectedItem.ToString();
            Detail oldDetail = DetailBusiness.GetDetail(plnum, matnr, posnr);
            Detail newDetail = DetailBusiness.GetDetail(matnr, plnum, lgpro, charg);
            #endregion
            if (count == 0)
            {
                MessageBox.Show("So luong khong duoc bang 0!", "Thong bao!");
                return;
            }
            else
            {
                /*Lấy ra 1 list các Detail trong danh sách có plnum, matnr, lgpro, charg có trong
                 * gridview trùng với objDetail sắp được sửa ra
                 */
                #region layListDetailTrongGridViewGiongVoiNewDetail
                string query = "select * from dbo.PlannedOrderDetail where status = 1 and plnum = " + plnum + "" +
                               " and matnr = '" + matnr + "' and lgpro = '" + lgpro + "' and charg = '" + charg + "'";

                DataTable     dt           = DataProvider.GetList(query, null, false);
                List <Detail> lstDetailNew = new List <Detail>();
                foreach (DataRow row in dt.Rows)
                {
                    Detail obj = new Detail(row);
                    lstDetailNew.Add(obj);
                }
                #endregion

                #region layListDetailKhongCoTrongGridViewGiongVoiNewDetail
                //lấy 1 list các Detail không có trong gridview
                string query1 = "select * from dbo.PlannedOrderDetail where status = 0 and plnum = " + plnum + "" +
                                " and matnr = '" + matnr + "' and lgpro = '" + lgpro + "' and charg = '" + charg + "'";

                DataTable     dt1          = DataProvider.GetList(query1, null, false);
                List <Detail> lstDetailOld = new List <Detail>();
                foreach (DataRow row in dt1.Rows)
                {
                    Detail obj = new Detail(row);
                    lstDetailOld.Add(obj);
                }
                #endregion

                if (newDetail.lgpro == oldDetail.lgpro && newDetail.charg == oldDetail.charg)
                {
                    DetailBusiness.UpdateDetail(plnum, matnr, count, lgpro, charg, posnr);
                    this.Close();
                }
                else
                {
                    if ((lstDetailNew.Count > 0 && newDetail.lgpro != oldDetail.lgpro && newDetail.charg == oldDetail.charg) || (lstDetailNew.Count > 0 && newDetail.lgpro == oldDetail.lgpro && newDetail.charg != oldDetail.charg) || (lstDetailNew.Count > 0 && newDetail.lgpro != oldDetail.lgpro && newDetail.charg != oldDetail.charg))
                    {
                        MessageBox.Show("Đã tồn tại một item có cùng kho và số batch!", "Thông báo!");
                    }
                    else if (lstDetailOld.Count > 0)
                    {
                        //Xoa OldDetail cần sửa
                        string query2 = "delete from PlannedOrderDetail where plnum = " + plnum + " and matnr = '" + matnr + "' and posnr = " + posnr;
                        //Cap nhat Detail bi trung trong list DetailOld
                        DataProvider.Execute(query2, null, false);
                        string query3 = "update dbo.PlannedOrderDetail set count = " + count + ", status = 1, posnr = " + posnr + " where plnum = " + plnum + " and matnr = '" + matnr + "' and lgpro = '" + lgpro + "' and charg = '" + charg + "'";
                        DataProvider.Execute(query3, null, false);
                        this.Close();
                    }
                    else
                    {
                        DetailBusiness.UpdateDetail(plnum, matnr, count, lgpro, charg, posnr);
                        this.Close();
                    }
                }

                //Nếu lstDetailNew có nhiều hơn 0 phần tử chứng tỏ đã bị trùng với một Detail khác trong gridview
                //if ((lstDetailNew.Count > 0 && newDetail.lgpro != oldDetail.lgpro && newDetail.charg == oldDetail.charg) ||(lstDetailNew.Count > 0 && newDetail.lgpro == oldDetail.lgpro && newDetail.charg != oldDetail.charg) ||(lstDetailNew.Count > 0 && newDetail.lgpro != oldDetail.lgpro && newDetail.charg != oldDetail.charg))
                //{
                //    MessageBox.Show("Đã tồn tại một item có cùng kho và số batch!", "Thông báo!");
                //}
                //else
                //{
                //    if (lstDetailOld.Count > 0)
                //    {
                //        //Xoa OldDetail cần sửa
                //        string query2 = "delete from PlannedOrderDetail where plnum = "+plnum+" and matnr = '"+matnr+"' and posnr = "+posnr;
                //        //Cap nhat Detail bi trung trong list DetailOld
                //        DataProvider.Execute(query2, null, false);
                //        string query3 = "update dbo.PlannedOrderDetail set count = " + count + ", status = 1, posnr = "+posnr+" where plnum = " + plnum + " and matnr = '" + matnr + "' and lgpro = '" + lgpro + "' and charg = '" + charg + "' and status = 0";
                //        DataProvider.Execute(query3, null, false);
                //    }
                //    else
                //    {
                //        DetailBusiness.UpdateDetail(plnum, matnr, count, lgpro, charg, posnr);
                //    }
                //    this.Close();
                //}
            }
        }
Esempio n. 4
0
        private void BtnChooseBatch_Click(object sender, EventArgs e)
        {
            //Neu da ton tai plannedOrderDetail + Batch do thi + them
            //Neu chua co batch do cho plannedOrderDetail do thi add 1 dong moi
            string          matnr   = txtMatnr.Text;
            List <Itemcode> lstItem = ItemCodeBusiness.GetITemList(matnr);
            string          maktx   = lstItem[0].maktx;
            int             loai    = int.Parse(lblLoai.Text);
            int             plnum   = int.Parse(lblPlnum.Text);
            double          count   = (double)nmItemCount.Value;
            string          charg   = "";
            string          erfme   = txtErfme.Text;

            List <string> lstBatch = BatchBusiness.GetBatchList2(plnum.ToString(), matnr);

            if (lstBatch.Count == 0)
            {
                if (!String.IsNullOrEmpty(cboChooseBatch.Text))
                {
                    MessageBox.Show("Không tồn tại batch tương ứng với Planned Order Detail này!", "Thông báo!");
                    return;
                }
                else
                {
                    charg = "";
                }
            }
            else
            {
                if (String.IsNullOrEmpty(cboChooseBatch.Text))
                {
                    charg = "";
                }
                else
                {
                    int i = 0;
                    foreach (string item in lstBatch)
                    {
                        if (item == cboChooseBatch.Text)
                        {
                            i++;
                        }
                    }

                    if (i == 0)
                    {
                        MessageBox.Show("Không tồn tại batch tương ứng với Planned Order Detail này!", "Thông báo!");
                        return;
                    }
                    else
                    {
                        charg = cboChooseBatch.Text;
                    }
                }
            }
            //Xử lý trường hợp nếu item không có batch ( ví dụ 1 số sản phẩm như chai lọ)
            //string lgort = (PlanndeBusiness.GetPlannedOrderFromPlnum(plnum)).lgort;
            string lgort = txtlg.Text;
            string lgpro = cboLgpro.SelectedItem.ToString();
            int    posnr = DetailBusiness.GetMaxPosnrFromMatnr(plnum);

            //Truong hop da ton tai matnr do trong list Detail
            //Them moi neu k trung batch, update neu trung batch
            //Kiểm tra xem batch đó có trong danh sách batch tương ứng với

            if (count == 0)
            {
                MessageBox.Show("So luong khong duoc bang 0!", "Thong bao!");
            }

            else
            {
                if (loai == 0)
                {
                    Detail        objDetail = DetailBusiness.GetDetail(matnr, plnum, lgpro, charg);
                    List <Detail> lstDetail = DetailBusiness.GetListDetailFromPlnum(plnum);
                    #region code thừa
                    //int i = 0;
                    //foreach (Detail item in lstDetail)
                    //{
                    //    if (item.charg == charg && item.matnr == matnr)
                    //    {
                    //        i++;
                    //    }
                    //}
                    #endregion
                    if (objDetail.charg == charg && objDetail.lgpro == lgpro)
                    {
                        //Neu da co thi update them erfmg
                        DetailBusiness.UpdateCountForDetail(plnum, objDetail.count + count, matnr, charg, lgpro);
                    }
                    else
                    {
                        //if (cboErfme.SelectedItem == null)
                        //{
                        //    erfme = "";
                        //}
                        //Neu chua co thi add them
                        objDetail.plnum = plnum.ToString();
                        objDetail.matnr = matnr;
                        objDetail.maktx = maktx;
                        objDetail.charg = charg;
                        objDetail.erfmg = objDetail.erfmg;
                        objDetail.plwrk = PlanndeBusiness.GetPlannde(plnum).plwrk;
                        objDetail.posnr = (posnr + 10);
                        objDetail.erfme = erfme;
                        objDetail.lgpro = lgpro;
                        objDetail.count = count;
                        DetailBusiness.AddDetail(objDetail);
                    }
                }
                //Them moi 1 Detail
                else
                {
                    //if (cboErfme.SelectedItem == null)
                    //{
                    //    erfme = "";
                    //}
                    //else
                    //{
                    Detail objDetail = new Detail();
                    objDetail.plnum = plnum.ToString();
                    objDetail.matnr = matnr;
                    objDetail.maktx = maktx;
                    objDetail.erfmg = 0;
                    objDetail.plwrk = PlanndeBusiness.GetPlannde(plnum).plwrk;
                    objDetail.lgpro = lgort;
                    objDetail.charg = charg;
                    objDetail.posnr = (posnr + 10);
                    objDetail.erfme = erfme;
                    objDetail.count = count;
                    DetailBusiness.AddDetail(objDetail);
                    //}
                }
            }
            this.Close();
            #region code cũ

            /*
             * string matnr = txtMatnr.Text;
             * Detail objDetail = DetailBusiness.GetPlannedOrderDetailFromMatnr(matnr);
             * List<Detail> lstPlannedOrderDetail = DetailBusiness.GetListPlannedOrderDetail(int.Parse(objDetail.plnum));
             * string charg = (cboChooseBatch.SelectedItem as Batch).charg;
             * Detail obj = DetailBusiness.GetPlannedOrderDetailFromMatnr(matnr);
             * float plannedOrderDetailCount = float.Parse(nmItemCount.Value.ToString());
             * int count = 0;
             * foreach (Detail item in lstPlannedOrderDetail)
             * {
             *  if (item.matnr == matnr && item.charg == charg)
             *  {
             *      count++;
             *  }
             * }
             * if (count > 0)
             * {
             *  DetailBusiness.UpdateErfmgForPlannedOrderDetail(plannedOrderDetailCount + obj.erfmg, matnr, charg);
             * }
             * else
             * {
             *  obj.erfmg = plannedOrderDetailCount;
             *  obj.charg = charg;
             *  obj.posnr = (DetailBusiness.GetMaxPosnrFromMatnr(matnr) + 10).ToString();
             *  DetailBusiness.AddPlannedOrderDetail(obj);
             * }
             */

            #endregion
        }
Esempio n. 5
0
 public void ShowBatchListToCombobox(string plnum, string matnr)
 {
     cboChooseBatch.DataSource = BatchBusiness.GetBatchList2(plnum, matnr);
     //cboChooseBatch.DisplayMember = "charg";
     //cboChooseBatch.DropDownStyle = ComboBoxStyle.DropDownList; //Cấm người dùng nhập tay vào :v
 }