Example #1
0
        private void btnLưu_Click(object sender, EventArgs e)
        {
            if (txtMaPX.Text == "" || txtTenNguoiNhan.Text == "" || txtCMND.Text == "")
            {
                MessageBox.Show("Vui lòng điền đủ thông tin phiên xuất kho", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else
            {
                //luu thong tin phien vao stockout, cap nhat trang thai barcode thanh false(da xuat kho), luu thong tin bang stockoutdetail
                //luu thong tin phien vao stockout
                StockOut so = new StockOut();
                so.StockOutCode  = txtMaPX.Text;
                so.UserID        = txtUser.Text;
                so.DateOut       = DateTime.Parse(dateNgayPX.EditValue.ToString());
                so.RecipientName = txtTenNguoiNhan.Text;
                so.IDCard        = txtCMND.Text;
                so.Company       = txtCongTy.Text;
                so.TotalWeight   = double.Parse(txtTongTrongLuong.Text);
                so.Quantity      = Int32.Parse(txtSoLuong.Text);
                so.Note          = txtGhiChu.Text;
                //Kiem tra trung stockoutcode
                StockOut var = (from s in dc.StockOuts
                                where s.StockOutCode == so.StockOutCode
                                select s).FirstOrDefault();
                if (var == null)
                {
                    dc.StockOuts.InsertOnSubmit(so);
                    dc.SubmitChanges();
                }
                else
                {
                    MessageBox.Show("Mã phiên xuất kho bị trùng lặp", "Thông báo", MessageBoxButtons.OK);
                }

                //cập nhật trang thai barcode thanh false (da xuat kho)
                for (int i = 0; i < gridViewBarcode.RowCount; i++)
                {
                    BarcodeDetail bd = (from c in dc.BarcodeDetails
                                        where c.Barcode == gridViewBarcode.GetRowCellValue(i, "Barcode").ToString()
                                        select c).FirstOrDefault();
                    if (bd != null)
                    {
                        bd.Status = false;
                        dc.SubmitChanges();
                    }
                }
                //luu thong tin stockout detail
                for (int i = 0; i < gridViewBarcode.RowCount; i++)
                {
                    StockOutDetail sod = new StockOutDetail();
                    sod.StockOutCode = txtMaPX.Text;
                    sod.Barcode      = gridViewBarcode.GetRowCellValue(i, "Barcode").ToString();
                    dc.StockOutDetails.InsertOnSubmit(sod);
                    dc.SubmitChanges();
                }
                MessageBox.Show("Lưu phiên xuất kho thành công", "Thông báo", MessageBoxButtons.OK);
            }
        }
Example #2
0
        private void btnThem_Click(object sender, EventArgs e)
        {
            if (txtTenRac.Text == "" || txtMaRac.Text == "" || cboLoaiRac.SelectedItem.ToString() == "" || txtDonVi.SelectedItem.ToString() == "")
            {
                MessageBox.Show("Vui lòng điền đủ thông tin", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else
            {
                Waste was = new Waste();
                was.WasteCode = txtMaRac.Text;
                was.WasteName = txtTenRac.Text;
                was.Type      = cboLoaiRac.SelectedItem.ToString();
                was.Unit      = txtDonVi.SelectedItem.ToString();
                if (rbtnKichHoat.Checked == true)
                {
                    was.Status = true;
                }
                else
                {
                    was.Status = false;
                }
                was.Note = txtGhiChu.Text;

                Waste var = (from c in dc.Wastes
                             where c.WasteCode == txtMaRac.Text && c.WasteName == txtTenRac.Text
                             select c).FirstOrDefault();
                if (var == null)
                {
                    try
                    {
                        dc.Wastes.InsertOnSubmit(was);
                        MessageBox.Show("Thêm mới loại rác thành công", "Thông báo");
                        dc.SubmitChanges();
                        txtMaRac.Text            = "";
                        txtTenRac.Text           = "";
                        cboLoaiRac.SelectedIndex = -1;
                        txtDonVi.SelectedIndex   = -1;
                        txtGhiChu.Text           = "";
                        rbtnKichHoat.Checked     = true;
                        DisplayData();
                    }
                    catch (Exception ex)
                    {
                        throw ex;
                    }
                }
                else
                {
                    MessageBox.Show("Loại rác thêm đã tồn tại", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }
        }
Example #3
0
        private void btnThem_Click(object sender, EventArgs e)
        {
            if (txtTenKho.Text == "" || txtMaKho.Text == "" || cbLoaiKho.SelectedItem.ToString() == "")
            {
                MessageBox.Show("Vui lòng điền đủ thông tin", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else
            {
                Storage sto = new Storage();
                sto.StorageCode = txtMaKho.Text;
                sto.StorageName = txtTenKho.Text;
                sto.Type        = cbLoaiKho.SelectedItem.ToString();
                if (rbtnKichHoat.Checked == true)
                {
                    sto.Status = true;
                }
                else
                {
                    sto.Status = false;
                }
                sto.Note = txtGhiChu.Text;

                Storage var = (from c in dc.Storages
                               where c.StorageCode == txtMaKho.Text && c.StorageName == txtTenKho.Text
                               select c).FirstOrDefault();
                if (var == null)
                {
                    try
                    {
                        dc.Storages.InsertOnSubmit(sto);
                        MessageBox.Show("Thêm mới kho thành công", "Thông báo");
                        dc.SubmitChanges();
                        txtMaKho.Text           = "";
                        txtTenKho.Text          = "";
                        cbLoaiKho.SelectedIndex = -1;
                        txtGhiChu.Text          = "";
                        rbtnKichHoat.Checked    = true;
                        DisplayData();
                    }
                    catch (Exception ex)
                    {
                        throw ex;
                    }
                }
                else
                {
                    MessageBox.Show("Kho thêm đã tồn tại", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }
        }
Example #4
0
        private void btnThem_Click(object sender, EventArgs e)
        {
            if (txtTenXuong.Text == "" || txtMaXuong.Text == "")
            {
                MessageBox.Show("Vui lòng điền đủ thông tin", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else
            {
                Factory f = new Factory();
                f.FactoryCode = txtMaXuong.Text;
                f.FactoryName = txtTenXuong.Text;
                if (rbtnKichHoat.Checked == true)
                {
                    f.Status = true;
                }
                else
                {
                    f.Status = false;
                }
                f.Note = txtGhiChu.Text;

                Factory var = (from c in dc.Factories
                               where c.FactoryCode == txtMaXuong.Text && c.FactoryName == txtTenXuong.Text
                               select c).FirstOrDefault();
                if (var == null)
                {
                    try
                    {
                        dc.Factories.InsertOnSubmit(f);
                        MessageBox.Show("Thêm mới xưởng thành công", "Thông báo");
                        dc.SubmitChanges();
                        txtMaXuong.Text      = "";
                        txtTenXuong.Text     = "";
                        txtGhiChu.Text       = "";
                        rbtnKichHoat.Checked = true;
                        DisplayData();
                    }
                    catch (Exception ex)
                    {
                        throw ex;
                    }
                }
                else
                {
                    MessageBox.Show("Xưởng thêm đã tồn tại", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }
        }
Example #5
0
        private void CalculateProductGroupRunRates()
        {
            using (WMSDataContext ctx = new WMSDataContext())
            {
                using (SqlConnection cn = new SqlConnection(Properties.Settings.Default.JDEConnectionString))
                {
                    cn.Open();
                    using (SqlCommand cmd = cn.CreateCommand())
                    {
                        int startDate = Utility.ToJulianDate(DateTime.Now.AddDays(-HistoryDays));

                        cmd.CommandText = @"SELECT LTRIM(RTRIM(SDSRP2)) AS BackendProductGroupCode, (SUM(SDSOQS) / COUNT(DISTINCT SDIVD)) AS AvgSalesPerDay
                              FROM F42119
                              WHERE SDDCTO IN ('SO','SI','SX','SW')
                              AND SDIVD >= @Date
                              GROUP BY SDSRP2";

                        cmd.Parameters.AddWithValue("@Date", startDate);
                        cmd.CommandType = System.Data.CommandType.Text;

                        using (SqlDataReader reader = cmd.ExecuteReader())
                        {
                            while (reader.Read())
                            {
                                ProductGroup group = (from pg in ctx.ProductGroups
                                                      where pg.CompanyID == this.CompanyID &&
                                                      pg.BackendID == reader["BackendProductGroupCode"].ToString()
                                                      select pg).FirstOrDefault();

                                if (group == null)
                                {
                                    continue;
                                }

                                group.RunRate = reader.GetDouble(1);

                                ctx.SubmitChanges();
                            }
                        }
                    }

                    cn.Close();
                }
            }
        }
Example #6
0
        private void btnDoiMK_Click(object sender, EventArgs e)
        {
            WMSDataContext dc  = new WMSDataContext();
            User           var = (from c in dc.Users
                                  where c.UserName == taikhoan
                                  select c).SingleOrDefault();

            if (var.Password != txtMKcu.Text)
            {
                MessageBox.Show("mật khẩu cũ không đúng, vui lòng kiểm tra lại", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                txtMKcu.Text = "";
                txtMKcu.Focus();
                txtMKmoi.Text        = "";
                txtMKmoixacnhan.Text = "";
            }
            else if (txtMKmoi.Text == "" || txtMKmoixacnhan.Text == "")
            {
                MessageBox.Show("Chưa nhập đủ thông tin", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else if (txtMKmoi.Text != txtMKmoixacnhan.Text)
            {
                MessageBox.Show("xác nhận mật khẩu không đúng, vui lòng kiểm tra lại", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                txtMKcu.Text = "";
                txtMKcu.Focus();
                txtMKmoi.Text        = "";
                txtMKmoixacnhan.Text = "";
            }
            else
            {
                try
                {
                    var.Password = txtMKmoi.Text;
                    dc.SubmitChanges();
                    MessageBox.Show("Đổi mật khẩu thành công", "Thông báo", MessageBoxButtons.OK);
                    txtMKcu.Text         = "";
                    txtMKmoi.Text        = "";
                    txtMKmoixacnhan.Text = "";
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
        }
Example #7
0
        private void btnLưu_Click(object sender, EventArgs e)
        {
            // luu thong tin phien, trang thai barcode chuyen sang chua nhap kho
            if (txtMaPN.Text == "" || txtMaNV.Text == "")
            {
                MessageBox.Show("Vui lòng điền đủ thông tin phiên nhập kho", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else
            {
                //luu thong tin phien vao stockin va tao barcode trang thai chua nhap kho va luu thong tin bang stockindetail
                //luu thong tin phien vao stockin
                StockIn si = new StockIn();
                si.StockInCode  = txtMaPN.Text;
                si.UserID       = txtUser.Text;
                si.EmployeeCode = txtMaNV.Text;
                si.DateIn       = DateTime.Parse(datePN.EditValue.ToString());
                si.Note         = txtGhiChuPhien.Text;
                si.TotalWeight  = double.Parse(txtTongTrongLuong.Text);
                si.Quantity     = Int32.Parse(txtSoLuong.Text);
                //Kiem tra trung stockincode
                StockIn var = (from s in dc.StockIns
                               where s.StockInCode == si.StockInCode
                               select s).FirstOrDefault();
                if (var == null)
                {
                    dc.StockIns.InsertOnSubmit(si);
                    dc.SubmitChanges();
                }
                else
                {
                    MessageBox.Show("Mã phiên nhập kho bị trùng lặp", "Thông báo", MessageBoxButtons.OK);
                }
                //luu thong tin barcode

                for (int i = 0; i < gridViewBarcode.RowCount; i++)
                {
                    BarcodeDetail bar = new BarcodeDetail();
                    bar.Barcode     = gridViewBarcode.GetRowCellValue(i, "Barcode").ToString();
                    bar.WasteCode   = gridViewBarcode.GetRowCellValue(i, "TenRac").ToString();
                    bar.FactoryCode = gridViewBarcode.GetRowCellValue(i, "Xuong").ToString();
                    bar.StorageCode = gridViewBarcode.GetRowCellValue(i, "Kho").ToString();
                    bar.Weigh       = double.Parse(gridViewBarcode.GetRowCellValue(i, "TrongLuong").ToString());
                    bar.Status      = true;
                    bar.Note        = gridViewBarcode.GetRowCellValue(i, "GhiChu").ToString();

                    //kiem tra trung barcode
                    BarcodeDetail barcode = (from s in dc.BarcodeDetails
                                             where s.Barcode == bar.Barcode
                                             select s).FirstOrDefault();
                    if (var == null)
                    {
                        dc.BarcodeDetails.InsertOnSubmit(bar);
                        dc.SubmitChanges();
                    }
                    else
                    {
                        MessageBox.Show("Mã barcode bị trùng lặp", "Thông báo", MessageBoxButtons.OK);
                    }
                }

                //Luu thong tin stockindetail

                for (int i = 0; i < gridViewBarcode.RowCount; i++)
                {
                    StockInDetail sid = new StockInDetail();
                    sid.StockInCode = txtMaPN.Text;
                    sid.Barcode     = gridViewBarcode.GetRowCellValue(i, "Barcode").ToString();
                    sid.Note        = txtGhiChuPhien.Text;
                    dc.StockInDetails.InsertOnSubmit(sid);
                    dc.SubmitChanges();
                }
                MessageBox.Show("Lưu phien nhập thành công", "Thông báo", MessageBoxButtons.OK);
            }
        }