private void procDonSanXuat_ViewGridControl_Click(object sender, EventArgs e) { chieudai = kichThuocTextEdit.Text.ToUpper().Replace("MM", ""); // xóa dữ liệu Clear(); // click chọn sẽ tab đến bộ phận của đơn hàng đó try { var db = new MyDBContextDataContext(); var ll = (from s in db.DonSanXuat_LanhLieu_QuanLyDonHang_SanXuat_Null() where s.SCD == sCDTextEdit.Text select s).Single(); if (ll.BoPhanSX != null) { boPhanTextEdit.Text = ll.BoPhanSX; MessageBox.Show("Đơn hàng đã chuyển đổi bộ phận " + ll.BoPhanSX + " , mọi người xem kỹ khi tính liệu"); } var vatlieu = (from s in db.VatLieu_4C() where s.TenHangHoa == vatLieuTextEdit.Text select s).ToList(); if (boPhanTextEdit.Text == offset) { xtraTabControl1.SelectedTabPage = tpOffset; QuycachOffset.Properties.DataSource = vatlieu;//vlCtr.GetData1C(vatLieuTextEdit.Text); QuycachOffset.Properties.DisplayMember = "QuyCach"; QuycachOffset.Properties.ValueMember = "QuyCach"; if (ll.LanhLieu == null) { if (tenKhachHangTextEdit.Text == PrintRibbon.AD) { SLSXOffset.Value = soLuongTextEdit.Value; } else { SLSXOffset.Value = soLuongTextEdit.Value * 115 / 100; } if (khoTextEdit.Text == banthanhpham || khoTextEdit.Text == thanhpham) { CatGiayOffset.Text = "1K"; } } else { KhoGiayInOffset.Text = ll.KhoGiayIn; CatGiayOffset.Text = ll.CatGiay; soLuongDanTrangTextEdit.Text = ll.SoLuongDanTrang.ToString(); SLSXOffset.Text = ll.SoLuongSanXuat.ToString(); soTrangInTextEdit.Text = ll.SoTrangIn; buHaoTextEdit.Text = ll.BuHao.ToString(); ctpOffsetTextEdit.Text = ll.CtpOffset.ToString(); QuycachOffset.Text = ll.QuyCach; if (ll.Kho == nguyenvatlieu) { var vl = (from a in db.tbVatLieus where a.TenHangHoa == ll.VatLieu && a.QuyCach == ll.QuyCach select a).Single(); btnTinhOffset.Text = ll.LanhLieu + " " + ll.DonViTinh + " (" + vatLieuTextEdit.Text + ") " + " " + ll.QuyCach; } else { btnTinhOffset.Text = ll.LanhLieu + " " + ll.DonViTinh + " " + vatLieuTextEdit.Text; } } } else if (boPhanTextEdit.Text == temvai) { //var vatlieu = (from s in db.VatLieu_4C() where s.TenHangHoa == vatLieuTextEdit.Text select s).ToList(); QuyCachTemVaiSearch.Properties.DataSource = vatlieu; QuyCachTemVaiSearch.Properties.DisplayMember = "QuyCach"; QuyCachTemVaiSearch.Properties.ValueMember = "QuyCach"; xtraTabControl1.SelectedTabPage = tpTemVai; var _kichthuoc = chieudai.Split('*'); txtChieuDai.Text = _kichthuoc[1]; if (ll.LanhLieu == null) { txtSLSXTemVai.Value = soLuongTextEdit.Value; txtChieuDai.Text = _kichthuoc[1]; if (tenKhachHangTextEdit.Text == PrintRibbon.AD) { txtBuHaoTemVai.Value = (decimal)1.06; foreach (var item in vatlieu) { QuyCachTemVaiSearch.Text = item.QuyCach; break; } } else { txtBuHaoTemVai.Value = (decimal)1.06; } } else { if (ll.SoLuongSanXuat != null) { txtSLSXTemVai.Value = ll.SoLuongSanXuat.Value; } txtBuHaoTemVai.Text = ll.BuHao.ToString(); btnTinhTemVai.Text = ll.LanhLieu.ToString(); QuyCachTemVaiSearch.Text = ll.QuyCach; } } else if (boPhanTextEdit.Text == danhthiep) { xtraTabControl1.SelectedTabPage = tpDanhThiep; if (ll.LanhLieu == null) { txtBuHaoDanhThiep.Text = "1.04"; txtSLDTDanhThiep.Value = 1; } else { txtSLSX_DanhThiep.Text = ll.SoLuongSanXuat.ToString(); txtSLDTDanhThiep.Text = ll.SoLuongDanTrang.ToString(); txtBuHaoDanhThiep.Text = ll.BuHao.ToString(); txtCTPDanhThiep.Text = ll.CtpOffset.ToString(); btnTinhDanhThiep.Text = ll.LanhLieu + " " + ll.DonViTinh; } } else if (boPhanTextEdit.Text == sticker) { //var vatlieu = (from s in db.VatLieu_4C() where s.TenHangHoa == vatLieuTextEdit.Text select s).ToList(); QuyCachStickerSearch.Properties.DataSource = vatlieu; QuyCachStickerSearch.Properties.DisplayMember = "QuyCach"; QuyCachStickerSearch.Properties.ValueMember = "QuyCach"; xtraTabControl1.SelectedTabPage = tpSticker; var chon = chieudai.Split('*'); if (radioGroup1.SelectedIndex == 0) { _dantrang = Math.Round(Convert.ToDouble(chon[0]), 0); _tinhlieu = Math.Round(Convert.ToDouble(chon[1]), 0); } else { _dantrang = Math.Round(Convert.ToDouble(chon[1]), 0); _tinhlieu = Math.Round(Convert.ToDouble(chon[0]), 0); } if (ll.LanhLieu == null) { txtBuHaoSticker.Text = "1.05"; txtSLDTSticker.Text = "2"; } else { txtSLSXSticker.Text = ll.SoLuongSanXuat.ToString(); txtSLDTSticker.Text = ll.SoLuongDanTrang.ToString(); txtBuHaoSticker.Text = ll.BuHao.ToString(); btnTinhSticker.Text = ll.LanhLieu + " " + ll.DonViTinh; QuyCachStickerSearch.Text = ll.QuyCach; } } else if (boPhanTextEdit.Text == inchu) { //var vatlieu = (from s in db.VatLieu_4C() where s.TenHangHoa == vatLieuTextEdit.Text select s).ToList(); QuyCachInChuSearch.Properties.DataSource = vatlieu; QuyCachInChuSearch.Properties.DisplayMember = "QuyCach"; QuyCachInChuSearch.Properties.ValueMember = "QuyCach"; xtraTabControl1.SelectedTabPage = tpInChuViTinh; var chon = chieudai.Split('*'); if (radioGroup2.SelectedIndex == 0) { _dantrang = Math.Round(Convert.ToDouble(chon[0]), 0); _tinhlieu = Math.Round(Convert.ToDouble(chon[1]), 0); } else { _dantrang = Math.Round(Convert.ToDouble(chon[0]), 0); _tinhlieu = Math.Round(Convert.ToDouble(chon[1]), 0); } if (ll.LanhLieu == null) { txtBuHaoInChu.Text = "1.03"; if (ll.LoaiSanPham == "TEM GIẤY") { txtSLSXInChu.BackColor = Color.LightGreen; txtSLDTInChu.BackColor = Color.LightGreen; txtBuHaoInChu.BackColor = Color.LightGreen; txtSLDTInChu.Text = "1"; } else if (ll.LoaiSanPham == "STICKER") { txtSLSXInChu.BackColor = Color.LightSalmon; txtSLDTInChu.BackColor = Color.LightSalmon; txtBuHaoInChu.BackColor = Color.LightSalmon; radioGroup2.BackColor = Color.LightSalmon; txtSLDTInChu.Text = "2"; } } else { txtSLSXInChu.Text = ll.SoLuongSanXuat.ToString(); txtSLDTInChu.Text = ll.SoLuongDanTrang.ToString(); txtBuHaoInChu.Text = ll.BuHao.ToString(); btnTinhInChu.Text = ll.LanhLieu + " " + ll.DonViTinh; QuyCachInChuSearch.Text = ll.QuyCach; } } else if (boPhanTextEdit.Text == sauin) { xtraTabControl1.SelectedTabPage = tpSauIn; txtKhoGiayInSauIn.Text = ll.KhoGiayIn; txtCatGiaySauIn.Text = ll.CatGiay; txtSLDTSauIn.Text = ll.SoLuongDanTrang.ToString(); txtSLSXSauIn.Text = ll.SoLuongSanXuat.ToString(); txtSLTISauIn.Text = ll.SoTrangIn; txtBuHaoSauIn.Text = ll.BuHao.ToString(); var khoGiayIn = (from a in db.tbKhoGiayIns where a.KhoIn == txtKhoGiayInSauIn.Text && a.CatGiay == txtCatGiaySauIn.Text select a).Single(); btnTinhSauIn.Text = ll.LanhLieu + " " + ll.DonViTinh + " (" + ll.VatLieu + ") " + khoGiayIn.GiayLon; } else if (boPhanTextEdit.Text == kts) { xtraTabControl1.SelectedTabPage = tpKyThuatSo; if (ll.LanhLieu == null) { if (soLuongTextEdit.Value < 5000) { txtBuHaoKTS.Text = "3"; } else { txtBuHaoKTS.Text = "5"; } } else { txtSLSXKyThuatSo.Text = ll.SoLuongSanXuat.ToString(); txtKhoGiayInKTS.Text = ll.KhoGiayIn; txtBuHaoKTS.Text = ll.BuHao.ToString(); txtSoLuongSizeKTS.Text = ll.SoLuongSize.ToString(); txtSLDTKTS.Text = ll.SoLuongDanTrang.ToString(); btnTinhKTS.Text = ll.LanhLieu + " " + ll.DonViTinh + " " + ll.KhoGiayIn; } } } catch (Exception) { // ignored } }