private void SaveCarInvoice() { CarInvoice item = new CarInvoice(); item.InvoiceID = (hfID.Value != "" ? Convert.ToInt64(hfID.Value) : 0); item.Car_ID = Convert.ToInt64(hfCarID.Value); item.Client_ID = Convert.ToInt64(ddlClients.SelectedValue); item.Currency_ID = Convert.ToInt32(ddlCurrency.SelectedValue); item.SalePrice = Convert.ToDecimal(txtSalePrice.Text); item.FirstAmount = Convert.ToDecimal(txtFirstAmount.Text); item.InvoiceDate = DateTime.Now; item.SiteCompany_ID = 1; // main company information for top invoice. item.Notes = txtShortdesc.Text; item.Store_ID = 1; // Store sale from. item.System_Who_Add = ClientSession.Current.loginId; item.System_LastAction_IP = ClientSession.Current.IP; var result = new SaleInvoicesManager().SaleInvoicesAddEdit(item, txtSecretCode.Text); if (result != null && result.CountSecretCode > 0 && result.CountInvoiceData > 0) // get invoice id. { Response.RedirectPermanent(ResolveClientUrl("invoice/") + result.CountInvoiceData + "/print.aspx"); // success add. } else { lblError.Text = Resources.AdminResources_en.ValidatesecretCode; txtSecretCode.Text = ""; // reset secret code. } }
private void ShowInvoiceDetails(long p) { var result = new SaleInvoicesManager().GetCarSaleInvoiceDetails(p); if (result != null) { divArrivalDate.InnerHtml = MinutesuaeConcrete.GetDateOnly(result.arrive_date, "dd/MM/yyyy"); divCarModel.InnerHtml = string.Format("{0} - {1}", result.MarkerNameEn, result.TypeNameEn); divCarNo.InnerHtml = result.engine_no; divChassisNo.InnerHtml = result.chassis_no; divColor.InnerHtml = result.ExtColorEn; divLotNo.InnerHtml = result.lot_no; divYear.InnerHtml = result.YearNameEn; divClient.InnerHtml = result.ClientName; divDescription.InnerHtml = result.Notes; divEmail.InnerHtml = result.CompEmail; divFax.InnerHtml = result.CompFax; divFirst.InnerHtml = string.Format("{0:F} {1}", result.FirstAmount, result.CurrencySymbol); divLotNo.InnerHtml = result.lot_no; divName.InnerHtml = result.CompName; divPhone.InnerHtml = result.CompPhone; divPrice.InnerHtml = string.Format("{0:F} {1}", result.SalePrice, result.CurrencySymbol); divWebsite.InnerHtml = result.CmopWebsite; divBillStatus.InnerHtml = result.Active == false ? "Canceled" : ""; imgMain.ImageUrl += result.main_picture != null ? result.main_picture : "no_photo.jpg"; // Go to list. string url = "client/" + result.Client_ID + "/invoices/" + MinutesuaeConcrete.ToSeoUrl(result.ClientName) + ".aspx"; lnkGoList.Attributes.Add("href", url); } }
private void FillInvoicesList() { string paramStr = " "; if (rblActive.SelectedIndex > 0) { paramStr += " AND Active = " + rblActive.SelectedValue; } if (txtName.Text.Trim() != String.Empty) { paramStr += " AND InvoiceID = " + txtName.Text; } if (Page.RouteData.Values["clientId"] != null) { long cID = Convert.ToInt64(Page.RouteData.Values["clientId"]); paramStr += string.Format(" AND Client_ID = {0} ", cID); // Assign client links. lnkAddPayment.HRef = string.Format("{0}{1}/addpayments.aspx", "client-", cID); #region "Invoices Payments Statistics" var statistics = new SaleInvoicesManager().GetClientSalesPaymentsShortStatistics(cID); if (statistics != null) { //decimal invoicesVal = (decimal)result.Sum(s => s.SalePrice); //decimal paymVal = (decimal)result.Where(e => e.InOutType == "payment").Sum(ss => ss.ExpenseValue); //var firstBalance = result.FirstOrDefault().OpeningBalance; string usedCurrency = "(AED)"; // ((result.Where(r => r.ExchangeRate == 1).FirstOrDefault() != null) ? (result.Where(r => r.ExchangeRate == 1).FirstOrDefault().CurrencySymbol) : (result.FirstOrDefault().CurrencySymbol)); //decimal openVal = (firstBalance != null ? (decimal)firstBalance : 0); divOpeningbalance.InnerHtml = string.Format("{0:F} {1}", statistics.ClientFirstBalance, usedCurrency); divTotalInvoices.InnerHtml = string.Format("{0:F} {1}", statistics.Invoices, usedCurrency); divTotalPayments.InnerHtml = "<a href='" + Request.Url.AbsolutePath.Replace("invoices", "payments") + "'>" + string.Format("{0:F} {1}", (statistics.Payments + statistics.SubPayments + statistics.InvoicesFirstAmount + statistics.NewBalance), usedCurrency) + "</a>"; //divRemainder.InnerHtml = string.Format("{0:F} {1}", ((statistics.ClientFirstBalance + statistics.Invoices) - (statistics.Payments + statistics.SubPayments + statistics.InvoicesFirstAmount)), usedCurrency); divRemainder.InnerHtml = string.Format("{0:F} {1}", ((statistics.ClientFirstBalance + statistics.Invoices) - (statistics.Payments + statistics.SubPayments + statistics.InvoicesFirstAmount + statistics.NewBalance)), usedCurrency); if (statistics.NewBalance > 0) { divNewBalance.InnerHtml = string.Format("<a class='toolTip' title='Divide this amount on invoices.' href='{0}-{1}/viewsubinvoices.aspx'>{2:F} {3}</a>", ResolveClientUrl("subinvoice"), cID, statistics.NewBalance, usedCurrency); } else { divNewBalance.InnerHtml = "0.00 (AED)"; } } #endregion } var result = new SaleInvoicesManager().GetClientSaleInvoices(paramStr); gvInvoices.DataSource = result; gvInvoices.DataBind(); if (result.FirstOrDefault() != null) { lblClientName.Text = " for: " + result.FirstOrDefault().ClientName; } }
protected void gvInvoices_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "Delete") { // Get id to delete. int _ID = Convert.ToInt32(e.CommandArgument); // Execute delete func. //if (new SaleInvoicesManager().DeleteCompany(_ID)) // Cancel invoice. // lblError.Text = Resources.AdminResources_en.SuccessDelete; //else // lblError.Text = Resources.AdminResources_en.ErrorDelete; } else if (e.CommandName == "ActiveDeactive") { // Get item id to. long _ID = Convert.ToInt64(e.CommandArgument.ToString().Remove(e.CommandArgument.ToString().IndexOf('.'))); bool toggle = e.CommandArgument.ToString().Substring(e.CommandArgument.ToString().IndexOf('.')).Contains('1'); //GridViewRow row = (GridViewRow)(((ImageButton)e.CommandSource).NamingContainer); //HiddenField userEmail = (HiddenField)row.FindControl("hfUserEmail"); // user email //HiddenField userName = (HiddenField)row.FindControl("hfUserName"); // user name // Execute change status func. var result = new SaleInvoicesManager().ActiveDeActiveInvoice(_ID, toggle); if (result != null) { if (result.Payments4This <= 0 && result.SubPayments4This <= 0) { lblError.Text = Resources.AdminResources_en.ActiveSuccess; FillInvoicesList(); } else { lblError.Text = Resources.AdminResources_en.InvoiceNotDeactive; } //if (toggle == true) // new SendEmail().SendAnEmail(userEmail.Value, string.Format("Your offer: {0} now active", _ID), CreateBody(_ID, userName.Value)); } else { lblError.Text = Resources.AdminResources_en.ActiveFail; } } }
private void GetInvoiceValue(string p) { var result = new SaleInvoicesManager().GetCarSaleInvoiceDetails(Convert.ToInt64(p)); lblSalePrice.Text = string.Format("and It`s Rest Value = {0:F} AED", ShowRestValue(result.SalePrice, result.FirstAmount, result.TotalPaymentsForThis, result.TotalSubPaymentsForThis)); }