protected void dxgvInvoiceLineItems_BeforePerformDataSelect(object sender, EventArgs e) { try { if ((sender as ASPxGridView).GetMasterRowKeyValue() == null) { return; } Int32 InvoiceId = Int32.Parse((sender as ASPxGridView).GetMasterRowKeyValue().ToString()); Invoice invoice = new Invoice(); invoice.InvoiceId = InvoiceId; DataSet ds = new InvoiceDAO().GetInvoiceDetailsByInvoiceIDForReporting(invoice); (sender as ASPxGridView).DataSource = ds; } catch (Exception ex) { ex.Data.Add("UILayerException", this.GetType().ToString() + Constant.Error_Seperator + "protected void dxgvInvoiceLineItems_BeforePerformDataSelect(object sender, EventArgs e)"); if (Master.LoggedUser != null && Master.LoggedUser.UserName != null && Master.LoggedUser.UserName != string.Empty) { Response.Redirect("Error.aspx?LogId=" + LankaTilesExceptions.WriteEventLogs(ex, Constant.Database_Connection_Name, Master.LoggedUser.UserName), false); } else { Response.Redirect("Error.aspx?LogId=" + LankaTilesExceptions.WriteEventLogs(ex, Constant.Database_Connection_Name, "Annonimous"), false); } } }
public ChargeAccountUI() { this.ChargeAccountDAO = new ChargeAccountDAO(); this.InvoiceDAO = new InvoiceDAO(); InitializeComponent(); PopulateDropDown(); }
public HomeController() { //constructor for connection strings string connectionString = ConfigurationManager.ConnectionStrings["datasource"].ConnectionString; _invoiceDataAccess = new InvoiceDAO(connectionString); _boatDataAccess = new BoatDAO(connectionString); }
// // GET: /Invoice/ public ActionResult Index(string type) { List <InvoiceModel> list = InvoiceDAO.GetInvoiceList(type); ViewBag.Type = type; return(View(list)); }
public ActionResult Print(int id) { InvoiceModel invoiceModel = InvoiceDAO.GetInvoice(id); ViewBag.Type = invoiceModel.Type; return(View(invoiceModel)); }
protected void Page_Load(object sender, EventArgs e) { InvoiceDAO invAccess = new InvoiceDAO(); DataSet dsInvoice = new DataSet(); dsInvoice = invAccess.GetAllInvoicesAndDetailsForReporting(); pgSalesSummary.DataSource = dsInvoice; pgSalesSummary.DataBind(); }
protected void OnextendDropDown_SelectedIndexChanged(object sender, EventArgs e) { string id = string.Format("Id: {0} Uri: {1}", Guid.NewGuid(), HttpContext.Current.Request.Url); using (Utils utility = new Utils()) { utility.MethodStart(id, System.Reflection.MethodBase.GetCurrentMethod()); } try { double TotalAmount = 0.00; Label lblPrice, lblTotalAmount; TextBox txtQuantity; GridViewRow row = (GridViewRow)grdInvoice.HeaderRow; lblPrice = (Label)row.FindControl("lblPrice"); lblTotalAmount = (Label)row.FindControl("lblTotalAmount"); txtQuantity = (TextBox)row.FindControl("txtQuantity"); ext = (ExtendedDropDownList.ExtendedDropDownList)row.FindControl("extddlItem"); _InvoiceDAO = new InvoiceDAO(); DataSet ds = new DataSet(); ds = _InvoiceDAO.getInvoiceItemPrice(ext.Text, txtCompanyId.Text); txtSelectedItemIndex.Text = ext.Text; if (ds.Tables[0].Rows.Count > 0) { lblPrice.Text = ds.Tables[0].Rows[0][0].ToString(); } else { lblPrice.Text = "0.00"; } if (txtQuantity.Text != "") { TotalAmount = Convert.ToDouble(lblPrice.Text) * Convert.ToDouble(txtQuantity.Text); lblTotalAmount.Text = TotalAmount.ToString(); Session["TotalAmount"] = lblTotalAmount.Text; } } catch (Exception ex) { Elmah.ErrorSignal.FromCurrentContext().Raise(ex); using (Utils utility = new Utils()) { utility.MethodEnd(id, System.Reflection.MethodBase.GetCurrentMethod()); } string str2 = "Error Request=" + id + ".Please share with Technical support."; base.Response.Redirect("../Bill_Sys_ErrorPage.aspx?ErrMsg=" + str2); } //Method End using (Utils utility = new Utils()) { utility.MethodEnd(id, System.Reflection.MethodBase.GetCurrentMethod()); } }
public void LoadHoaDon() { try { InvoiceDAO dt = new InvoiceDAO(); grKhoanchi.DataSource = dt.ListInvoice((int)cbbNamhoc.SelectedValue, (int)cbbHocky.SelectedValue); } catch { } }
public ActionResult Load() { try { using (var invoiceDAO = new InvoiceDAO()) return(StatusCode(200, invoiceDAO.Load())); } catch (Exception ex) { return(StatusCode(500, new { Message = "Falha ao carregar faturas" })); } }
public ActionResult Get(int id) { try { using (var invoiceDAO = new InvoiceDAO()) return(StatusCode(200, invoiceDAO.Get(id))); } catch (Exception ex) { return(StatusCode(500, new { Message = "Falha ao obter fatura" })); } }
public ActionResult Edit(InvoiceModel invoiceModel) { try { InvoiceDAO.UpdateInvoice(invoiceModel); return(RedirectToAction("Index", new { type = invoiceModel.Type })); } catch { return(View()); } }
private void btnLuu_Click(object sender, EventArgs e) { if (grChiTietKhoanChi.RowCount != 0) { try { InvoiceDAO dt = new InvoiceDAO(); InvoiceDetailDAO dc = new InvoiceDetailDAO(); Invoice a = new Invoice(); a.CourseID = (int)cbbNamhoc.SelectedValue; a.SemesterID = (int)cbbHocky.SelectedValue; a.CreatedDate = DateTime.Now; a.EmployeeID = LoginDetail.LoginID; a.NameMoneyReceive = txtHoten.Text; a.PhoneNumber = txtSDT.Text; a.AdressDetail = txtDiachi.Text; a.TotalPrice = decimal.Parse(txtTongchi.Text); a.SpendSpeciesID = (int)cbbLoaichi.SelectedValue; a.Note = txtGhichu.Text; System.Guid a1 = dt.Insert(a); if (a1 != null) { for (int i = 0; i < grChiTietKhoanChi.RowCount; i++) { InvoiceDetail b = new InvoiceDetail(); b.InvoiceID = a1; b.NameInvoiceDetail = grChiTietKhoanChi.GetRowCellValue(i, grChiTietKhoanChi.Columns["NameInvoiceDetail"]).ToString(); b.Price = (decimal)grChiTietKhoanChi.GetRowCellValue(i, grChiTietKhoanChi.Columns["Price"]); b.Unit = grChiTietKhoanChi.GetRowCellValue(i, grChiTietKhoanChi.Columns["Unit"]).ToString(); b.Amount = (int)grChiTietKhoanChi.GetRowCellValue(i, grChiTietKhoanChi.Columns["Amount"]); b.TotalPriceDetail = (decimal)grChiTietKhoanChi.GetRowCellValue(i, grChiTietKhoanChi.Columns["TotalPriceDetail"]); b.Note = grChiTietKhoanChi.GetRowCellValue(i, grChiTietKhoanChi.Columns["Note"]).ToString(); b.Status = false; if (dc.Insert(b) == true) { } else { MessageBox.Show("Bản ghi " + i + " bị lỗi"); break; } } MessageBox.Show("Lưu thành công"); this.Close(); } } catch { } } }
protected string GeneratePDF(string strHtml, string P_Company_Id, string P_Case_Id, string P_User_Name, string P_Case_No, string P_Invoice_ID) { GeneratePatientInfoPDF objPDF = new GeneratePatientInfoPDF(); Bill_Sys_NF3_Template objNF3Template = new Bill_Sys_NF3_Template(); string pdffilename = ""; try { SautinSoft.PdfMetamorphosis objHTMToPDF = new SautinSoft.PdfMetamorphosis(); _InvoiceDAO = new InvoiceDAO(); objHTMToPDF.Serial = "10007706603"; string htmfilename = getFileName("I") + ".htm"; string FullPath = ""; pdffilename = getFileName("P") + ".pdf"; StreamWriter sw = new StreamWriter(ApplicationSettings.GetParameterValue("EXCEL_SHEET") + htmfilename); sw.Write(strHtml); sw.Close(); Int32 iTemp; iTemp = objHTMToPDF.HtmlToPdfConvertFile(ApplicationSettings.GetParameterValue("EXCEL_SHEET") + htmfilename, ApplicationSettings.GetParameterValue("EXCEL_SHEET") + pdffilename); String szDestinationDir = Company_Name + "/" + Case_Id + "/No Fault File/Invoice/"; FullPath = objNF3Template.getPhysicalPath().ToString() + szDestinationDir.ToString() + pdffilename.ToString(); string FilePath = szDestinationDir.ToString(); string Path = szDestinationDir.ToString() + pdffilename.ToString(); if (File.Exists(ApplicationSettings.GetParameterValue("EXCEL_SHEET") + pdffilename)) { if (!Directory.Exists(objNF3Template.getPhysicalPath() + szDestinationDir)) { Directory.CreateDirectory(objNF3Template.getPhysicalPath() + szDestinationDir); } File.Copy(ApplicationSettings.GetParameterValue("EXCEL_SHEET") + pdffilename, objNF3Template.getPhysicalPath() + szDestinationDir + pdffilename); } ArrayList objAL1 = new ArrayList(); objAL1.Add(P_Company_Id); objAL1.Add(P_Case_Id); objAL1.Add(pdffilename); // SZ_BILL_NAME objAL1.Add(FilePath); // SZ_BILL_FILE_PATH objAL1.Add(P_User_Name); objAL1.Add("NF"); objAL1.Add(P_Case_No); objAL1.Add(Path); objAL1.Add(P_Invoice_ID); _InvoiceDAO.saveGeneratedInvoicePath(objAL1); } catch (Exception ex) { Elmah.ErrorSignal.FromCurrentContext().Raise(ex); } return(pdffilename); }
public ActionResult Checkout(INVOICE invoice) { var sessionCart = (CartModel)Session[Common.CommonConstants.CART_SESSION]; var sessionUser = Session[Common.CommonConstants.USER_SESSION]; invoice.Created_Time = DateTime.Now; invoice.Status = 0; invoice.Total = sessionCart.Total * (100 - sessionCart.DiscountAmount) / 100; if (sessionCart.DiscountCode != null) { invoice.Id_Discount_Code = new DiscountCodeDAO().GetDiscountCodeByCode(sessionCart.DiscountCode).Id; } if (sessionUser != null) { var user = (USER)sessionUser; invoice.Id_User = user.Id; } if (ModelState.IsValid) { var invoiceId = new InvoiceDAO().Insert(invoice); if (invoiceId > 0) { var detailDAO = new InvoiceDetailDAO(); foreach (var item in sessionCart.ListCartItem) { var invoiceDetail = new INVOICE_DETAIL { Id_Invoice = invoiceId, Id_Product = item.Product.Id, Quantity = item.Quantity }; detailDAO.Insert(invoiceDetail); } Session[Common.CommonConstants.CART_SESSION] = null; return(Json(new { result = true })); } } return(PartialView("CheckoutForm", invoice)); }
public ActionResult Edit(int id, string type) { ViewBag.Type = type; var invoiceModel = InvoiceDAO.GetInvoice(id); var clientList = ClientDAO.GetClientList().Select(client => new SelectListItem { Text = client.Name, Value = client.ID.ToString() }).ToList(); return(View(new InvoiceViewModel { InvoiceModel = invoiceModel, Clients = clientList, PriceTypes = GetPriceTypes() })); }
public ActionResult Remove(int id) { try { using (var invoiceDAO = new InvoiceDAO()) if (invoiceDAO.Remove(id)) { return(StatusCode(200, new { Message = "Removido" })); } return(StatusCode(304, new { Message = "Não Removido" })); } catch (Exception ex) { return(StatusCode(500, new { Message = "Falha ao remover" })); } }
public bool SaveInvoice(List <Invoice> saveData) { using (DbContextTransaction transaction = Context.Database.BeginTransaction()) { try { long seq = InvoiceDAO.GetInvoiceSEQ(); foreach (Invoice data in saveData) { switch (data.Status) { // Add new case ModifyMode.Insert: seq++; data.InvoiceID = GenerateID.InvoiceID(seq); this.InvoiceDAO.InsertInvoice(data); break; // Update case ModifyMode.Update: this.InvoiceDAO.UpdateInvoice(data); break; // Delete case ModifyMode.Delete: this.InvoiceDAO.DeleteInvoice(data.InvoiceID, data.CompanyID); break; } } transaction.Commit(); return(true); } catch (Exception ex) { transaction.Rollback(); BSLog.Logger.Error(ex.Message); return(false); } } }
protected void Page_Load(object sender, EventArgs e) { try { if (!IsPostBack) { Master.ClearSessions();//Clear all sessions DataSet dsSelectAllInv = new InvoiceDAO().GetInvoiceByRole(Master.LoggedUser.UserRoleID); dxgvInvoice.DataSource = dsSelectAllInv; dxgvInvoice.DataBind(); Session["SearchInvoice"] = dsSelectAllInv; } if (IsCallback) { if (Session["SearchInvoice"] != null) { dxgvInvoice.DataSource = (DataSet)Session["SearchInvoice"]; dxgvInvoice.DataBind(); } else { dxgvInvoice.DataSource = new InvoiceDAO().GetAllInvoices(); dxgvInvoice.DataBind(); } } } catch (Exception ex) { ex.Data.Add("UILayerException", this.GetType().ToString() + Constant.Error_Seperator + "protected void Page_Load(object sender, EventArgs e)"); if (Master.LoggedUser != null && Master.LoggedUser.UserName != null && Master.LoggedUser.UserName != string.Empty) { Response.Redirect("Error.aspx?LogId=" + LankaTilesExceptions.WriteEventLogs(ex, Constant.Database_Connection_Name, Master.LoggedUser.UserName), false); } else { Response.Redirect("Error.aspx?LogId=" + LankaTilesExceptions.WriteEventLogs(ex, Constant.Database_Connection_Name, "Annonimous"), false); } } }
// // GET: /Invoice/Create public ActionResult Create(string type) { ViewBag.Type = type; var invoiceModel = new InvoiceModel { Number = InvoiceDAO.GetNextInvoiceNumber(type), Date = DateTime.Now, Type = type }; var clientList = ClientDAO.GetClientList().Select(client => new SelectListItem { Text = client.Name, Value = client.ID.ToString() }).ToList(); return(View(new InvoiceViewModel { InvoiceModel = invoiceModel, Clients = clientList, PriceTypes = GetPriceTypes() })); }
private void FillSession() { try { InvoiceSearch search = new InvoiceSearch(); search.FromDateRep = dtpFromDate.Date; search.ToDateRep = dtpToDate.Date; if ((int)rblReportOption.SelectedItem.Value == 0) { Session["InvoiceReport"] = new InvoiceDAO().GetAllInvoicesAndDetailsForReporting(search); } else if ((int)rblReportOption.SelectedItem.Value == 1) { //load all active only Session["InvoiceReport"] = new InvoiceDAO().GetAllActiveInvoicesForReporting(search); } else if ((int)rblReportOption.SelectedItem.Value == 2) { //load all cancelled only Session["InvoiceReport"] = new InvoiceDAO().GetAllCancelledInvoicesForReporting(search); } else if ((int)rblReportOption.SelectedItem.Value == 3) { //load all pending payments only Session["InvoiceReport"] = new InvoiceDAO().GetAllPaymentDueInvoicesForReporting(search); } this.FilterDataByUserRole(); } catch (Exception ex) { throw ex; } }
public InvoiceController() { this.Context = new BSContext(); this.InvoiceDAO = new InvoiceDAO(this.Context); this.InvoiceLogic = new InvoiceLogic(this.Context); }
protected void ItemName_SelectedIndexChanged(object sender, EventArgs e) { string id = string.Format("Id: {0} Uri: {1}", Guid.NewGuid(), HttpContext.Current.Request.Url); using (Utils utility = new Utils()) { utility.MethodStart(id, System.Reflection.MethodBase.GetCurrentMethod()); } try { DataTable dtTable = (DataTable)ViewState["Table"]; int index = Convert.ToInt32(Session["RowIndex"].ToString()); Label lblPrice; lblPrice = (Label)grdInvoice.Rows[index].FindControl("txtPriceValue"); ext1 = (ExtendedDropDownList.ExtendedDropDownList)grdInvoice.Rows[index].FindControl("ItemName"); TextBox txtQuantity1 = (TextBox)grdInvoice.Rows[index].FindControl("txtQuantityValue"); Label txtAmount = (Label)grdInvoice.Rows[index].FindControl("txtAmount"); _InvoiceDAO = new InvoiceDAO(); DataSet ds = new DataSet(); string flag = "false"; if (ext1.Text != "NA") { int p = Convert.ToInt32(ext1.Text); for (int i = 0; i < dtTable.Rows.Count; i++) { if (i != index) { if (dtTable.Rows[i][5].ToString().Equals(ext1.Text)) { flag = "true"; } } } if (flag == "false") { if (ext1.Selected_Text.ToString().Equals("---Select---")) { ScriptManager.RegisterClientScriptBlock(this, GetType(), "mm", "ValidateItem();", true); } else if (txtQuantity1.Text == "") { ScriptManager.RegisterClientScriptBlock(this, GetType(), "mm", "ValidateQuantity();", true); } else { ds = _InvoiceDAO.getInvoiceItemPrice(ext1.Text, txtCompanyId.Text); txtSelectedItemIndex.Text = ext1.Text; if (ds.Tables[0].Rows.Count > 0) { lblPrice.Text = ds.Tables[0].Rows[0][0].ToString(); } else { lblPrice.Text = "0.00"; } double Total = Convert.ToDouble(lblPrice.Text) * Convert.ToDouble(txtQuantity1.Text); txtAmount.Text = Total.ToString(); //Bind Latest Data In ViewState DataTable _datatable = new DataTable(); DataRow dr = null; _datatable.Columns.Add(new DataColumn("RowNumber", typeof(string))); _datatable.Columns.Add(new DataColumn("ItemName", typeof(string))); _datatable.Columns.Add(new DataColumn("Quantity", typeof(string))); _datatable.Columns.Add(new DataColumn("Price", typeof(float))); _datatable.Columns.Add(new DataColumn("TotalAmount", typeof(float))); _datatable.Columns.Add(new DataColumn("ItemId", typeof(string))); _datatable.Columns.Add(new DataColumn("Invoice_Detail_Id", typeof(string))); for (int i = 0; i < grdInvoice.Rows.Count; i++) { ext1 = (ExtendedDropDownList.ExtendedDropDownList)grdInvoice.Rows[i].FindControl("ItemName"); TextBox txtQuantityVal1 = (TextBox)grdInvoice.Rows[i].Cells[2].FindControl("txtQuantityValue"); Label txtPrice1 = (Label)grdInvoice.Rows[i].Cells[3].FindControl("txtPriceValue"); Label txtAmount1 = (Label)grdInvoice.Rows[i].Cells[4].FindControl("txtAmount"); dr = _datatable.NewRow(); dr["RowNumber"] = i; dr["ItemName"] = ext1.Selected_Text; dr["Quantity"] = txtQuantityVal1.Text; dr["Price"] = txtPrice1.Text; dr["TotalAmount"] = txtAmount1.Text; dr["ItemId"] = ext1.Text; dr["Invoice_Detail_Id"] = grdInvoice.DataKeys[i][1].ToString(); _datatable.Rows.Add(dr); } ViewState["Table"] = _datatable; //End Of Code } } else { ScriptManager.RegisterClientScriptBlock(this, GetType(), "mm", "DuplicateItemValidation();", true); ext1.Text = Session["ItemIndex"].ToString(); } } else { ScriptManager.RegisterClientScriptBlock(this, GetType(), "mm", "NoItemSelectedValidation();", true); ext1.Text = Session["ItemIndex"].ToString(); } } catch (Exception ex) { Elmah.ErrorSignal.FromCurrentContext().Raise(ex); using (Utils utility = new Utils()) { utility.MethodEnd(id, System.Reflection.MethodBase.GetCurrentMethod()); } string str2 = "Error Request=" + id + ".Please share with Technical support."; base.Response.Redirect("../Bill_Sys_ErrorPage.aspx?ErrMsg=" + str2); } //Method End using (Utils utility = new Utils()) { utility.MethodEnd(id, System.Reflection.MethodBase.GetCurrentMethod()); } }
protected void btnSave_Click(object sender, EventArgs e) { string id = string.Format("Id: {0} Uri: {1}", Guid.NewGuid(), HttpContext.Current.Request.Url); using (Utils utility = new Utils()) { utility.MethodStart(id, System.Reflection.MethodBase.GetCurrentMethod()); } try { int flag = 0; ext1 = (ExtendedDropDownList.ExtendedDropDownList)grdInvoice.Rows[0].FindControl("ItemName"); for (int i = 0; i < grdInvoice.Rows.Count; i++) { LinkButton lnkEdit1 = (LinkButton)grdInvoice.Rows[i].Cells[0].FindControl("lnkEdit"); if (lnkEdit1.Text == "Update") { flag = 1; } } if (flag == 1) { ScriptManager.RegisterClientScriptBlock(this, GetType(), "mm", "UpdateValidation();", true); } else if (extddlOffice.Selected_Text == "--- Select ---") { ScriptManager.RegisterClientScriptBlock(this, GetType(), "mm", "ProviderValidate();", true); } else if (txtServiceDate.Text == "") { ScriptManager.RegisterClientScriptBlock(this, GetType(), "mm", "DateValidate();", true); } else if (txtShipping.Text == "") { ScriptManager.RegisterClientScriptBlock(this, GetType(), "mm", "ShippingAmountValidate();", true); } else if (txtPersonName.Text == "") { ScriptManager.RegisterClientScriptBlock(this, GetType(), "mm", "PersonName();", true); } else if (txtPersonAddress.Text == "") { ScriptManager.RegisterClientScriptBlock(this, GetType(), "mm", "EmptyAddress();", true); } else if (txtCity.Text == "") { ScriptManager.RegisterClientScriptBlock(this, GetType(), "mm", "EmptyCity();", true); } else if (extddlPatientState.Selected_Text == "--- Select ---") { ScriptManager.RegisterClientScriptBlock(this, GetType(), "mm", "EmptyState();", true); } else if (txtZip.Text == "") { ScriptManager.RegisterClientScriptBlock(this, GetType(), "mm", "EmptyZip();", true); } else if (grdInvoice.Rows.Count <= 1 && ext1.Selected_Text == "---Select---") { ScriptManager.RegisterClientScriptBlock(this, GetType(), "mm", "EmptyGridValidate();", true); } else { _InvoiceDAO = new InvoiceDAO(); DataTable dt = new DataTable(); ArrayList objArr = new ArrayList(); dt = (DataTable)ViewState["Table"]; for (int i = 0; i < dt.Rows.Count; i++) { _InvoiceGetSet = new InvoiceGetSet(); _InvoiceGetSet.ItemID = dt.Rows[i][5].ToString(); _InvoiceGetSet.Quantity = dt.Rows[i][2].ToString(); _InvoiceGetSet.UnitePrice = dt.Rows[i][3].ToString(); _InvoiceGetSet.Amount = dt.Rows[i][4].ToString(); _InvoiceGetSet.InvoiceItemId = dt.Rows[i]["Invoice_Detail_Id"].ToString(); objArr.Add(_InvoiceGetSet); } arrStartValues = (ArrayList)ViewState["ArrayList"]; if (btnSave.Text == "Save") { _InvoiceDAO.SaveInvoice(((Bill_Sys_CaseObject)Session["CASE_OBJECT"]).SZ_CASE_ID, txtCompanyId.Text, txtServiceDate.Text, Convert.ToDouble(lblTAmount.Text.Substring(1)), lblTodaysDate.Text, ((Bill_Sys_UserObject)Session["USER_OBJECT"]).SZ_USER_ID, Convert.ToDouble(txtShipping.Text), ((Bill_Sys_BillingCompanyObject)Session["BILLING_COMPANY_OBJECT"]).SZ_COMPANY_NAME, "SAVE", txtInvoiceId.Text, ((Bill_Sys_UserObject)Session["USER_OBJECT"]).SZ_USER_NAME, lblCaseNo.Text, extddlOffice.Text, objArr, arrStartValues, txtPersonName.Text, txtPersonAddress.Text, txtZip.Text, extddlPatientState.Text, txtCity.Text, ((Bill_Sys_UserObject)Session["USER_OBJECT"]).SZ_USER_NAME); ClearFields(); } else if (btnSave.Text == "Update") { _InvoiceDAO.SaveInvoice(((Bill_Sys_CaseObject)Session["CASE_OBJECT"]).SZ_CASE_ID, txtCompanyId.Text, txtServiceDate.Text, Convert.ToDouble(lblTAmount.Text.Substring(1)), lblTodaysDate.Text, ((Bill_Sys_UserObject)Session["USER_OBJECT"]).SZ_USER_ID, Convert.ToDouble(txtShipping.Text), ((Bill_Sys_BillingCompanyObject)Session["BILLING_COMPANY_OBJECT"]).SZ_COMPANY_NAME, "UPDATE", txtInvoiceId.Text, ((Bill_Sys_UserObject)Session["USER_OBJECT"]).SZ_USER_NAME, lblCaseNo.Text, extddlOffice.Text, objArr, arrStartValues, txtPersonName.Text, txtPersonAddress.Text, txtZip.Text, extddlPatientState.Text, txtCity.Text, ((Bill_Sys_UserObject)Session["USER_OBJECT"]).SZ_USER_NAME); } usrMessage.PutMessage("Invoice Items Saved Successfully"); usrMessage.SetMessageType(UserControl_ErrorMessageControl.DisplayType.Type_UserMessage); usrMessage.Show(); } } catch (Exception ex) { Elmah.ErrorSignal.FromCurrentContext().Raise(ex); using (Utils utility = new Utils()) { utility.MethodEnd(id, System.Reflection.MethodBase.GetCurrentMethod()); } string str2 = "Error Request=" + id + ".Please share with Technical support."; base.Response.Redirect("../Bill_Sys_ErrorPage.aspx?ErrMsg=" + str2); } //Method End using (Utils utility = new Utils()) { utility.MethodEnd(id, System.Reflection.MethodBase.GetCurrentMethod()); } }
protected void Page_Load(object sender, EventArgs e) { string id = string.Format("Id: {0} Uri: {1}", Guid.NewGuid(), HttpContext.Current.Request.Url); using (Utils utility = new Utils()) { utility.MethodStart(id, System.Reflection.MethodBase.GetCurrentMethod()); } try { txtCompanyId.Text = ((Bill_Sys_BillingCompanyObject)Session["BILLING_COMPANY_OBJECT"]).SZ_COMPANY_ID; lblTodaysDate.Text = DateTime.Today.ToString("MM/dd/yyyy"); extddlOffice.Flag_ID = txtCompanyId.Text; if (Page.IsPostBack == false) { Session["TotalAmount"] = ""; if (Request.QueryString["InvoiceId"] != "" && Request.QueryString["InvoiceId"] != null) { _InvoiceDAO = new InvoiceDAO(); txtInvoiceId.Text = Request.QueryString["InvoiceId"]; dtFillGrid = new DataTable(); dtFillGrid = _InvoiceDAO.getInvoiceDetails(txtInvoiceId.Text, txtCompanyId.Text, "", "GET_INVOICE_DETAILS"); grdInvoice.DataSource = dtFillGrid; grdInvoice.DataBind(); lblTAmount.Text = dtFillGrid.Rows[0][10].ToString(); lblFinalTotalAmount.Text = dtFillGrid.Rows[0][11].ToString(); extddlOffice.Text = dtFillGrid.Rows[0][12].ToString(); txtShipping.Text = dtFillGrid.Rows[0][6].ToString(); txtServiceDate.Text = dtFillGrid.Rows[0][7].ToString(); txtPersonName.Text = dtFillGrid.Rows[0][13].ToString(); txtPersonAddress.Text = dtFillGrid.Rows[0][14].ToString(); txtCity.Text = dtFillGrid.Rows[0][15].ToString(); extddlPatientState.Text = dtFillGrid.Rows[0][16].ToString(); txtZip.Text = dtFillGrid.Rows[0][17].ToString(); GridViewRow row = (GridViewRow)grdInvoice.HeaderRow; ext = (ExtendedDropDownList.ExtendedDropDownList)row.FindControl("extddlItem"); ext.Flag_ID = ((Bill_Sys_BillingCompanyObject)Session["BILLING_COMPANY_OBJECT"]).SZ_COMPANY_ID; for (int i = 0; i < dtFillGrid.Rows.Count; i++) { ext1 = (ExtendedDropDownList.ExtendedDropDownList)grdInvoice.Rows[i].FindControl("ItemName"); ext1.Flag_ID = ((Bill_Sys_BillingCompanyObject)Session["BILLING_COMPANY_OBJECT"]).SZ_COMPANY_ID; ext1.Text = dtFillGrid.Rows[i][5].ToString(); ext1.Enabled = false; arrStartValues.Add(dtFillGrid.Rows[i][9].ToString()); } ViewState["ArrayList"] = (ArrayList)arrStartValues; ViewState["Table"] = dtFillGrid; btnSave.Text = "Update"; dtFillGrid = _InvoiceDAO.getInvoiceDetails(txtInvoiceId.Text, txtCompanyId.Text, Request.QueryString["CaseId"].ToString(), "GET_PATIENT_INFO"); lblCaseNo.Text = dtFillGrid.Rows[0][1].ToString(); lblPatientName.Text = dtFillGrid.Rows[0][0].ToString(); CalculateTotalAmount(); } else { FillGrid(); lblCaseNo.Text = ((Bill_Sys_CaseObject)Session["CASE_OBJECT"]).SZ_CASE_NO; lblPatientName.Text = ((Bill_Sys_CaseObject)Session["CASE_OBJECT"]).SZ_PATIENT_NAME; } //BindgrdLitigationdesk(); } #region "check version readonly or not" string app_status = ((Bill_Sys_BillingCompanyObject)Session["APPSTATUS"]).SZ_READ_ONLY.ToString(); if (app_status.Equals("True")) { Bill_Sys_ChangeVersion cv = new Bill_Sys_ChangeVersion(this.Page); cv.MakeReadOnlyPage("Bill_Sys_Invoice.aspx"); } #endregion } catch (Exception ex) { Elmah.ErrorSignal.FromCurrentContext().Raise(ex); using (Utils utility = new Utils()) { utility.MethodEnd(id, System.Reflection.MethodBase.GetCurrentMethod()); } string str2 = "Error Request=" + id + ".Please share with Technical support."; base.Response.Redirect("../Bill_Sys_ErrorPage.aspx?ErrMsg=" + str2); } //Method End using (Utils utility = new Utils()) { utility.MethodEnd(id, System.Reflection.MethodBase.GetCurrentMethod()); } }
public bool SaveInvoice(List <Invoice> saveData, List <InvoiceS35> DataS35) { using (DbContextTransaction transaction = Context.Database.BeginTransaction()) { try { long seq = InvoiceDAO.GetInvoiceSEQ(); foreach (Invoice data in saveData) { switch (data.Status) { // Add new case ModifyMode.Insert: seq++; data.InvoiceID = GenerateID.InvoiceID(seq); Boolean resultInsert = false; resultInsert = this.InvoiceDAO.InsertInvoice(data); if (resultInsert) { //Nếu tồn tại S35ID thì update liên kết cho S35 if (data.InvoiceS35ID != null) { List <InvoiceS35> invoiceS35 = new List <InvoiceS35>(); invoiceS35 = DataS35.Where(o => o.InvoiceS35ID == data.InvoiceS35ID).ToList(); if (invoiceS35.Count > 0) { invoiceS35[0].StatusLienKet = true; this.InvoiceS35DAO.UpdateInvoiceS35(invoiceS35[0]); } } } else { transaction.Rollback(); BSLog.Logger.Error("InvoiceLogic 107 InserInvoice Fail!"); return(false); } break; // Update case ModifyMode.Update: this.InvoiceDAO.UpdateInvoice(data); break; // Delete case ModifyMode.Delete: this.InvoiceDAO.DeleteInvoice(data.InvoiceID, data.CompanyID); break; } } transaction.Commit(); return(true); } catch (Exception ex) { transaction.Rollback(); BSLog.Logger.Error(ex.Message); return(false); } } }
public ActionResult GenerateInvoice(int companyId, [FromBody] DateTime begin) { try { Company company; Rules rules; using (var companyDAO = new CompanyDAO()) company = companyDAO.Get(companyId); if (company == null) { return(StatusCode(404, new { Message = "Empresa não encontrada" })); } using (var providerDAO = new RulesDAO()) rules = providerDAO.Get(); if (rules == null) { return(StatusCode(404, new { Message = "Não há regras base para o cálculo da fatura" })); } using (var invoiceDAO = new InvoiceDAO()) { var invoice = new Invoice() { GenerationDate = DateTime.Now, CompanyDebtor = company.Id, TaxConsidered = rules.Tax, IntervalMinutesConsidered = rules.IntervalMinutes }; invoice.Id = invoiceDAO.Add(invoice); if (invoice.Id != 0) { using (var flowRecordDAO = new FlowRecordDAO()) { List <FlowRecord> records; decimal total = 0; flowRecordDAO.MarkCharge(invoice.Id, company.Id, begin, begin.AddDays(company.InvoiceInterval)); records = invoiceDAO.GetInvoiceRecords(invoice.Id); Parallel.ForEach(records, (record) => { // Calcula o valor para o período de permanência desse Ônibus com base no intervalo de cobrança e o valor da tarifa var permanence = record.Departure - record.Arrival; total += rules.Tax * Convert.ToDecimal(Math.Floor(permanence.Value.TotalMinutes / rules.IntervalMinutes)); // Caso tenha permanecido menos que o intervalo de cobrança, é cobrado a taxa mínima if (total <= 0) { total += rules.Tax; } }); if (records.Count <= 0 && invoiceDAO.Cancel(invoice.Id)) { return(StatusCode(304, new { Message = "Não há registros não faturados para este período" })); } if (invoiceDAO.SetInvoiceValue(invoice.Id, total)) { invoice = invoiceDAO.Get(invoice.Id); return(StatusCode(200, invoice)); } } } return(StatusCode(304, new { Message = "A fatura não foi gerada" })); } } catch (Exception ex) { return(StatusCode(500, new { Message = "Erro interno ao gerar fatura" })); } }
protected void grdInvoiceReport_RowCommand(object sender, GridViewCommandEventArgs e) { string id = string.Format("Id: {0} Uri: {1}", Guid.NewGuid(), HttpContext.Current.Request.Url); using (Utils utility = new Utils()) { utility.MethodStart(id, System.Reflection.MethodBase.GetCurrentMethod()); } try { if (e.CommandName == "InvoiceId") { int index = Convert.ToInt32(e.CommandArgument); LinkButton lnkInvoiceId = new LinkButton(); lnkInvoiceId = (LinkButton)grdInvoiceReport.Rows[index].FindControl("lnkSelectCase"); string InvoiceId = lnkInvoiceId.Text; string Case_Id = grdInvoiceReport.DataKeys[index][0].ToString(); ScriptManager.RegisterClientScriptBlock(this, GetType(), "mm", "OpenInvoiceWiseItem(" + InvoiceId + "," + Case_Id + ");", true); } if (e.CommandName == "Generate Invoice") { #region "Logic to view bills" string InvoiceId = e.CommandArgument.ToString(); _InvoiceDAO = new InvoiceDAO(); string PDF_Path; PDF_Path = _InvoiceDAO.GetPDFPath(InvoiceId, txtCompanyId.Text); if (PDF_Path.ToString() != "") { //PDF_Path = ConfigurationSettings.AppSettings["DocumentManagerURL"].ToString() + PDF_Path; ScriptManager.RegisterStartupScript(this, this.GetType(), "starScript", "window.open('" + PDF_Path + "');", true); } else { ScriptManager.RegisterStartupScript(this, this.GetType(), "starScript", "alert('No Invoice Generated ...!');", true); } #endregion } if (e.CommandName == "Make Payment") { string InvoiceId = e.CommandArgument.ToString(); lblPosteddate.Text = DateTime.Today.ToShortDateString(); txtPaymentDate.Text = lblPosteddate.Text; lblInvoiceId.Text = InvoiceId.ToString(); btnUpdate.Enabled = false; btnSave.Enabled = true; txtCompanyID1.Text = ((Bill_Sys_BillingCompanyObject)Session["BILLING_COMPANY_OBJECT"]).SZ_COMPANY_ID; txtCaseID.Text = ((Bill_Sys_CaseObject)Session["CASE_OBJECT"]).SZ_CASE_ID; txtUserID.Text = ((Bill_Sys_UserObject)Session["USER_OBJECT"]).SZ_USER_ID; BindGrid(); ModalPopupExtender1.Show(); } } catch (Exception ex) { Elmah.ErrorSignal.FromCurrentContext().Raise(ex); using (Utils utility = new Utils()) { utility.MethodEnd(id, System.Reflection.MethodBase.GetCurrentMethod()); } string str2 = "Error Request=" + id + ".Please share with Technical support."; base.Response.Redirect("../Bill_Sys_ErrorPage.aspx?ErrMsg=" + str2); } //Method End using (Utils utility = new Utils()) { utility.MethodEnd(id, System.Reflection.MethodBase.GetCurrentMethod()); } }
public InvoiceService(InvoiceDAO dao) { this.dao = dao; }
private void btnSave_Click(object sender, EventArgs e) { if (carDTO == null) { MessageBox.Show("Please choose a model!"); return; } string sQuantity = txtQuantity.Text.Trim(); int Quantity = int.Parse(sQuantity); if (Quantity <= 0) { MessageBox.Show("Quantity must be greater than 0!"); return; } CarDAO carDAO = new CarDAO(); int numberAvailable = carDAO.GetNumberAvailableCarByID(carDTO.ID); if (numberAvailable - Quantity < 0) { MessageBox.Show("Quantity is out of stock!"); return; } string Fullname = txtFullname.Text.Trim(); string Email = txtEmail.Text.Trim(); if (string.IsNullOrEmpty(Fullname) || string.IsNullOrEmpty(Email)) { MessageBox.Show("Please complete customer's info!"); return; } int insertCusResult = -1; if (cusDTO == null) { cusDTO = new CustomerDTO { Fullname = Fullname, Email = Email, Phone = txtPhone.Text }; CustomerDAO cusDAO = new CustomerDAO(); insertCusResult = cusDAO.CreateCustomer(cusDTO); if (insertCusResult == -1) { MessageBox.Show("Insert new customer failed!"); return; } } else { insertCusResult = cusDTO.ID; } InvoiceDAO invoiceDAO = new InvoiceDAO(); int invoiceID = invoiceDAO.CreateNewInvoice(insertCusResult); InvoiceDetailsDAO invoiceDetailsDAO = new InvoiceDetailsDAO(); bool createInvoiceDetails = invoiceDetailsDAO.CreateInvoiceDetails(carDTO, invoiceID, Quantity); if (createInvoiceDetails) { MessageBox.Show("Add new invoice successfully!"); cusDTO = null; } else { MessageBox.Show("Add new invoice failed!"); } this.DialogResult = DialogResult.OK; }
public string SaveInvoice(string P_Case_Id, string P_Company_Id, string P_Date_Of_Service, double P_Total, string P_Created_Date, string P_Created_User_Id, double P_Shipping, string P_Company_Name, string P_Flag, string P_InvoiceId, string P_User_Name, string P_Case_No, string P_ProviderID, ArrayList objArr, ArrayList objArrRecords, string Sz_Person_Name, string SZ_Person_Address, string SZ_Zip, string SZ_State, string SZ_City, string SZ_User_name) { ArrayList objDeletList = new ArrayList(); Company_Name = P_Company_Name; Case_Id = P_Case_Id; InvoiceGetSet _InvoiceGetSet; InvoiceDAO _InvoiceDAO = new InvoiceDAO(); sqlCon = new SqlConnection(strConn); ds = new DataSet(); DataSet ds2 = new DataSet(); DataSet ds1 = new DataSet(); sqlCmd = new SqlCommand(); sqlCmd.CommandTimeout = Convert.ToInt32(ConfigurationManager.AppSettings["CommandTimeOut"].ToString()); string InvoiceId = ""; SqlTransaction transaction; sqlCon.Open(); transaction = sqlCon.BeginTransaction(); try { if (P_Flag == "UPDATE") { for (int j = 0; j < objArrRecords.Count; j++) { string flag = "true"; for (int i = 0; i < objArr.Count; i++) { _InvoiceGetSet = new InvoiceGetSet(); _InvoiceGetSet = (InvoiceGetSet)objArr[i]; if (_InvoiceGetSet.InvoiceItemId == objArrRecords[j].ToString()) { flag = "false"; } } if (flag == "true") { objDeletList.Add(objArrRecords[j].ToString()); } } } sqlCmd.CommandText = "SP_SAVE_TXN_INVOICE"; sqlCmd.CommandType = CommandType.StoredProcedure; sqlCmd.Connection = sqlCon; sqlCmd.Transaction = transaction; #region "Save Invoice in Txn_Invoice" sqlCmd.Parameters.AddWithValue("@SZ_CASE_ID", P_Case_Id); sqlCmd.Parameters.AddWithValue("@SZ_COMPANY_ID", P_Company_Id); sqlCmd.Parameters.AddWithValue("@DT_DATE_OF_SERVICE", P_Date_Of_Service); sqlCmd.Parameters.AddWithValue("@FLT_TOTAL", P_Total); sqlCmd.Parameters.AddWithValue("@FLT_RECIVED", 0.00); sqlCmd.Parameters.AddWithValue("@FLT_PENDING", 0.00); sqlCmd.Parameters.AddWithValue("@DT_UPDATED_DATE", P_Created_Date); sqlCmd.Parameters.AddWithValue("@SZ_UPDATED_USEr_ID", P_Created_User_Id); sqlCmd.Parameters.AddWithValue("@FLT_SHIIPING_HANDELING", P_Shipping); sqlCmd.Parameters.AddWithValue("@SZ_OFFICE_ID", P_ProviderID); sqlCmd.Parameters.AddWithValue("@SZ_INVOICE_ID", P_InvoiceId); sqlCmd.Parameters.AddWithValue("@SZ_PERSON_NAME", Sz_Person_Name); sqlCmd.Parameters.AddWithValue("@SZ_PERSON_ADDRESS", SZ_Person_Address); sqlCmd.Parameters.AddWithValue("@SZ_PERSON_CITY", SZ_City); sqlCmd.Parameters.AddWithValue("@SZ_PERSON_STATE", Convert.ToInt32(SZ_State)); sqlCmd.Parameters.AddWithValue("@SZ_PERSON_ZIP", SZ_Zip); sqlCmd.Parameters.AddWithValue("@FLAG", P_Flag); sqlCmd.Parameters.AddWithValue("@I_INVOICE_ID", SqlDbType.NVarChar); sqlCmd.Parameters["@I_INVOICE_ID"].Direction = ParameterDirection.ReturnValue; sqlCmd.ExecuteNonQuery(); InvoiceId = sqlCmd.Parameters["@I_INVOICE_ID"].Value.ToString(); #endregion #region "Delete Particular Item From TXN_INVOICE_DETAILS" if (objDeletList.Count > 0) { for (int i = 0; i < objDeletList.Count; i++) { SqlCommand sqlCmd1 = new SqlCommand(); sqlCmd1.CommandTimeout = Convert.ToInt32(ConfigurationManager.AppSettings["CommandTimeOut"].ToString()); sqlCmd1.CommandText = "SP_SAVE_TXN_INVOICE_DETAIL"; sqlCmd1.CommandType = CommandType.StoredProcedure; sqlCmd1.Connection = sqlCon; sqlCmd1.Transaction = transaction; sqlCmd1.Parameters.AddWithValue("@I_INVOICE_DETAIL_ID", objDeletList[i].ToString()); sqlCmd1.Parameters.AddWithValue("@FLAG", "DELETE"); sqlCmd1.ExecuteNonQuery(); } } #endregion #region "Save Invoice Details in TXN_INVOICE_DETAIL" for (int i = 0; i < objArr.Count; i++) { _InvoiceGetSet = new InvoiceGetSet(); _InvoiceGetSet = (InvoiceGetSet)objArr[i]; SqlCommand sqlCmd1 = new SqlCommand(); sqlCmd1.CommandTimeout = Convert.ToInt32(ConfigurationManager.AppSettings["CommandTimeOut"].ToString()); sqlCmd1.CommandText = "SP_SAVE_TXN_INVOICE_DETAIL"; sqlCmd1.CommandType = CommandType.StoredProcedure; sqlCmd1.Connection = sqlCon; sqlCmd1.Transaction = transaction; sqlCmd1.Parameters.AddWithValue("@I_INVOICE_ID", InvoiceId); sqlCmd1.Parameters.AddWithValue("@I_INVOICE_ITEM_ID", _InvoiceGetSet.ItemID); sqlCmd1.Parameters.AddWithValue("@I_QUANTITY", _InvoiceGetSet.Quantity); sqlCmd1.Parameters.AddWithValue("@FLT_UNIT_PRICE", Convert.ToDouble(_InvoiceGetSet.UnitePrice)); sqlCmd1.Parameters.AddWithValue("@FLT_AMOUNT", Convert.ToDouble(_InvoiceGetSet.Amount)); sqlCmd1.Parameters.AddWithValue("@SZ_COMPANY_ID", P_Company_Id); sqlCmd1.Parameters.AddWithValue("@DT_UPDATED_DATE", P_Created_Date); sqlCmd1.Parameters.AddWithValue("@SZ_UPDATED_USEr_ID", P_Created_User_Id); sqlCmd1.Parameters.AddWithValue("@I_INVOICE_DETAIL_ID", _InvoiceGetSet.InvoiceItemId); sqlCmd1.Parameters.AddWithValue("@FLAG", P_Flag); sqlCmd1.ExecuteNonQuery(); } #endregion #region "Update Invoice Amount in Txn_Invoice" SqlCommand sqlCmd2 = new SqlCommand(); sqlCmd2.CommandTimeout = Convert.ToInt32(ConfigurationManager.AppSettings["CommandTimeOut"].ToString()); sqlCmd2.CommandText = "SP_SAVE_TXN_INVOICE"; sqlCmd2.CommandType = CommandType.StoredProcedure; sqlCmd2.Connection = sqlCon; sqlCmd2.Transaction = transaction; sqlCmd2.Parameters.AddWithValue("@SZ_COMPANY_ID", P_Company_Id); sqlCmd2.Parameters.AddWithValue("@SZ_INVOICE_ID", P_InvoiceId); sqlCmd2.Parameters.AddWithValue("@FLAG", "UPDATEAMOUNT"); sqlCmd2.Parameters.AddWithValue("@I_INVOICE_ID", SqlDbType.NVarChar); sqlCmd2.Parameters["@I_INVOICE_ID"].Direction = ParameterDirection.ReturnValue; sqlCmd2.ExecuteNonQuery(); InvoiceId = sqlCmd.Parameters["@I_INVOICE_ID"].Value.ToString(); #endregion #region "save multiple date of service" string[] values = P_Date_Of_Service.Split(','); for (int i = 0; i < values.Length; i++) { if (values[i].ToString().Trim() != "" && values[i].ToString() != "1900-01-01 00:00:00.000") { SqlCommand sqlCmd3 = new SqlCommand(); sqlCmd3.CommandTimeout = Convert.ToInt32(ConfigurationManager.AppSettings["CommandTimeOut"].ToString()); sqlCmd3.CommandText = "SP_SAVE_MUL_DATE_INVOICE"; sqlCmd3.CommandType = CommandType.StoredProcedure; sqlCmd3.Connection = sqlCon; sqlCmd3.Transaction = transaction; sqlCmd3.Parameters.AddWithValue("@SZ_CASE_ID", P_Case_Id); sqlCmd3.Parameters.AddWithValue("@DT_DATEOF_SERVICE", values[i].ToString()); sqlCmd3.Parameters.AddWithValue("@I_INVOICE_ID", InvoiceId); sqlCmd3.Parameters.AddWithValue("@SZ_USER_NAME", SZ_User_name); sqlCmd3.Parameters.AddWithValue("@SZ_COMPANY_ID", P_Company_Id); sqlCmd3.ExecuteNonQuery(); } } #endregion transaction.Commit(); #region "Generate And Save PDF" ds1 = _InvoiceDAO.getCaseWiseCompanyPatientDetails(P_Case_Id, P_ProviderID); ds2 = _InvoiceDAO.getInvoiceWiseItemDetails(InvoiceId); string strhtml = GenerateHTML(ds1, ds2, P_Case_No); GeneratePDF(strhtml, P_Company_Id, P_Case_Id, P_User_Name, P_Case_No, InvoiceId); #endregion } catch (Exception ex) { Elmah.ErrorSignal.FromCurrentContext().Raise(ex); transaction.Rollback(); } finally { transaction.Dispose(); sqlCon.Close(); } return(InvoiceId); }