private void showResult(MaCuon mc, SoMay may) { Result frmRs = new Result(mc, may, mainFrm); this.Close(); frmRs.ShowDialog(); }
public DataTable GetOrder(MaCuon macuon, SoMay may) { // kiểm tra cuộn giấy đó có trong đơn hàng sản xuất Database longwayDb = Database.NewStructDatabase(); //string connect = "Server =LINH-PC\\HOATIEU; database = CPMS; user = sa; pwd = ht"; //Database longwayDb = Database.NewCustomDatabase(connect); int startNum = 0, endNum = 0; switch (may) { case SoMay.May1: startNum = 3; endNum = 5; break; case SoMay.May2: startNum = 7; endNum = 9; break; case SoMay.May3: startNum = 11; endNum = 13; break; default: break; } string query = @"SELECT PaperUse, ProduceWid, CutNum, SumSquare, OrderNo FROM LW_Order WHERE SUBSTRING(PaperUse, {0}, 2) = '{1}' OR SUBSTRING(PaperUse, {2}, 2) = '{3}'"; DataTable order = longwayDb.GetDataTable(string.Format(query, startNum, macuon.KyHieu, endNum, macuon.KyHieu)); return(order); }
private void CheckData(MaCuon mc, SoMay may) { if (!mainFrm.IsQuanLy()) { Login frmLogin = new Login(); frmLogin.StartPosition = FormStartPosition.CenterScreen; frmLogin.ShowDialog(); //dang nhap lai quyen quan ly if (frmLogin.DialogResult != DialogResult.Cancel) { mainFrm.UpdateLoginUser(frmLogin.drUser); if (!mainFrm.IsQuanLy()) { XtraMessageBox.Show("Chức năng này chỉ dành cho quản lý", "POS Warning"); this.Close(); } else { showResult(mc, may); } } else { this.Close(); } } else { showResult(mc, may); } }
public Result(MaCuon macuon, SoMay May, Main main) { InitializeComponent(); label6.Text = macuon.KyHieu; label7.Text = macuon.Kho; label8.Text = macuon.Macuon; label9.Text = macuon.SoKg.ToString("###,###"); LoaiMay = May; mainFrm = main; macuonData = macuon; }
public MaCuon GetMaCuon(string code) { MaCuon result = new MaCuon(); string dataCnn = Config.GetValue("DataConnection").ToString(); if (string.IsNullOrEmpty(dataCnn)) { XtraMessageBox.Show("Không tìm thấy chuỗi kết nối database", Config.GetValue("PackageName").ToString()); this.Close(); } dataCnn = dataCnn.Replace("POS", "HTCPH"); Database hoaTieuDb = Database.NewCustomDatabase(dataCnn); string macuon = textBox1.Text; result.Macuon = textBox1.Text; if (!string.IsNullOrEmpty(code)) { macuon = code; result.Macuon = code; } var soTon = hoaTieuDb.GetValue(string.Format("SELECT SoLuong FROM TonKhoNL WHERE MaCuon = '{0}'", macuon.Trim())); decimal soluongTon = 0; if (soTon != null) { soluongTon = Convert.ToDecimal(soTon.ToString()); } result.SoKg = soluongTon; var manl = hoaTieuDb.GetValue(string.Format("SELECT MaNL FROM DT42 WHERE MaCuon = '{0}'", macuon.Trim())); if (manl != null) { result.MaNL = manl.ToString(); DataTable dmNL = hoaTieuDb.GetDataTable(string.Format("SELECT KyHieu, Kho FROM wDMNL2 WHERE Ma = '{0}'", manl.ToString())); if (dmNL.Rows.Count > 0) { result.KyHieu = dmNL.Rows[0]["KyHieu"].ToString(); result.Kho = dmNL.Rows[0]["Kho"].ToString(); } var tileK = hoaTieuDb.GetValue(string.Format("SELECT TiLeK from DMNL WHERE Ma = '{0}'", manl.ToString())); if (tileK != null) { result.TileK = Convert.ToDecimal(string.IsNullOrEmpty(tileK.ToString()) ? "0" : tileK.ToString()); } } return(result); }
public Result(MaCuon macuon, string May, PosMain posMain, int vitri) { InitializeComponent(); label6.Text = macuon.KyHieu; label7.Text = macuon.Kho; macuonl.Text = macuon.Macuon; label10.Text = macuon.SoKg.ToString("###,###"); machine = May; xvitri = vitri; posMainFrm = posMain; macuonData = macuon; }
public void AddToReturnGrid(int may, MaCuon macuon, decimal duongkinh) { string ngay = DateTime.Now.ToString(); decimal soluongBD = Convert.ToDecimal(macuon.SoKg); decimal soluongCL = (duongkinh / 1000) * Convert.ToDecimal(macuon.Kho) * Convert.ToDecimal("3.14") * macuon.TileK; decimal soluongSD = soluongBD - soluongCL; string list = ""; // tính số lượng đơn hàng sử dụng string nguoiduyet = loginUser["HoTen"].ToString(); string sql = @"INSERT INTO YeuCauXuatKho (Ngay, MaCuon, SoLuongBD, SoLuongSD, SoLuongCL, NguoiDuyet, LSX, Duyet, NguoiLap) VALUES ('{0}','{1}',{2},{3},{4},'{5}', '{6}',1, '{7}')" ; db.UpdateByNonQuery(string.Format(sql, ngay, macuon.Macuon, soluongBD, soluongSD, soluongCL, nguoiduyet, list, loginUser["Ma"].ToString())); ReloadReturnGrid(); }
public void LoadToData(MaCuon macuon, string may, int vitri) { switch (softwareType) { case "SV": string sql = @"INSERT INTO {0} (MaCuon, Vitri, SoKG, Duyet) VALUES ('{1}',{2},{3},'{4}')"; decimal sokg = macuon.SoKg; db.UpdateByNonQuery(string.Format(sql, machineTable, macuon.Macuon.ToString(), vitri, sokg, macuon.Duyet)); mainFrm.SyncMainGrid(); break; case "MV": string machine = machineTable.Substring(0, 3).ToString(); string sql1 = @"INSERT INTO {0}_{1} (MaCuon, Vitri, SoKG,Duyet) VALUES ('{2}',{3},{4},'{5}')"; decimal sokg1 = macuon.SoKg; db.UpdateByNonQuery(string.Format(sql1, machineTable, may, macuon.Macuon.ToString(), vitri, sokg1, macuon.Duyet)); mainFrm.SyncMainGrid(); break; } }
public void LoadToGrid(MaCuon macuon, SoMay may) { string data = macuon.Macuon + " - " + macuon.KyHieu + " - " + macuon.SoKg.ToString("###,###") + "KG"; if (gridView1.RowCount == 0) { DataRow row = source.NewRow(); AddNewRow(row, data, may); } else { string field = ""; switch (may) { case SoMay.May1: field = "MS1"; break; case SoMay.May2: field = "MS2"; break; case SoMay.May3: field = "MS3"; break; } for (int i = 0; i < gridView1.DataRowCount; i++) { if (string.IsNullOrEmpty(gridView1.GetRowCellValue(i, field).ToString())) { gridView1.SetRowCellValue(i, field, data); SyncMainGrid(); return; } } DataRow row = source.NewRow(); AddNewRow(row, data, may); } SyncMainGrid(); }
private void UpdateData(string macuon, string may) { string ngay = DateTime.Now.ToString(); MaCuon mc = new MaCuon(); string dataCnn = Config.GetValue("DataConnection").ToString(); dataCnn = dataCnn.Replace("POS", "HTCPH"); Database hoaTieuDb = Database.NewCustomDatabase(dataCnn); mc.Macuon = macuon; //lay manvl + kho + ky hieu + ty le khoi var manl = hoaTieuDb.GetValue(string.Format("SELECT MaNL FROM DT42 WHERE MaCuon = '{0}'", macuon.Trim())); string cVitri = ""; string msch = machineTable.Substring(0, 3).ToString(); if (manl != null) { mc.MaNL = manl.ToString(); DataTable dmNL = hoaTieuDb.GetDataTable(string.Format("SELECT KyHieu, Kho FROM wDMNL2 WHERE Ma = '{0}'", manl.ToString())); if (dmNL.Rows.Count > 0) { mc.KyHieu = dmNL.Rows[0]["KyHieu"].ToString(); mc.Kho = dmNL.Rows[0]["Kho"].ToString(); } var tileK = hoaTieuDb.GetValue(string.Format("SELECT TiLeK from DMNL WHERE Ma = '{0}'", manl.ToString())); if (tileK != null) { mc.TileK = Convert.ToDecimal(string.IsNullOrEmpty(tileK.ToString()) ? "0" : tileK.ToString()); } DataTable dbo = db.GetDataTable(string.Format("SELECT Duyet,SoKg,ViTri from {0}_{1} WHERE MaCuon = '{2}'", msch, may, mc.Macuon)); if (dbo.Rows.Count > 0) { mc.Duyet = dbo.Rows[0]["Duyet"].ToString(); mc.SoKg = Convert.ToDecimal(dbo.Rows[0]["SoKg"].ToString()); cVitri = dbo.Rows[0]["ViTri"].ToString(); } } string _machine = machineTable.Substring(0, 3).ToString(); decimal sosokgBd = mc.SoKg; decimal duongkinh = 0; Input dkFrm = new Input(); dkFrm.ShowDialog(); if (dkFrm.DialogResult != DialogResult.Cancel) { duongkinh = dkFrm.duongkinh; } decimal soluongCL = (duongkinh / 1000) * Convert.ToDecimal(mc.Kho) * Convert.ToDecimal("3.14") * mc.TileK; decimal soluongSD = mc.SoKg - soluongCL; string sql = @"INSERT INTO YeuCauXuatKho (Ngay, MaCuon, SoLuongBD, SoLuongSD, SoLuongCL, NguoiDuyet, LSX, Duyet, NguoiLap,ViTri) VALUES ('{0}','{1}',{2},{3},{4},'{5}', '{6}',1, '{7}', '{8}_{9}_{10}')"; db.UpdateByNonQuery(string.Format(sql, ngay, mc.Macuon, mc.SoKg, soluongSD, soluongCL, mc.Duyet, "LSX", mainFrm.loginUser["Ma"].ToString(), msch, may, cVitri)); string sql2 = @"DELETE FROM {0}_{1} WHERE MaCuon = '{2}'"; db.UpdateByNonQuery(string.Format(sql2, _machine, may, mc.Macuon)); mainFrm.SyncMainGrid(); this.Close(); }
private void nhapCuon(string xmacuon, string may, int vitri) { // buoc 1: Lay thong tin cuon MaCuon mc = new MaCuon(); string dataCnn = Config.GetValue("DataConnection").ToString(); dataCnn = dataCnn.Replace("POS", "HTCPH"); Database hoaTieuDb = Database.NewCustomDatabase(dataCnn); mc.Macuon = xmacuon; //lay manvl + kho + ky hieu + ty le khoi var manl = hoaTieuDb.GetValue(string.Format("SELECT MaNL FROM DT42 WHERE MaCuon = '{0}'", xmacuon.Trim())); if (manl != null) { mc.MaNL = manl.ToString(); DataTable dmNL = hoaTieuDb.GetDataTable(string.Format("SELECT KyHieu, Kho FROM wDMNL2 WHERE Ma = '{0}'", manl.ToString())); if (dmNL.Rows.Count > 0) { mc.KyHieu = dmNL.Rows[0]["KyHieu"].ToString(); mc.Kho = dmNL.Rows[0]["Kho"].ToString(); } var tileK = hoaTieuDb.GetValue(string.Format("SELECT TiLeK from DMNL WHERE Ma = '{0}'", manl.ToString())); if (tileK != null) { mc.TileK = Convert.ToDecimal(string.IsNullOrEmpty(tileK.ToString()) ? "0" : tileK.ToString()); } } // lay so kg var soTon = hoaTieuDb.GetValue(string.Format("SELECT SoLuong FROM TonKhoNL WHERE MaCuon = '{0}'", xmacuon)); decimal soluongTon = 0; if (soTon != null) { soluongTon = Convert.ToDecimal(soTon.ToString()); } mc.SoKg = soluongTon; if (mc.SoKg == 0) { messageBox msg = new messageBox("PPEr", "Paper Err", "Cuộn vừa nhập đã sử dụng hết"); msg.ShowDialog(); this.Close(); } else { // check current list string dataCnn1 = Config.GetValue("DataConnection").ToString(); if (string.IsNullOrEmpty(dataCnn1)) { messageBox msg = new messageBox("ConnErr", "Database Err", "Không tìm thấy chuỗi kết nối database"); msg.ShowDialog(); this.Close(); } Database posDB = Database.NewCustomDatabase(dataCnn1); string machine = machineTable.Substring(0, 3).ToString(); int ms1 = Convert.ToInt32(posDB.GetValue(string.Format("SELECT count(ID) FROM {0}_D WHERE [MaCuon] = '{1}'", machine, xmacuon.Trim()))); int ms2 = Convert.ToInt32(posDB.GetValue(string.Format("SELECT count(ID) FROM {0}_E WHERE [MaCuon] = '{1}'", machine, xmacuon.Trim()))); int ms3 = Convert.ToInt32(posDB.GetValue(string.Format("SELECT count(ID) FROM {0}_B WHERE [MaCuon] = '{1}'", machine, xmacuon.Trim()))); int ms4 = Convert.ToInt32(posDB.GetValue(string.Format("SELECT count(ID) FROM {0}_C WHERE [MaCuon] = '{1}'", machine, xmacuon.Trim()))); if ((ms1 + ms2 + ms3 + ms4) >= 1) { messageBox msg = new messageBox("PPEr", "Paper Err", "Cuộn vừa nhập đang được sử dụng"); msg.ShowDialog(); this.Close(); } else { Database longwayDb = Database.NewStructDatabase(); int startNum = 0; switch (may) { case "D": startNum = 0; break; case "E": switch (vitri) { case 1: startNum = 3; break; case 2: startNum = 5; break; } break; case "B": switch (vitri) { case 1: startNum = 7; break; case 2: startNum = 9; break; } break; case "C": switch (vitri) { case 1: startNum = 11; break; case 2: startNum = 13; break; } break; default: break; } string query = @"SELECT PaperUse, ProduceWid, CutNum, SumSquare, OrderNo FROM LW_Order WHERE SUBSTRING(PaperUse, {0}, 2) = '{1}' and ProduceWid = {2} "; DataTable order = longwayDb.GetDataTable(string.Format(query, startNum, mc.KyHieu, mc.Kho)); if (order == null || order.Rows.Count == 0) { messageBox msg = new messageBox("PPEr", "Paper Err", "Cuộn này không có trong kế hoạch sản xuất, Yêu cầu Admin Xác nhận"); msg.ShowDialog(); if (msg.DialogResult != DialogResult.Cancel) { if (!mainFrm.IsQuanLy()) { //Login frmLogin = new Login(); //frmLogin.StartPosition = FormStartPosition.CenterScreen; //frmLogin.ShowDialog(); AdminConfirm frmConfirm = new AdminConfirm(); frmConfirm.StartPosition = FormStartPosition.CenterScreen; frmConfirm.ShowDialog(); //dang nhap lai quyen quan ly if (frmConfirm.DialogResult != DialogResult.Cancel) { if (!frmConfirm.confUser["Quyen"].ToString().Equals("Quản lý")) { MessageBox.Show("Chức năng này chỉ dành cho quản lý", "POS Warning"); this.Close(); } else { mc.Duyet = frmConfirm.confUser["HoTen"].ToString(); LoadToData(mc, may, vitri); } } else { this.Close(); } } else { mc.Duyet = mainFrm.loginUser["HoTen"].ToString(); LoadToData(mc, may, vitri); } } this.Close(); } else { LoadToData(mc, may, vitri); } }// check longway } }