private void btexportExcell_Click(object sender, EventArgs e) { FrmNhapLyDo nhapLyDo = new FrmNhapLyDo(); nhapLyDo.ShowDialog(); if (nhapLyDo._isdongy) { SaveFileDialog save = new SaveFileDialog(); save.Filter = "*.xls|*.xls|*.pdf|*.pdf"; if (save.ShowDialog() == DialogResult.OK) { CXoa.Visible = false; GrDSSKU.ExportToXls(save.FileName); if (txtghichu.Text != string.Empty) { CTLImportExcel excel = new CTLImportExcel(); excel.WireGhiChuExcel(save.FileName, txtghichu.Text, gridView1.DataRowCount + 5); } File.Copy(save.FileName, Path.Combine(Path.Combine(Path.Combine(Application.StartupPath, "ExpCust"), DateTime.Now.ToString("MMyyyy")), DateTime.Now.ToString("ddMMyyhhmmss"))); //GrDSSKU.ExportToXls(save.); //GrDSSKU.ExportToXls(save.FileName); CXoa.Visible = true; CTLSearchBug ctlSearchBug = new CTLSearchBug(); ctlSearchBug.InsertTraceLog(Config._MaNV, DateTime.Now, GetIP(), "FrmXuatBangGia", 1, "FrontEnd Utility", "Export Export Excel"); InfoMessage.HienThi("Xuất file " + save.FileName + " Thành công!!", "Xuất file Excel", "Thông báo", HinhAnhThongBao.THANHCONG, NutThongBao.DONGY); } } }
private void btAddCm_Click(object sender, EventArgs e) { if (_IDDocument == string.Empty) { InfoMessage.HienThi("Vui lòng chọn Event để comment !!!", "Thông báo", "Add Comment", HinhAnhThongBao.THANHCONG, NutThongBao.DONGY); return; } FrmAddComment addComment = new FrmAddComment(); addComment.richTextEdit1.isComment = true; addComment.richTextEdit1._IDIsuee = _IDDocument; addComment.richTextEdit1._IDCreate = Config._idcreate; addComment.richTextEdit1.labelControl1.Visible = false; addComment.richTextEdit1.labelControl2.Visible = false; addComment.richTextEdit1.labelControl3.Visible = false; addComment.richTextEdit1.txtVersion.Visible = false; addComment.richTextEdit1.txtAtt.Visible = false; addComment.richTextEdit1.txtReference.Visible = false; addComment.richTextEdit1.btnBrowse.Visible = false; addComment.ShowDialog(); if (addComment.richTextEdit1._isfinish) { InfoMessage.HienThi("Add new comment thành công!", "Thông báo", "Add Comment", HinhAnhThongBao.THANHCONG, NutThongBao.DONGY); } }
private void btexportExcell_Click(object sender, EventArgs e) { try { if (gridView1.DataRowCount <= 0) { InfoMessage.HienThi("Không có dữ liệu xuất file ", "Vui lòng load dữ liệu", "Thông báo", HinhAnhThongBao.THONGTIN, NutThongBao.DONGY); return; } SaveFileDialog saveFileDialog = new SaveFileDialog(); saveFileDialog.Filter = "*.xls|*.xls"; saveFileDialog.FileName = "CheckSKU_CKTM" + DateTime.Now.ToString("ddMMyyyy") + ".xls"; if (saveFileDialog.ShowDialog() == DialogResult.OK) { GrDSPriceSKU.ExportToXls(saveFileDialog.FileName); InfoMessage.HienThi("Xuất file " + saveFileDialog.FileName + " thành công!!! ", "Export Excell", "Thanh Cong", HinhAnhThongBao.THANHCONG, NutThongBao.DONGY); } } catch (Exception exception) { CTLError.WriteError("Export excell file ", exception.Message); throw; } }
static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); SplashScreen.SetTitleString("FrontEnd Utility !!!"); SplashScreen.SetCommentaryString("Khởi tạo chương trình ......."); SplashScreen.SetBackgroundImage(Image.FromFile(Path.Combine(Application.StartupPath, "Image.png"))); SplashScreen.BeginDisplay(); if (!Config.CheckConfig()) { InfoMessage.HienThi("Vui lòng liên hệ với vi tính để config database!", "Chưa config database", "Thong bao", HinhAnhThongBao.LOI, NutThongBao.DONGY); return; } SplashScreen.SetCommentaryString("lấy cấu hình......."); Config.GetConfiguration(); Config.LayCauHinh(); SplashScreen.SetCommentaryString("Kiểm tra version......."); Config.CheckVersion(); SplashScreen.EndDisplay(); Application.Run(new MainForm()); SplashScreen.EndDisplay(); //Application.Run(new FrmTest()); //SplashScreen.EndDisplay(); //Application.Run(new FrmScaleAdappterTool.FrmScaleAddTool()); }
private void btexportExcell_Click(object sender, EventArgs e) { //FrmNhapLyDo nhapLyDo=new FrmNhapLyDo(); //nhapLyDo.ShowDialog(); //if(nhapLyDo._isdongy) //{ SaveFileDialog save = new SaveFileDialog(); save.Filter = "*.xls|*.xls|*.pdf|*.pdf"; if (save.ShowDialog() == DialogResult.OK) { ExcelHelper.exportDataToExcel("Đơn Đặt Hàng", (DataTable)GrDSSKU.DataSource, save.FileName, txthotenKH.Text, txtDienThoai.Text, txtDiaChi.Text); //CXoa.Visible = false; //GrDSSKU.ExportToXls(save.FileName); if (txtghichu.Text != string.Empty) { CTLImportExcel excel = new CTLImportExcel(); excel.WireGhiChuExcel(save.FileName, txtghichu.Text, gridView1.DataRowCount + 7); } //excel.WireInfomationCIM(save.FileName, gridView1.DataRowCount + 5, "Họ Tên KH: " + txthotenKH.Text, "Số Điện Thoại: " + txtDienThoai.Text, "Địa Chỉ: " + txtDiaChi.Text); //File.Copy(save.FileName, Path.Combine(Path.Combine(Path.Combine(Application.StartupPath, "ExpCust"), DateTime.Now.ToString("MMyyyy")), DateTime.Now.ToString("ddMMyyhhmmss"))); ////GrDSSKU.ExportToXls(save.); ////GrDSSKU.ExportToXls(save.FileName); //CXoa.Visible = true; //CTLSearchBug ctlSearchBug = new CTLSearchBug(); //ctlSearchBug.InsertTraceLog(Config._MaNV, DateTime.Now, GetIP(), "FrmXuatBangGia", 1, "FrontEnd Utility", "Export Export Excel"); InfoMessage.HienThi("Xuất file " + save.FileName + " Thành công!!", "Xuất file Excel", "Thông báo", HinhAnhThongBao.THANHCONG, NutThongBao.DONGY); } //} }
private void txtBrowse_Click(object sender, EventArgs e) { OpenFileDialog ofd = new OpenFileDialog(); ofd.Multiselect = true; ofd.Filter = @"All files (*.*)|*.*"; if (ofd.ShowDialog() == DialogResult.OK) { foreach (string ffn in ofd.FileNames) { lstFullFileName.Add(ffn); } foreach (string fn in ofd.SafeFileNames) { if (lstFileName.Contains(fn)) { //FrmMessage frm = new FrmMessage("File đã tồn tại"); //frm.ShowDialog(); InfoMessage.HienThi("File đã tồn tại", "Attatch file", "Thông báo", HinhAnhThongBao.LOI, NutThongBao.DONGY); return; } lstFileName.Add(fn); if (txtAtt.RichText.Text.Length > 0) { txtAtt.RichText.AppendText(" " + fn + ";"); } else { txtAtt.RichText.AppendText(" " + fn + ";"); } } } }
public bool GoiEmailNhomWinDSS(string filenaem) { try { try { SmtpClient emailClient1 = new SmtpClient("10.10.15.61", 25); System.Net.NetworkCredential SMTPUserInfo1 = new System.Net.NetworkCredential("*****@*****.**", "@Nhnhatduy25"); emailClient1.UseDefaultCredentials = false; MailAddress FromMail1 = new MailAddress("*****@*****.**", "Bao Cao Upload File T"); //emailClient.EnableSsl = true; emailClient1.Credentials = SMTPUserInfo1; //MailAddress FromMail1 = new MailAddress(CTLConfig._UserEmail, "IT SGC WinDSS"); MailMessage message1 = new MailMessage(FromMail1, new MailAddress("*****@*****.**")); message1.Subject = "Thông báo V/v upload File T strore " + _Store + " ngay " + Ngay.Value.ToString("dd-MM-yyyy"); message1.To.Add("*****@*****.**"); message1.To.Add("*****@*****.**"); message1.To.Add("*****@*****.**"); message1.Body = "Thông báo V/v upload File T strore " + _Store + " ngay " + Ngay.Value.ToString("dd-MM-yyyy hh:mm:ss") + " file " + filenaem; //System.Net.Mail.Attachment attachment; //attachment = new System.Net.Mail.Attachment(Path.Combine(Application.StartupPath, DateTime.Now.AddDays(-1).ToString("dd-MM-yyyy") + "_BaoCao.csv")); //message1.Attachments.Add(attachment); emailClient1.Send(message1); return(true); } catch (Exception) { SmtpClient emailClient1 = new SmtpClient("10.10.15.61", 25); System.Net.NetworkCredential SMTPUserInfo1 = new System.Net.NetworkCredential("*****@*****.**", "@Nhnhatduy1"); emailClient1.UseDefaultCredentials = false; MailAddress FromMail1 = new MailAddress("*****@*****.**", "Bao Cao Upload File T"); //emailClient.EnableSsl = true; emailClient1.Credentials = SMTPUserInfo1; //MailAddress FromMail1 = new MailAddress(CTLConfig._UserEmail, "IT SGC WinDSS"); MailMessage message1 = new MailMessage(FromMail1, new MailAddress("*****@*****.**")); message1.Subject = "Thông báo V/v upload File T strore " + _Store + " ngay " + Ngay.Value.ToString("dd-MM-yyyy hh:mm:ss") + " file " + filenaem; message1.To.Add("*****@*****.**"); message1.To.Add("*****@*****.**"); message1.To.Add("*****@*****.**"); message1.Body = "Thông báo V/v upload File T strore " + _Store + " ngay " + Ngay.Value.ToString("dd-MM-yyyy"); //System.Net.Mail.Attachment attachment; //attachment = new System.Net.Mail.Attachment(Path.Combine(Application.StartupPath, DateTime.Now.AddDays(-1).ToString("dd-MM-yyyy") + "_BaoCao.csv")); //message1.Attachments.Add(attachment); emailClient1.Send(message1); return(true); } } catch (Exception ex) { CTLError.WriteError("Loi Khi Goi Email nhom WinDSS ", ex.Message); InfoMessage.HienThi("Vui long lien he voi voi Nhom WinDSS (Ex : 1081) ", "Loi Khi Goi Email nhom WDSS...", "Loi", HinhAnhThongBao.LOI, NutThongBao.DONGY); return(false); throw; } }
public bool validate() { if (gridView1.DataRowCount <= 0) { InfoMessage.HienThi("Vui lòng nhập Sản phẩm cho đơn hàng", "Thông báo", "Thong Bao", HinhAnhThongBao.THONGTIN, NutThongBao.DONGY); return(false); } return(true); }
void DeleteAttachment(string AttID) { CTLXuLyAddNewApplication_Master control = new CTLXuLyAddNewApplication_Master(); if (!control.DeleteAtt(AttID)) { //FrmMessage frm = new FrmMessage("Lỗi chỉnh sửa attachment. Vui lòng thao tác lại"); //frm.ShowDialog(); InfoMessage.HienThi("Lỗi chỉnh sửa attachment. Vui lòng thao tác lại", "Attatch file", "Thông báo", HinhAnhThongBao.LOI, NutThongBao.DONGY); return; } }
private void button1_Click(object sender, EventArgs e) { if (txtlydo.Text == string.Empty) { InfoMessage.HienThi("Vui lòng nhập lý do xuất file", "Xuất file excel", "Thong bao", HinhAnhThongBao.LOCK, NutThongBao.DONGY); return; } checkPath(); WriteLogfile("ExpL", "", txtlydo.Text); _isdongy = true; this.Close(); }
void AddNewAttachment(string filePath, string DocID, string content, string fileNames, string version, string reference, string Title_att) { CTLXuLyAddNewApplication_Master control = new CTLXuLyAddNewApplication_Master(); if (!control.AddNewAtt(filePath, DocID, content, fileNames, version, reference, Title_att)) { //FrmMessage frm = new FrmMessage("Lỗi chỉnh sửa attachment. Vui lòng thao tác lại"); //frm.ShowDialog(); InfoMessage.HienThi("Lỗi chỉnh sửa attachment. Vui lòng thao tác lại", "Thông báo", "Thông báo", HinhAnhThongBao.LOI, NutThongBao.DONGY); return; } }
private void BTcheckFileT_Click(object sender, EventArgs e) { if (validateForm()) { try { panel1.Visible = false; panel2.Visible = false; panel3.Visible = false; TPSDataAccess accessPathWSS = new TPSDataAccess(Path.Combine(Config._pathfileWinDSS, "SYSMST")); string MaST = "0"; MaST = accessPathWSS.getMaSieuthi(); if (MaST == "0") { InfoMessage.HienThi("Khong lay Duoc Store ...,Vui long lien he voi Admin", "Loi ", "Thong bao", HinhAnhThongBao.LOI, NutThongBao.DONGY); return; } NetworkShareAccesser.Access("10.10.1.23", "synback", "synsgcoop"); string strStore = "000" + MaST; strStore = strStore.Substring(strStore.Length - 5, 5); _Store = strStore; FileInfo f = new FileInfo(@"\\10.10.1.23\QDLS\MM770FLR\" + "A" + strStore + @"\T1" + Ngay.Value.ToString("dd") + ".001"); FileInfo fthumuc0 = new FileInfo(@"\\10.10.1.23\QDLS\MM770FLR\" + strStore + @"\T1" + Ngay.Value.ToString("yyMMdd") + ".001"); DateTime datemodify = f.LastWriteTime; if (f.Exists && datemodify.Month == Ngay.Value.Month) { panel2.Visible = true; } else if (fthumuc0.Exists) { panel1.Visible = true; } else { panel3.Visible = true; } } catch (Exception) { throw; } } }
private void BTLoadDS_Click(object sender, EventArgs e) { WaitingMsg waitingMsg = new WaitingMsg("Chương trình đang load dữ liệu!", "Please Waiting ......."); try { if (CopyFileINVMST()) { if (_PathFileINVMST == string.Empty) { InfoMessage.HienThi("Thong bao", "Không lấy đữ liệu được ! Vui lòng kiểm tra lại H:\\ hoặc Server 21", "Lay du lieu khong thanh cong", HinhAnhThongBao.THONGTIN, NutThongBao.DONGY); return; } //_PathFileINVMST = @"C:\WINDOWS\Temp\INVMST.tps"; TPSDataAccess access = new TPSDataAccess(_PathFileINVMST); string strsql = string.Format(@"Select SKU,Description,Disc_Flag,0 as Check from INVMST where Disc_Flag='N'"); DataTable dt = new DataTable(); dt = access.GetDataTable(strsql); GrDSPriceSKU.DataSource = null; if (dt != null && dt.Rows.Count > 0) { GrDSPriceSKU.DataSource = dt; repositoryItemCheckEdit2.ValueChecked = 1; repositoryItemCheckEdit2.ValueUnchecked = 0; } } else { InfoMessage.HienThi("Thong bao", "Không lấy đữ liệu được ! Vui lòng kiểm tra lại H:\\ hoặc Server 21", "Lay du lieu khong thanh cong", HinhAnhThongBao.THONGTIN, NutThongBao.DONGY); return; } waitingMsg.Finish(); } catch (Exception exception) { CTLError.WriteError("btLoadData ", exception.Message); waitingMsg.Finish(); return; } }
public static void CheckVersion() { string strCurrenVersion = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString(); SQLHelper helper = new SQLHelper(); string strVersion = ""; strVersion = "" + helper.GetExecuteScalarByCommandBytext("Select Version from UpdateList where AppType='12'").ToString(); //if(strVersion==string.Empty) //{ // return; //} if (strVersion != strCurrenVersion) { SplashScreen.EndDisplay(); InfoMessage.HienThi( "Version Của Chương trình không đúng!Vui lòng liên hệ với vi tính hoặc Helpdesk để cập nhật", "Vui lòng cập nhật version " + strVersion, "Thông báo", HinhAnhThongBao.LOI, NutThongBao.DONGY); Process.GetCurrentProcess().Kill(); } }
void DeleteAtt_Text(int pos, List <string> lstFile) { int start = 0; int end = 0; string filename = ""; for (int i = 0; i < lstFile.Count; i++) { end = start + (lstFile[i].Length) + 1; if (pos >= start && pos <= end) { // xử lý delete filename = lstFile[i]; if (filename.Trim().Length > 0) { if (DeleteinDB(filename.Trim(), ID)) { lstFile.Remove(lstFile[i]); txtAtt.RichText.Select(start, end - start + 1); SendKeys.Send(""); //txtAtt.RichText.Text.Replace(" ", ""); SendKeys.Send("{END}"); return; } else { //FrmMessage frm = new FrmMessage("Delete Attachment fail"); //frm.ShowDialog(); InfoMessage.HienThi("Delete Attachment fail", "Thông báo", "Thông báo", HinhAnhThongBao.LOI, NutThongBao.DONGY); return; } } } start = end; } }
private void button2_Click(object sender, EventArgs e) { try { FileInfo f = new FileInfo(textBox1.Text); if (f.Exists && validateFileT(f.Name)) { if (_Store != "") { FileInfo fthumuc0 = new FileInfo(@"\\10.10.1.23\QDLS\MM770FLR\" + _Store + @"\T1" + Ngay.Value.ToString("yyMMdd") + ".001"); if (!fthumuc0.Exists) { f.CopyTo(fthumuc0.FullName); if (GoiEmailNhomWinDSS(f.Name)) { InfoMessage.HienThi("Upload File Thanh Cong !!!", "Upload file....", "Thanh Cong", HinhAnhThongBao.THANHCONG, NutThongBao.DONGY); } } else { InfoMessage.HienThi("File " + fthumuc0.Name + " Da Ton tai,Vui long kiem tra lai !!!", "Upload file....", "Thong Bao", HinhAnhThongBao.THONGTIN, NutThongBao.DONGY); } } } } catch (Exception ex) { CTLError.WriteError("Loi Khi Upload File T ", ex.Message); InfoMessage.HienThi("Vui long lien he voi admin ", "Loi Khi upload file...", "Loi", HinhAnhThongBao.LOI, NutThongBao.DONGY); return; throw; } }
public string AutoSave(string applicationName, string item, string eventIssue, string idNhanVien, string content, string version, string reference) { CTLXuLyAddNewApplication_Master control = new CTLXuLyAddNewApplication_Master(); try { ID = control.AddNewEvent(applicationName, item, eventIssue, idNhanVien, content, version, reference, lstFullFileName, lstFileName); } catch (Exception ex) { //FrmMessage frm = new FrmMessage("Thêm mới không thành công. Vui lòng kiểm tra lại thông tin"); //frm.ShowDialog(); InfoMessage.HienThi("Thêm mới không thành công. Vui lòng kiểm tra lại thông tin", "Thông báo", "Thông báo", HinhAnhThongBao.LOI, NutThongBao.DONGY); return(null); } //FrmMessage frm2 = new FrmMessage("Thêm mới thành công"); //frm2.Show(); InfoMessage.HienThi("Thêm mới thành công", "Thông báo", "Thông báo", HinhAnhThongBao.THANHCONG, NutThongBao.DONGY); btnManualSave.Enabled = true; return(ID); }
private void simpleButton1_Click(object sender, EventArgs e) { string upc = ""; string sku = ""; if (gridView1.RowCount >= 30) { InfoMessage.HienThi("Số lượng SKU cho phép xuất bảng giá là 30 !", "Vui lòng kiểm tra lại", "Thong bao", HinhAnhThongBao.THONGTIN, NutThongBao.DONGY); return; } if (txtSKU.Text == string.Empty || txtSKU.Text.Length > 18) { return; } string where = ""; if (txtSKU.Text.Length <= 9) { sku = _sokhong.Substring(0, 9 - txtSKU.Text.Length) + txtSKU.Text; where = " and SKU='" + sku + "'"; } else { upc = _sokhong.Substring(0, 18 - txtSKU.Text.Length) + txtSKU.Text; where = " and UPC='" + upc + "'"; } if (!validate((sku != string.Empty) ? sku : upc)) { InfoMessage.HienThi("SKU đã có trong danh sách!", "Vui lòng thay đổi số lượng trong lưới", "Thong Bao", HinhAnhThongBao.THONGTIN, NutThongBao.DONGY); return; } TPSDataAccess dataAccess = new TPSDataAccess(_PathFileINVMST); TPSDataAccess dataAccessKM = new TPSDataAccess(_PathFileINVEVT); DataTable dt = new DataTable(); dt = dataAccess.GetTableDM("Select SKU,UPC,Description,Price From INVMST where 1=1 " + where); if (dt == null || dt.Rows.Count <= 0) { InfoMessage.HienThi("SKU không có trong danh mục!", "Vui lòng kiểm tra lại", "Thong Bao", HinhAnhThongBao.THONGTIN, NutThongBao.DONGY); return; } DataTable dtKM = new DataTable(); dtKM = dataAccessKM.GetTableDM("select SKU,QTY1,DISCPRICE,Method From INVEVT where SKU='" + dt.Rows[0]["SKU"].ToString() + "' and " + (Math.Round(DateTime.Now.ToOADate()) + _Const_datetime) + @" >= Start and " + (Math.Round(DateTime.Now.ToOADate()) + _Const_datetime) + " <= stop "); DataRow r = _dsSKU.NewRow(); r["SKU"] = dt.Rows[0]["SKU"].ToString(); r["UPC"] = dt.Rows[0]["UPC"].ToString(); r["Description"] = dt.Rows[0]["Description"].ToString(); r["SoLuong"] = txtsoluong.Value; r["GiaGoc"] = dt.Rows[0]["Price"].ToString(); r["ThanhTien"] = r["GiaGoc"]; if (dtKM.Rows.Count > 0) { r["Method"] = dtKM.Rows[0]["Method"].ToString(); r["DISCPRICE"] = dtKM.Rows[0]["DISCPRICE"].ToString(); r["QTY1"] = dtKM.Rows[0]["QTY1"].ToString(); if (dtKM.Rows[0]["Method"].ToString() == "25") { r["GiaKM"] = dtKM.Rows[0]["DISCPRICE"].ToString(); r["ThanhTien"] = txtsoluong.Value * Convert.ToDecimal(r["GiaKM"]); } else if (dtKM.Rows[0]["Method"].ToString() == "2") { r["ThanhTien"] = (int)(txtsoluong.Value / Int32.Parse(Convert.ToDecimal(dtKM.Rows[0]["QTY1"]).ToString("N0"))) * Convert.ToDecimal(dtKM.Rows[0]["DISCPRICE"].ToString()) + (int)(txtsoluong.Value % Int32.Parse(Convert.ToDecimal(dtKM.Rows[0]["QTY1"]).ToString("N0"))) * Convert.ToDecimal(r["GiaGoc"]); r["GhiChu"] = "Mua SL " + dtKM.Rows[0]["QTY1"].ToString() + " co gia " + Convert.ToDecimal(dtKM.Rows[0]["DISCPRICE"]).ToString("N0"); } } else { r["GiaKM"] = r["GiaGoc"]; r["ThanhTien"] = Convert.ToDecimal(r["GiaGoc"]) * txtsoluong.Value; } _dsSKU.Rows.Add(r); _dsSKUAdd.Add((sku != string.Empty) ? sku : upc, _indexadd++); clearData(); txtSKU.Focus(); GrDSSKU.DataSource = _dsSKU; }
private void tvDocument_AfterLabelEdit(object sender, NodeLabelEditEventArgs e) { if (!isEdit) { if (e.Node.Level == 1) // Application { TreeNode root = tvDocument.Nodes.Find("-1", true)[0]; TreeNode des = FindNameInTreeView(root, e.Label == null?e.Node.Text:e.Label); if (!(des != null && des.Level == 1)) { if (e.Label != null) { _control.AddNewApp(e.Label, ""); AppName = e.Label; } else { _control.AddNewApp(e.Node.Text, ""); AppName = e.Node.Text; } } else { //FrmMessage frm = new FrmMessage("Đã có application " + e.Label + ". Vui lòng dùng tên khác."); //frm.ShowDialog(); InfoMessage.HienThi("Đã có application " + e.Label + ". Vui lòng dùng tên khác.", "Thông báo", "Thông báo", HinhAnhThongBao.THONGTIN, NutThongBao.DONGY); e.Node.Remove(); AppName = ""; return; } } if (e.Node.Level == 2) // Add item { TreeNode root = tvDocument.Nodes.Find("-1", true)[0]; TreeNode des = FindNameInTreeView(root, e.Label == null?e.Node.Text:e.Label); if (!(des != null && des.Level == 2)) { if (_control.CheckEmptyApp(e.Node.Parent.Text)) { if (e.Label != null) { _control.UpdateApp(e.Node.Parent.Text, e.Label); } else { _control.UpdateApp(e.Node.Parent.Text, e.Node.Text); } } else { _control.AddNewApp(e.Node.Parent.Text, e.Label == null?e.Node.Text:e.Label); } if (e.Label != null) { Item = e.Label; } else { Item = e.Node.Text; } } else { //FrmMessage frm = new FrmMessage("Đã có item " + e.Label + ". Vui lòng dùng tên khác."); //frm.ShowDialog(); InfoMessage.HienThi("Đã có item " + e.Label + ". Vui lòng dùng tên khác.", "Thông báo", "Thông báo", HinhAnhThongBao.THONGTIN, NutThongBao.DONGY); e.Node.Remove(); Item = ""; return; } } if (e.Node.Level == 3) // Add issue { TreeNode root = tvDocument.Nodes.Find("-1", true)[0]; TreeNode des = FindNameInTreeView(root, e.Label == null?e.Node.Text:e.Label); if (!(des != null && des.Level == 3)) { rte.CreateDocument(); rte._isModify = false; if (e.Label != null) { e.Node.Name = rte.AutoSave(e.Node.Parent.Parent.Text, e.Node.Parent.Text, e.Label, IdNhanVien, rte.AutoEditor, "", ""); } else { e.Node.Name = rte.AutoSave(e.Node.Parent.Parent.Text, e.Node.Parent.Text, e.Node.Text, IdNhanVien, rte.AutoEditor, "", ""); } } else { //FrmMessage frm = new FrmMessage("Đã có Event " + e.Label + ". Vui lòng dùng tên khác."); //frm.ShowDialog(); InfoMessage.HienThi("Đã có Event " + e.Label + ". Vui lòng dùng tên khác.", "Thông báo", "Thông báo", HinhAnhThongBao.THONGTIN, NutThongBao.DONGY); e.Node.Remove(); rte.Hide(); rte._isModify = false; return; } if (e.Label != null) { EventName = e.Label; rte.Event = e.Label; } else { EventName = e.Node.Text; rte.Event = e.Node.Text; } } } else { // rename if (e.Node.Level == 1) { TreeNode root = tvDocument.Nodes.Find("-1", true)[0]; TreeNode des = FindNameInTreeView(root, e.Label == null?e.Node.Text:e.Label); if (!(des != null && des.Level == 1)) { if (e.Label != null /*|| e.Label.Length > 0*/) { _control.UpdateAppName(AppName, e.Label == null?e.Node.Text:e.Label); } } else { //FrmMessage frm = new FrmMessage("Đã có Application " + e.Label + ". Vui lòng dùng tên khác."); //frm.ShowDialog(); InfoMessage.HienThi("Đã có Application " + e.Label + ". Vui lòng dùng tên khác.", "Thông báo", "Thông báo", HinhAnhThongBao.THONGTIN, NutThongBao.DONGY); return; } } if (e.Node.Level == 2) { TreeNode root = tvDocument.Nodes.Find("-1", true)[0]; TreeNode des = FindNameInTreeView(root, e.Label == null?e.Node.Text:e.Label); if (!(des != null && des.Level == 1)) { if (e.Label != null /*|| e.Label.Length > 0*/) { _control.UpdateItemName(Item, e.Label == null?e.Node.Text:e.Label, ((TreeNode)e.Node.Parent).Text); } } else { //FrmMessage frm = new FrmMessage("Đã có item " + e.Label + ". Vui lòng dùng tên khác."); //frm.ShowDialog(); InfoMessage.HienThi("Đã có item " + e.Label + ". Vui lòng dùng tên khác.", "Thông báo", "Thông báo", HinhAnhThongBao.THONGTIN, NutThongBao.DONGY); return; } } if (e.Node.Level == 3) { TreeNode root = tvDocument.Nodes.Find("-1", true)[0]; TreeNode des = FindNameInTreeView(root, e.Label == null?e.Node.Text:e.Label); if (!(des != null && des.Level == 1)) { if (e.Label != null /*|| e.Label.Length > 0*/) { _control.UpdateEventName(EventName, e.Label == null ? e.Node.Text : e.Label, ((TreeNode)e.Node.Parent.Parent).Text, ((TreeNode)e.Node.Parent).Text); } } else { //FrmMessage frm = new FrmMessage("Đã có item " + e.Label + ". Vui lòng dùng tên khác."); //frm.ShowDialog(); InfoMessage.HienThi("Đã có item " + e.Label + ". Vui lòng dùng tên khác.", "Thông báo", "Thông báo", HinhAnhThongBao.THONGTIN, NutThongBao.DONGY); return; } } } tvDocument.LabelEdit = false; }
private void tvDocument_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e) { lstAtt = new List <DocAttachment>(); if (e.Node.Level == 3 && e.Button == MouseButtons.Left) { if (rte._isModify) { if (InfoMessage.HienThi("Bạn muốn đóng Văn bản đang soạn thảo??", "Thông báo", "Close Document", HinhAnhThongBao.HOI, NutThongBao.CO_KHONG) == KetQuaThongBao.KHONG) { return; } else { rte._isModify = false; } } EventName = e.Node.Text; DataTable kq = _control.LoadEventContent(e.Node.Text, e.Node.Parent.Parent.Text, e.Node.Parent.Text); rte._isload = true; rte._isModify = false; if (kq.Rows.Count > 0) { StringBuilder richText = new StringBuilder(); richText.Append(Convert.ToString(kq.Rows[0]["IssueContent"])); string reference = Convert.ToString(kq.Rows[0]["Reference"]); string version = Convert.ToString(kq.Rows[0]["Version"]); string att = Convert.ToString(kq.Rows[0]["Title"]); currentID = e.Node.Name; if (att.Length > 0) { att = att.Substring(0, att.Length - 1); } //region xu ly viewdoc string[] lstatt = att.Split(';'); att = " "; foreach (string s in lstatt) { if (s.Length > 0) { int index = s.IndexOf('-') + 1; int length = s.Length - index; att += s.Substring(index, length) + "; "; DocAttachment item = new DocAttachment(); item.Id = s.Substring(0, s.IndexOf('-')); item.Name = s.Substring(index, length); item.Filepath = ""; item.DocId = currentID; lstAtt.Add(item); } } if (att.Length > 0) { att = att.Substring(0, att.Length - 1); } //endregion rte.Visible = true; rte.ViewDocument(richText, version, att, Convert.ToString(kq.Rows[0]["Title"]), reference, currentID); rte.GetListAttachment(lstAtt); rte._isModify = false; } else { } } if (e.Node.Level == 1) { AppName = e.Node.Text; } if (e.Node.Level == 2) { Item = e.Node.Text; } if (e.Node.Level == 3) { AppName = e.Node.Parent.Parent.Text; Item = e.Node.Parent.Text; } }
private void BTXuatfile_Click(object sender, EventArgs e) { //SaveFileDialog saveFileDialog = new SaveFileDialog(); //saveFileDialog.Filter = "PRCUPD.*|PRCUPD.*"; //saveFileDialog.FileName = "PRCUPD.001"; //if (saveFileDialog.ShowDialog() == DialogResult.OK) //{ try { if (gridView1.DataRowCount <= 0) { InfoMessage.HienThi("Không có dữ liệu export!!!!!", "Vui lòng kiểm tra lại", "Thông báo", HinhAnhThongBao.THONGTIN, NutThongBao.DONGY); return; } gridView1.FocusedRowHandle = -1; bool isdata = false; for (int i = 0; i < gridView1.DataRowCount; i++) { DataRow row = gridView1.GetDataRow(i); if (Convert.ToBoolean(row["Check"])) { isdata = true; } } if (!isdata) { InfoMessage.HienThi("vui lòng chọn dữ liệu export!!!!!", "Vui lòng kiểm tra lại", "Thông báo", HinhAnhThongBao.THONGTIN, NutThongBao.DONGY); return; } CTLSearchBug ctlSearchBug = new CTLSearchBug(); int iTo = 0; int maxP = GetMaxFilePRCUPD(); if (_filepuge < maxP) { _filepuge = maxP + 1; } if (_filepuge < 999) { _filepuge += 1; } //for (int i = 0; i < gridView1.DataRowCount;) //{ //int numTemp = gridView1.DataRowCount - i; //iTo = numTemp> 100 ? iTo + 100 : iTo + (numTemp); DirectoryInfo directoryInfo = new DirectoryInfo(Path.Combine(Path.Combine(Application.StartupPath, "ExportBackup"), DateTime.Now.ToString("yyyyMMddhhmm"))); if (!directoryInfo.Exists) { directoryInfo.Create(); } if (!ExportFile(@"H:\Pollfile")) { InfoMessage.HienThi("Conect server không thành công!!!!!", "Vui lòng kiểm tra lại", "Thông báo", HinhAnhThongBao.THONGTIN, NutThongBao.DONGY); return; } ExportFile(directoryInfo.FullName); //} // Ghi log file khi export ctlSearchBug.InsertTraceLog(Config._MaNV, DateTime.Now, GetIP(), "FrmSynPrice", 1, "FrontEnd Utility", "Export PRCUPD file"); InfoMessage.HienThi("Export file " + " thành công !!!!!", "Export file", "Thanh cong", HinhAnhThongBao.THANHCONG, NutThongBao.DONGY); return; } catch (Exception exception) { CTLError.WriteError("Export file from DSSKU ", exception.Message); //ctlSearchBug.InsertTraceLog(Config._MaNV, DateTime.Now, GetIP(), "FrmSynPrice", 0); return; throw; } }
private void tvDocument_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Delete) { if (tvDocument.SelectedNode.Level == 1) // delete app { //FrmConfirm askApp = // new FrmConfirm("Bạn có chắc muốn xóa application " + tvDocument.SelectedNode.Text); //askApp.ShowDialog(); if (InfoMessage.HienThi("Bạn có chắc muốn xóa application " + tvDocument.SelectedNode.Text, "Delete Application", "Thông báo", HinhAnhThongBao.HOI, NutThongBao.CO_KHONG) == KetQuaThongBao.CO) { string name = tvDocument.SelectedNode.Text; if (_control.DeleteApplication(name)) { tvDocument.Nodes.Remove(tvDocument.SelectedNode); //FrmMessage frm = new FrmMessage("Đã xóa application " + name); //frm.ShowDialog(); InfoMessage.HienThi("Đã xóa application " + name, "Thông báo", "Thông báo", HinhAnhThongBao.THONGTIN, NutThongBao.DONGY); return; } else { //FrmMessage frm = new FrmMessage("Không xóa được application " + name); //frm.ShowDialog(); InfoMessage.HienThi("Không xóa được application " + name, "Thông báo", "Thông báo", HinhAnhThongBao.THONGTIN, NutThongBao.DONGY); return; } } } if (tvDocument.SelectedNode.Level == 2) // delete item { //FrmConfirm askItem = new FrmConfirm("Bạn có chắc muốn xóa item " + tvDocument.SelectedNode.Text); //askItem.ShowDialog(); if (/*askItem.buttonRes == FrmConfirm.ButtonResult.OK*/ InfoMessage.HienThi("Bạn có chắc muốn xóa item " + tvDocument.SelectedNode.Text, "Thông báo", "Thông báo", HinhAnhThongBao.HOI, NutThongBao.CO_KHONG) == KetQuaThongBao.CO) { string itemName = tvDocument.SelectedNode.Text; string appName = tvDocument.SelectedNode.Parent.Text; if (_control.DeleteItem(appName, itemName)) { tvDocument.Nodes.Remove(tvDocument.SelectedNode); //FrmMessage frm = new FrmMessage("Đã xóa item " + itemName); //frm.ShowDialog(); InfoMessage.HienThi("Đã xóa item " + itemName, "Thông báo", "Thông báo", HinhAnhThongBao.THANHCONG, NutThongBao.DONGY); return; } else { //FrmMessage frm = new FrmMessage("Không xóa được item " + itemName); //frm.ShowDialog(); InfoMessage.HienThi("Không xóa được item " + itemName, "Thông báo", "Thông báo", HinhAnhThongBao.THANHCONG, NutThongBao.DONGY); return; } } } if (tvDocument.SelectedNode.Level == 3) // delete item { //FrmConfirm askItem = new FrmConfirm("Bạn có chắc muốn xóa item " + tvDocument.SelectedNode.Text); //askItem.ShowDialog(); if (InfoMessage.HienThi("Bạn có chắc muốn xóa item " + tvDocument.SelectedNode.Text, "Delete Item", "Thông báo", HinhAnhThongBao.HOI, NutThongBao.CO_KHONG) == KetQuaThongBao.CO) { string itemName = tvDocument.SelectedNode.Parent.Text; string appName = tvDocument.SelectedNode.Parent.Parent.Text; string eventName = tvDocument.SelectedNode.Text; if (_control.DeleteEvent(appName, itemName, eventName)) { TreeNode next = tvDocument.SelectedNode.NextNode; tvDocument.Nodes.Remove(tvDocument.SelectedNode); rte.Visible = false; rte._isModify = false; tvDocument.SelectedNode = next; //FrmMessage frm = new FrmMessage("Đã xóa event " + eventName); //frm.ShowDialog(); InfoMessage.HienThi("Đã xóa event " + eventName, "Thông báo", "Thông báo", HinhAnhThongBao.THANHCONG, NutThongBao.DONGY); return; } else { //FrmMessage frm = new FrmMessage("Không xóa được event " + eventName); //frm.ShowDialog(); InfoMessage.HienThi("Không xóa được event " + eventName, "Thông báo", "Thông báo", HinhAnhThongBao.THONGTIN, NutThongBao.DONGY); return; } } } } if (e.KeyCode == Keys.F2) { tvDocument.LabelEdit = true; tvDocument.SelectedNode.BeginEdit(); } }
private void txtsoluong_KeyDown(object sender, KeyEventArgs e) { string upc = ""; string sku = ""; if (e.KeyCode == Keys.F5) { btclear_Click(null, null); return; } if (e.KeyCode == Keys.Enter) { if (gridView1.RowCount >= 30) { InfoMessage.HienThi("Số lượng SKU cho phép xuất bảng giá là 30 !", "Vui lòng kiểm tra lại", "Thong bao", HinhAnhThongBao.THONGTIN, NutThongBao.DONGY); return; } if (txtSKU.Text == string.Empty || txtSKU.Text.Length > 18) { return; } string where = ""; if (txtSKU.Text.Length <= 9) { sku = _sokhong.Substring(0, 9 - txtSKU.Text.Length) + txtSKU.Text; where = " and SKU='" + sku + "'"; } else { upc = _sokhong.Substring(0, 18 - txtSKU.Text.Length) + txtSKU.Text; where = " and UPC='" + upc + "'"; } if (!validate((sku != string.Empty) ? sku : upc)) { InfoMessage.HienThi("SKU đã có trong danh sách!", "Vui lòng thay đổi số lượng trong lưới", "Thong Bao", HinhAnhThongBao.THONGTIN, NutThongBao.DONGY); return; } TPSDataAccess dataAccess = new TPSDataAccess(_PathFileINVMST); TPSDataAccess dataAccessKM = new TPSDataAccess(_PathFileINVEVT); DataTable dt = new DataTable(); dt = dataAccess.GetTableDM("Select SKU,UPC,Description,Price From INVMST where 1=1 " + where); if (dt == null || dt.Rows.Count <= 0) { InfoMessage.HienThi("SKU không có trong danh mục!", "Vui lòng kiểm tra lại", "Thong Bao", HinhAnhThongBao.THONGTIN, NutThongBao.DONGY); return; } DataTable dtKM = new DataTable(); dtKM = dataAccessKM.GetTableDM("select SKU,QTY1,PRICE,DISCPRICE,Method,Prc_Key,Code From INVEVT where SKU='" + dt.Rows[0]["SKU"].ToString() + "' and " + (Math.Round(dateNgayapDung.Value.ToOADate()) + _Const_datetime) + @" >= Start and " + (Math.Round(dateNgayapDung.Value.ToOADate()) + _Const_datetime) + " <= stop and Method in (2,25)"); DataRow r = _dsSKU.NewRow(); r["SKU"] = dt.Rows[0]["SKU"].ToString(); r["UPC"] = dt.Rows[0]["UPC"].ToString(); r["Description"] = dt.Rows[0]["Description"].ToString(); r["SoLuong"] = txtsoluong.Value; r["GiaGoc"] = dt.Rows[0]["Price"].ToString(); r["ThanhTien"] = r["GiaGoc"]; if (dtKM.Rows.Count > 0) { r["Method"] = dtKM.Rows[0]["Method"].ToString(); r["DISCPRICE"] = dtKM.Rows[0]["DISCPRICE"].ToString(); r["QTY1"] = dtKM.Rows[0]["QTY1"].ToString(); if (dtKM.Rows[0]["Method"].ToString() == "25") { DataRow row; if (dtKM.Select("MeThod=25 and Prc_Key=Min(Prc_Key)").Length == 1) { row = dtKM.Select("MeThod=25 and Prc_Key=Min(Prc_Key)")[0]; } else { Int32 prc_key = Convert.ToInt32(dtKM.Select("MeThod=25 and Prc_Key=Min(Prc_Key)")[0]["Prc_key"]); row = dtKM.Select("MeThod=25 and Prc_Key=" + prc_key + " and Code=max(Code)")[0]; } //panel1.Visible = true; //labgiapos.Text = " " + Convert.ToDecimal(row["Price"]).ToString("N2");// +" Từ: " + Convert.ToDateTime(row["Start"]).ToString("dd/MM/yyyy") + " Đến:" + Convert.ToDateTime(row["Stop"]).ToString("dd/MM/yyyy"); //labslpos.Text = "1"; r["GiaKM"] = row["PRICE"].ToString(); r["ThanhTien"] = txtsoluong.Value * Convert.ToDecimal(r["GiaKM"]); } else if (dtKM.Rows[0]["Method"].ToString() == "2") { DataRow row; if (dtKM.Select("MeThod=2 and Prc_Key=Min(Prc_Key)").Length == 1) { row = dtKM.Select("MeThod=2 and Prc_Key=Min(Prc_Key)")[0]; } else { Int32 prc_key = Convert.ToInt32(dtKM.Select("MeThod=2 and Prc_Key=Min(Prc_Key)")[0]["Prc_key"]); row = dtKM.Select("MeThod=2 and Prc_Key=" + prc_key + " and Code=max(Code)")[0]; } //panel2.Visible = true; //labGiaKMTL.Text = "Khi mua với SL " + Convert.ToInt32(row["Qty1"]).ToString("N0") + " giá tiền là " + Convert.ToDecimal(row["DiscPrice"]).ToString("N2"); //+ " Từ: " + Convert.ToDateTime(row["Start"]).ToString("dd/MM/yyyy") + " Đến:" + Convert.ToDateTime(row["Stop"]).ToString("dd/MM/yyyy"); //labslKMTL.Text = Convert.ToInt32(row["Qty1"]).ToString("N0"); r["ThanhTien"] = (int)(txtsoluong.Value / Int32.Parse(Convert.ToDecimal(row["QTY1"]).ToString("N0"))) * Convert.ToDecimal(row["DISCPRICE"].ToString()) + (int)(txtsoluong.Value % Int32.Parse(Convert.ToDecimal(row["QTY1"]).ToString("N0"))) * Convert.ToDecimal(r["GiaGoc"]); r["GhiChu"] = "Mua SL " + row["QTY1"].ToString() + " co gia " + Convert.ToDecimal(row["DISCPRICE"]).ToString("N0"); } } else { r["GiaKM"] = r["GiaGoc"]; r["ThanhTien"] = Convert.ToDecimal(r["GiaGoc"]) * txtsoluong.Value; } _dsSKU.Rows.Add(r); _dsSKUAdd.Add((sku != string.Empty) ? sku : upc, _indexadd++); clearData(); txtSKU.Focus(); } GrDSSKU.DataSource = _dsSKU; //_dsSKUAdd.Add((sku != string.Empty) ? sku : upc, _indexadd++); //clearData(); }
private void BTHienthi_Click(object sender, EventArgs e) { WaitingMsg waitingMsg = new WaitingMsg("Chương trình đang load dữ liệu!", "Please Waiting ......."); try { _tbDSGia.Clear(); copyfile(Config._pathfileWinDSS); //TPSDataAccess access = new TPSDataAccess(Path.Combine(CTLConfig._pathfileWinDSS, "INVMST")); TPSDataAccess access = new TPSDataAccess(_PathFileINVMST); TPSDataAccess accessPathWSS = new TPSDataAccess(Path.Combine(Config._pathfileWinDSS, "SYSMST")); SQLHelper helper = new SQLHelper(true); string MaST = "0"; MaST = accessPathWSS.getMaSieuthi(); _storeName = MaST; helper.AddParameterToSQLCommand("@STR", SqlDbType.NVarChar, 8); helper.SetSQLCommandParameterValue("@STR", MaST); if (MaST == "0") { InfoMessage.HienThi("Khong lay duoc StoreNumber " + MaST + " ", "Vui long lien he voi quan tri", "Loi Get StoreNumber", HinhAnhThongBao.LOI, NutThongBao.DONGY); return; } string strconf = ""; string strsale = ""; string strupc = ""; if (!radConfirAll.Checked) { strconf = " and CONF_PRICE=" + (radconfirYes.Checked ? "'Y'" : "'N'"); helper.AddParameterToSQLCommand("@ISTYPE", SqlDbType.NVarChar, 8); helper.SetSQLCommandParameterValue("@ISTYPE", (radconfirNo.Checked) ? "01" : "CS"); } if (!radsaleAll.Checked) { strsale = " and SELL_UNIT=" + (radsaleEA.Checked ? "'EA'" : "'KG'"); helper.AddParameterToSQLCommand("@ISLUM", SqlDbType.NVarChar, 8); helper.SetSQLCommandParameterValue("@ISLUM", (radsaleKG.Checked) ? radsaleKG.Text : radsaleEA.Text); } if (!radUPCALL.Checked) { strupc = " and UPC<>''"; helper.AddParameterToSQLCommand("@ISUPC", SqlDbType.NVarChar, 8); helper.SetSQLCommandParameterValue("@ISUPC", 1); } DataTable dt = helper.GetDatatableBySP("PRLN_spGetPricebyStore"); string sql = string.Format("Select SKU,Price,Description from INVMST where 1=1 {0}{1}{2} order by SKU", strconf, strsale, strupc); DataTable tbg = access.GetDataTable(sql); int dem = 0; foreach (DataRow dataRow in dt.Rows) { decimal p = Convert.ToDecimal(dataRow["PLNITM"].ToString()); for (int i = dem; i < tbg.Rows.Count; i++) { decimal pMMS = Convert.ToDecimal(tbg.Rows[i]["SKU"].ToString()); if (p == pMMS) { if (Convert.ToDecimal(tbg.Rows[i]["Price"]) != Convert.ToDecimal(dataRow["PLNAMT"].ToString())) { DataRow r = _tbDSGia.NewRow(); r["SKU"] = "00" + dataRow["PLNITM"].ToString(); r["Check"] = false; r["Description"] = tbg.Rows[i]["Description"].ToString(); r["Price"] = Convert.ToDecimal(dataRow["PLNAMT"].ToString()); r["PriceMMS"] = Convert.ToDecimal(tbg.Rows[i]["Price"]); _tbDSGia.Rows.Add(r); } dem = i + 1; break; } else if (pMMS > p) { dem = i; break; } } } GrDSPriceSKU.DataSource = _tbDSGia; waitingMsg.Finish(); } catch (Exception exception) { CTLError.WriteError("btLoadData ", exception.Message); waitingMsg.Finish(); return; throw; } }
private void btnManualSave_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { if (isComment) { CTLSearchBug searchBug = new CTLSearchBug(); string ten = Config._tennv + "-" + Config._tenst; if (searchBug.InsertFeedBack(_IDIsuee, Editor.Document.RtfText, (ten.Length > 36) ? ten.Substring(0, 36) : ten.Substring(0, ten.Length), "")) { _isfinish = true; } return; } _isload = true; _isModify = false; //if (isNew) //{ // // Khi lưu phải lưu những phần DocumentIssue, DocumentDetail,Attachment // string applicationName = AppName; // string item = Item; // string eventIssue = Event; // string idNhanVien = IDNhanVien; // string content = Editor.Document.RtfText; // string version = txtVersion.Text; // string reference = txtReference.Text; // CTLXuLyAddNewApplication_Master control = new CTLXuLyAddNewApplication_Master(); // try // { // control.AddNewEvent(applicationName, item, eventIssue, idNhanVien, content, version, // reference, lstFullFileName, lstFileName); // } // catch (Exception ex) // { // FrmMessage frm = new FrmMessage("Thêm mới không thành công. Vui lòng kiểm tra lại thông tin"); // frm.Show(); // return; // } // FrmMessage frm2 = new FrmMessage("Thêm mới thành công"); // frm2.Show(); // btnManualSave.Enabled = true; // return; //} //else //{ // Cập nhật detail: string applicationName = AppName; string item = Item; string eventIssue = Event; string idNhanVien = IDNhanVien; StringBuilder content = new StringBuilder(); content.Append(Editor.Document.RtfText); string version = txtVersion.Text; string reference = txtReference.Text; try { //int a = control.UpdateDocument_Detail(ID, content,version,reference,Att_Title,lstFileName); if (CompareAttachment(content.ToString(), version, reference, Att_Title)) { //FrmMessage frm1 = new FrmMessage("Cập nhật thành công"); //frm1.ShowDialog(); InfoMessage.HienThi("Cập nhật thành công", "Update", "Thông báo", HinhAnhThongBao.THANHCONG, NutThongBao.DONGY); lstFileName.Clear(); lstFullFileName.Clear(); return; } else { //FrmMessage frm = new FrmMessage("Cập nhật không thành công. Vui lòng kiểm tra lại thông tin"); //frm.ShowDialog(); InfoMessage.HienThi("Cập nhật không thành công", "Update", "Thông báo", HinhAnhThongBao.LOI, NutThongBao.DONGY); lstFileName.Clear(); lstFullFileName.Clear(); return; } } catch (Exception ex) { //FrmMessage frm = new FrmMessage("Cập nhật không thành công. Vui lòng kiểm tra lại thông tin"); //frm.ShowDialog(); InfoMessage.HienThi("Cập nhật không thành công. Vui lòng kiểm tra lại thông tin", "Update", "Thông báo", HinhAnhThongBao.LOI, NutThongBao.DONGY); lstFileName.Clear(); lstFullFileName.Clear(); return; } //} }
public static bool InsertDonDatHang(EntityDonDatHang dh, DataTable ctdh) { SQLHelper sqlHelper = new SQLHelper(); decimal soluong = 0; decimal thanhtien = 0; try { sqlHelper.BeginTransaction("InsertDDH"); string sql = string.Format(@" INSERT INTO [" + Config._DBNameFrontEnd + @"].dbo.DonDatHang ( ID, HoTen, DienThoai, DiaChi, SoLuong, ThanhTien, NgayTao, GhiChu ) VALUES ( '{0}'/* ID */, '{1}'/* HoTen */, '{2}'/* DienThoai */, '{3}'/* DiaChi */, {4}/* SoLuong */, {5}/* ThanhTien */, @ngaytao/* NgayTao */, '{6}'/* GhiChu */ )", dh.ID, dh.HoTen, dh.DT, dh.DiaChi, dh.SoLuong, dh.ThanTien, dh.GhiChu); sqlHelper.AddParameterToSQLCommand("@ngaytao", SqlDbType.DateTime); //sqlHelper.AddParameterToSQLCommand("@image", SqlDbType.Image); sqlHelper.SetSQLCommandParameterValue("@ngaytao", dh.NgayTao); //sqlHelper.SetSQLCommandParameterValue("@image", a.Image); bool kq = sqlHelper.GetExecuteNonQueryByCommand(sql) > 0; if (!kq) { InfoMessage.HienThi("Lưu đơn hàng không thành công!", "Lưu đơn đặt hàng", "Thong Bao", HinhAnhThongBao.LOI, NutThongBao.DONGY); return(false); } foreach (DataRow row in ctdh.Rows) { EntityCTDonDatHang ct = new EntityCTDonDatHang(); ct.ID = Guid.NewGuid().ToString(); ct.IDDonDatHang = dh.ID; ct.SKU = row["SKU"].ToString(); ct.UPC = row["UPC"].ToString(); ct.GhiChu = ("" + row["GhiChu"]).ToString(); ct.TenSP = row["Description"].ToString(); ct.SoLuong = Convert.ToDecimal(row["SoLuong"]); ct.GiaGoc = Convert.ToDecimal(row["GiaGoc"]); ct.GiaKM = Convert.ToDecimal("0" + row["GiaKM"]); ct.ThanTien = Convert.ToDecimal(row["ThanhTien"]); kq &= InsertCTDDH(ct); soluong += ct.SoLuong; thanhtien += ct.ThanTien; } //kq &= UpdateDonDatHang(dh.ID, soluong, thanhtien); if (!kq) { InfoMessage.HienThi("Lưu đơn hàng không thành công!", "Lưu đơn đặt hàng", "Thong Bao", HinhAnhThongBao.LOI, NutThongBao.DONGY); return(false); } sqlHelper.Commit(); InfoMessage.HienThi("Lưu đơn hàng thành công!!!", "Lưu đơn đặt hàng", "Thong Bao", HinhAnhThongBao.THANHCONG, NutThongBao.DONGY); return(true); } catch (Exception ex) { sqlHelper.Rollback("InsertDDH"); InfoMessage.HienThi("Lưu đơn hàng không thành công!", "Lưu đơn đặt hàng", "Thong Bao", HinhAnhThongBao.LOI, NutThongBao.DONGY); CTLError.WriteError("InsertDonDatHang ", ex.Message); return(false); throw; } }