private void btn_Commit_Click(object sender, EventArgs e) { if (CheckRequiredFields()) { if (Config.PrintAdmissionDocument && Db.GetPrinterName(Utility.GetMACAddress()) == "N/A") { MessageBox.Show("لم يتم تحديد الطابعة التي سيتم عبرها طباعة بطاقة الدخول", "خطأ" , MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1, MessageBoxOptions.RightAlign); } else { string Msg = "هل تريد بالتأكيد الحفظ؟" + Environment.NewLine + Environment.NewLine + "تنبيه : لايمكن التراجع بعد الحفظ."; if (new Dialogs.Dg_ComfirmMessage("الحفظ", Msg).MessageResult() == DialogResult.Yes) { if (CurrentStepName == "new") { #region Create New Reception ... string EntryDocNo = Db.CreateDlgReception(txt_H_CertNo.Text, int.Parse(txt_H_ShareQty.Text), CurrentDelegateClass , txt_H_HolderName.Text, txt_H_IdTypeId.Text, txt_H_IdNo.Text, DateTime.Parse(txt_H_IdDate.Text) , txt_H_IdPlace.Text, int.Parse(string.IsNullOrEmpty(txt_H_CardNo.Text) ? "0" : txt_H_CardNo.Text) , string.Empty, SharedParam.CurrentUser.UserID, "HolderDelagate", "pending", string.Empty); if (int.Parse(EntryDocNo) > 0) { int lineno = 0; foreach (PresentHolderCertsWithDelegate tmp in HolderCertsList) { int result = Db.CreateDlgReceptionDetails(int.Parse(EntryDocNo), ++lineno, tmp.CertNo, tmp.ShareQty, tmp.ClassId , tmp.IsDelagated, tmp.DlgNo, tmp.DlgDate, tmp.DlgName, tmp.ApprovedNo, tmp.ApprovedDate, tmp.ApprovedOrg , int.Parse(tmp.RowId), tmp.Note, tmp.Delegate_Type, tmp.Reception_Type, tmp.Userid); } if (!Db.HasData("DlgReception_Details", " Where entry_doc_no=" + EntryDocNo)) { Db.ExecuteSQLCommand("delete from DlgReception where entry_doc_no=" + EntryDocNo); } else { DataTable dt = Db.GetDataAsDataTable("select isnull(count(*),0) cnt,sum(share_qty) shares from DlgReception_Details where entry_doc_no=@entrydocno" , "actual", "entrydocno", EntryDocNo); if (dt != null) { Dialogs.Dg_InfoMessage frm = new Dialogs.Dg_InfoMessage("تم الحفظ بنجاح" , EntryDocNo , (dt.Rows[0]["cnt"] == DBNull.Value ? 0 : (int)dt.Rows[0]["cnt"]) , (dt.Rows[0]["shares"] == DBNull.Value ? 0 : (int)dt.Rows[0]["shares"])); frm.ShowDialog(); #region Print Admission Paper ... //if (Config.PrintAdmissionDocument) //{ // string result = Db.CreatePrint(int.Parse(EntryDocNo) // , "entry", "first_print", SharedParam.CurrentUser.UserID, "other" // , string.Empty); // if (result == "success") // { // DataTable dt2 = Db.GetDataAsDataTableFromSP("sp_AdmissionReport", "AdmissionDT", "@EntryDocNo", EntryDocNo); // appcode.Printable p = new Printable(); // //p.PrinterName = "PDFCreator"; // ReportParameter[] ReportParams = new ReportParameter[] // { //new ReportParameter("EventDate",Config.EventDate), //new ReportParameter("EventYear",Config.EventYear) // }; // //frm_Report frm2 = new frm_Report(); // //frm2.PreviewAdmissionByAgentReport(EntryDocNo, ReportParams); // p.OnlyOnePage = true; // p.Run(@Config.ReportsPath + "AgentAdmission.rdlc", "AddmissionDataset", dt2, ReportParams); // } // else // { // MessageBox.Show("فشلت عملية الطباعة"); // } //} #endregion NewTransaction(); } } } else { } #endregion } else if (CurrentStepName == "edit") { #region Edit Reception ... int result = Db.EditDlgReception(CurrentEntryNo, txt_H_IdTypeId.Text, txt_H_IdNo.Text, DateTime.Parse(txt_H_IdDate.Text) , txt_H_IdPlace.Text, int.Parse(string.IsNullOrEmpty(txt_H_CardNo.Text) ? "0" : txt_H_CardNo.Text), string.Empty); if (result == 1) { Db.ExecuteSQLCommand("delete from DlgReception_Details where entry_doc_no=" + CurrentEntryNo); int lineno = 0; foreach (PresentHolderCertsWithDelegate tmp in HolderCertsList) { result = Db.CreateDlgReceptionDetails(int.Parse(CurrentEntryNo), ++lineno, tmp.CertNo, tmp.ShareQty, tmp.ClassId , tmp.IsDelagated, tmp.DlgNo, tmp.DlgDate, tmp.DlgName, tmp.ApprovedNo, tmp.ApprovedDate, tmp.ApprovedOrg , int.Parse(tmp.RowId), tmp.Note, tmp.Delegate_Type, tmp.Reception_Type, tmp.Userid); } DataTable dt = Db.GetDataAsDataTable("select isnull(count(*),0) cnt,sum(share_qty) shares from DlgReception_Details where entry_doc_no=@entrydocno" , "actual", "entrydocno", CurrentEntryNo); if (dt != null) { Dialogs.Dg_InfoMessage frm = new Dialogs.Dg_InfoMessage("تم التعديل بنجاح" , CurrentEntryNo , (dt.Rows[0]["cnt"] == DBNull.Value ? 0 : (int)dt.Rows[0]["cnt"]) , (dt.Rows[0]["shares"] == DBNull.Value ? 0 : (int)dt.Rows[0]["shares"])); frm.ShowDialog(); #region Print Admission Paper ... //if (Config.PrintAdmissionDocument) //{ // string result2 = Db.CreatePrint(int.Parse(CurrentEntryNo) // , "entry", "first_print", SharedParam.CurrentUser.UserID, "other" // , string.Empty); // if (result2 == "success") // { // DataTable dt2 = Db.GetDataAsDataTableFromSP("sp_AdmissionReport", "AdmissionDT", "@EntryDocNo", EntryDocNo); // appcode.Printable p = new Printable(); // //p.PrinterName = "PDFCreator"; // ReportParameter[] ReportParams = new ReportParameter[] // { // new ReportParameter("EventDate",Config.EventDate), // new ReportParameter("EventYear",Config.EventYear) // }; // //frm_Report frm2 = new frm_Report(); // //frm2.PreviewAdmissionByAgentReport(EntryDocNo, ReportParams); // p.OnlyOnePage = true; // p.Run(@Config.ReportsPath + "AgentAdmission.rdlc", "AddmissionDataset", dt2, ReportParams); // } // else // { // MessageBox.Show("فشلت عملية الطباعة"); // } //} #endregion this.Close(); } } #endregion } } else { //MessageBox.Show("NO"); } }// Check Printer ... } }
private void btn_Commit_Click(object sender, EventArgs e) { if (CheckRequiredFields()) { if (Config.PrintAdmissionDocument && Db.GetPrinterName(Utility.GetMACAddress()) == "N/A") { MessageBox.Show("لم يتم تحديد الطابعة التي سيتم عبرها طباعة بطاقة الدخول", "خطأ" , MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1, MessageBoxOptions.RightAlign); } else { string Msg = "هل تريد بالتأكيد الحفظ؟" + Environment.NewLine + Environment.NewLine + "تنبيه : لايمكن التراجع بعد الحفظ."; if (new Dialogs.Dg_ComfirmMessage("الحفظ", Msg).MessageResult() == DialogResult.Yes) { string EntryDocNo = Db.CreateReception(txt_H_CertNo.Text, int.Parse(txt_H_ShareQty.Text), CurrentHolderClass , txt_H_HolderName.Text, txt_H_IdTypeId.Text, txt_H_IdNo.Text, DateTime.Parse(txt_H_IdDate.Text) , txt_H_IdPlace.Text, int.Parse(string.IsNullOrEmpty(txt_H_CardNo.Text) ? "0" : txt_H_CardNo.Text) , string.Empty, SharedParam.CurrentUser.UserID, "Holder", "post", SharedParam.CurrentUser.UserID); if (int.Parse(EntryDocNo) > 0) { int lineno = 0; foreach (PresentHolderCerts tmp in HolderCertsList) { int result = Db.CreateReceptionDetails(int.Parse(EntryDocNo), ++lineno, tmp.CertNo, tmp.ShareQty, tmp.ClassId , false, string.Empty, DateTime.MinValue, string.Empty, string.Empty, DateTime.MinValue, string.Empty , int.Parse(tmp.RowId), string.Empty, "Delegated", "Holder", SharedParam.CurrentUser.UserID); } if (!Db.HasData("reception_details", " Where entry_doc_no=" + EntryDocNo)) { Db.ExecuteSQLCommand("delete from reception where entry_doc_no=" + EntryDocNo); } else { DataTable dt = Db.GetDataAsDataTable("select isnull(count(*),0) cnt,sum(share_qty) shares from reception_details where entry_doc_no=@entrydocno" , "actual", "entrydocno", EntryDocNo); if (dt != null) { Dialogs.Dg_InfoMessage frm = new Dialogs.Dg_InfoMessage("تم الحفظ بنجاح" , EntryDocNo , (dt.Rows[0]["cnt"] == DBNull.Value ? 0 : (int)dt.Rows[0]["cnt"]) , (dt.Rows[0]["shares"] == DBNull.Value ? 0 : (int)dt.Rows[0]["shares"])); frm.ShowDialog(); NewTransaction(); if (Config.PrintAdmissionDocument) { string result = Db.CreatePrint(int.Parse(EntryDocNo) , "entry", "first_print", SharedParam.CurrentUser.UserID, "other" , string.Empty); if (result == "success") { //if (Config.GetPrinterName() != "N/A") //{ DataTable dt2 = Db.GetDataAsDataTableFromSP("sp_AdmissionReport", "AdmissionDT", "@EntryDocNo", EntryDocNo); appcode.Printable p = new Printable(); //p.PrinterName = "PDFCreator"; ReportParameter[] ReportParams = new ReportParameter[] { new ReportParameter("EventDate", Config.EventDate), new ReportParameter("EventYear", Config.EventYear) }; p.OnlyOnePage = true; p.Run(@Config.ReportsPath + "SelfAdmission.rdlc", "AdmissionDataset", dt2, ReportParams); //PrintToPrinter(EntryDocNo, ReportParams); //PrintToPrinter(EntryDocNo); //} //else //{ //} } else { MessageBox.Show("فشلت عملية الطباعة"); } } } } } else { } } else { //MessageBox.Show("NO"); } } } }