/// <summary> /// Handles the OnClick event of the lbtnSendInvoice control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> protected void lbtnSendInvoice_OnClick(object sender, EventArgs e) { if (chxForBuyer.Checked && ucSendInvoiceBuyerContact.SelectedValue.HasValue) { InvoiceNotificationService.SendToContact(_invoiceId, ucSendInvoiceBuyerContact.SelectedValue.Value); } if (chxForExecutor.Checked && ucSendInvoiceExecutorContact.SelectedValue.HasValue) { InvoiceNotificationService.SendToContact(_invoiceId, ucSendInvoiceExecutorContact.SelectedValue.Value); } Response.Redirect(UrlsData.AP_InvoiceEdit(_invoiceId)); }
/// <summary> /// Handles the OnItemDataBound event of the gridInvoices control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="Telerik.Web.UI.GridItemEventArgs"/> instance containing the event data.</param> protected void gridInvoices_OnItemDataBound(object sender, GridItemEventArgs e) { if (e.Item is GridDataItem) { if (access == null) { access = Access.Check(); } var item = (GridDataItem)e.Item; var data = (DataRowView)e.Item.DataItem; var hlTitle = (HyperLink)item.FindControl("hlTitle"); hlTitle.Text = string.Format("Счет №{0} от {1}", data["tbl_Invoice_Number"], DateTime.Parse(data["tbl_Invoice_CreatedAt"].ToString()).ToString("dd/MM/yyyy")); ((HyperLink)item.FindControl("hlEdit")).NavigateUrl = hlTitle.NavigateUrl = UrlsData.AP_InvoiceEdit(Guid.Parse(data["tbl_Invoice_ID"].ToString())); ((Literal)item.FindControl("lrlInvoiceAmount")).Text = decimal.Parse(data["tbl_Invoice_InvoiceAmount"].ToString()).ToString("F"); ((Literal)item.FindControl("lrlNote")).Text = data["tbl_Invoice_Note"].ToString(); ((Literal)item.FindControl("lrlInvoiceStatus")).Text = EnumHelper.GetEnumDescription((InvoiceStatus)int.Parse(data["tbl_Invoice_InvoiceStatusID"].ToString())); if (!string.IsNullOrEmpty(data["tbl_Invoice_PaymentDateActual"].ToString())) { ((Literal)item.FindControl("lrlPaymentDateActual")).Text = DateTime.Parse(data["tbl_Invoice_CreatedAt"].ToString()).ToString("dd/MM/yyyy"); } else { ((Literal)item.FindControl("lrlPaymentDateActual")).Text = "---"; } if (!string.IsNullOrEmpty(data["tbl_Company_Name"].ToString())) { ((Literal)item.FindControl("lrlCompany")).Text = string.Format("<a href=\"{0}\">{1}</a>", UrlsData.AP_Company(Guid.Parse(data["tbl_Company_ID"].ToString())), data["tbl_Company_Name"]); } if (!string.IsNullOrEmpty(data["tbl_CompanyLegalAccount_Title"].ToString())) { ((Literal)item.FindControl("lrlCompanyLegalAccount")).Text = data["tbl_CompanyLegalAccount_Title"].ToString(); } var lbDelete = (LinkButton)e.Item.FindControl("lbDelete"); lbDelete.CommandArgument = data["ID"].ToString(); lbDelete.Command += lbDelete_OnCommand; lbDelete.Visible = access.Delete; var invoice = DataManager.Invoice.SelectById(Guid.Parse(data["tbl_Invoice_ID"].ToString())); if (invoice.tbl_Shipment.Any()) { ((Literal)item.FindControl("lrlShipments")).Text = string.Format("<div class=\"span-url\">Отгрузки: {0}</div>", string.Join(", ", invoice.tbl_Shipment.Select( o => string.Format("<a href=\"{0}\">Отгрузка №{1} от {2}</a>", UrlsData.AP_ShipmentEdit(o.ID), o.Number, o.CreatedAt.ToString("dd.MM.yyyy"))))); } } }