public async Task <ActionResult> Edit(Licensor licensor, bool?modal) { if (ModelState.IsValid) { OnEditSaving(licensor); DataContext.Entry(licensor).State = EntityState.Modified; await DataContext.SaveChangesAsync(this); OnEditSaved(licensor); if (modal ?? false) { return(Json(new { saved = true })); } return(RedirectToAction("Index")); } SetSelectLists(licensor); if (modal ?? false) { ViewBag.Modal = true; return(PartialView("_Edit", licensor)); } return(View(licensor)); }
private void gridExLicensors_CellValueChanged(object sender, ColumnActionEventArgs e) { if (e.Column.DataMember == "LicencjodawcaId") { gridExLicensors.UpdateData(); if (gridExLicensors.CurrentRow.Cells["LicencjodawcaId"].Value != null) { int selectedId = (int)gridExLicensors.CurrentRow.Cells["LicencjodawcaId"].Value; Licensor selectedLicensor = LicensorsRepo.GetById(selectedId); gridExLicensors.CurrentRow.Cells["AdresEmail"].Text = selectedLicensor.Email; gridExLicensors.CurrentRow.Cells["OsobaFizyczna"].Value = selectedLicensor.IsNaturalPerson; gridExLicensors.CurrentRow.Cells["PodatekProcent"].Value = selectedLicensor.TaxPercentage; } else { gridExLicensors.CurrentRow.Cells["AdresEmail"].Text = ""; gridExLicensors.CurrentRow.Cells["OsobaFizyczna"].Value = null; gridExLicensors.CurrentRow.Cells["PodatekProcent"].Value = 0; } } this.SetAgreementChangesPending(true); }
public static Licensor GetById(int licensorId) { Licensor licensor = new Licensor(); using (SqlConnection dbConnection = new DBConnection().Connection) { string sqlQuery = string.Format("SELECT * FROM [Licencjodawca] WHERE [Id] = {0}", licensorId); using (SqlCommand command = new SqlCommand(sqlQuery, dbConnection)) { SqlDataReader reader = command.ExecuteReader(); while (reader.Read()) { licensor.Id = reader.GetInt32(reader.GetOrdinal("id")); licensor.CertificateDate = reader.IsDBNull(reader.GetOrdinal("DataObowiazywaniaCertyfikatu")) ? (DateTime?)null : reader.GetDateTime(reader.GetOrdinal("DataObowiazywaniaCertyfikatu")); licensor.EditedBy = reader.GetInt32(reader.GetOrdinal("EdycjaUzytkownik")); licensor.EditedDate = reader.GetDateTime(reader.GetOrdinal("EdycjaData")); licensor.Email = reader.GetString(reader.GetOrdinal("AdresEmail")); licensor.FirstName = reader.GetString(reader.GetOrdinal("Imie")); licensor.LastName = reader.GetString(reader.GetOrdinal("Nazwisko")); licensor.Name = reader.GetString(reader.GetOrdinal("Nazwa")); licensor.IsNaturalPerson = reader.GetBoolean(reader.GetOrdinal("OsosbaFizyczna")); licensor.TaxPercentage = reader.GetDecimal(reader.GetOrdinal("PodatekProcent")); licensor.VAT = reader.IsDBNull(reader.GetOrdinal("PodatekVAT")) ? (decimal?)null : reader.GetDecimal(reader.GetOrdinal("PodatekVAT")); } } } return(licensor); }
public async Task <ActionResult> Create(Licensor licensor, bool?modal) { if (ModelState.IsValid) { OnCreateSaving(licensor); DataContext.Companies.Add(licensor); await DataContext.SaveChangesAsync(this); OnCreateSaved(licensor); if (modal ?? false) { return(Json(new { saved = true })); } return(RedirectToAction("Index")); } SetSelectLists(licensor); if (modal ?? false) { ViewBag.Modal = true; return(PartialView("_Create", licensor)); } return(View(licensor)); }
private void gridExLicensors_CellEdited(object sender, ColumnActionEventArgs e) { if (gridExLicensors.CurrentColumn != null && gridExLicensors.CurrentColumn.Key == "LicencjodawcaId") { gridExLicensors.UpdateData(); if (int.TryParse(gridExLicensors.CurrentRow.Cells["LicencjodawcaId"].Value.ToString(), out int selectedId)) { selectedId = (int)gridExLicensors.CurrentRow.Cells["LicencjodawcaId"].Value; Licensor selectedLicensor = LicensorsRepo.GetById(selectedId); gridExLicensors.CurrentRow.Cells["AdresEmail"].Text = selectedLicensor.Email; gridExLicensors.CurrentRow.Cells["OsobaFizyczna"].Value = selectedLicensor.IsNaturalPerson; gridExLicensors.CurrentRow.Cells["PodatekProcent"].Value = selectedLicensor.TaxPercentage; } else { gridExLicensors.CurrentRow.Cells["AdresEmail"].Text = ""; gridExLicensors.CurrentRow.Cells["OsobaFizyczna"].Value = false; gridExLicensors.CurrentRow.Cells["PodatekProcent"].Value = 0; } } this.SetAgreementChangesPending(true); }
partial void SetSelectLists(Licensor licensor) { //TODO: Optimize query var queryCountryId = DataContext.Countries; int countryId = licensor == null ? 0 : licensor.CountryId; ViewBag.CountryId = new SelectList(queryCountryId, "Id", "CountryName", countryId); }
public async Task <ActionResult> Delete(int?id) //GET: /Licensors { if (id == null) { return(BadRequestTextResult()); } Licensor licensor = await FindAsyncLicensor(id.Value); if (licensor == null) { return(NotFoundTextResult()); } int purchaseOrdersCount = licensor.PurchaseOrders.Count; int contactsCount = licensor.Contacts.Count; if ((purchaseOrdersCount + contactsCount) > 0) { var sb = new StringBuilder(); sb.Append(MessageStrings.CanNotDelete); sb.Append(" <b>"); sb.Append(licensor.CompanyName); sb.Append("</b>.<br/>"); if (purchaseOrdersCount > 0) { sb.Append(string.Format(MessageStrings.RelatedRecordsExist, purchaseOrdersCount, EntityStrings.PurchaseOrders)); sb.Append("<br/>"); } if (contactsCount > 0) { sb.Append(string.Format(MessageStrings.RelatedRecordsExist, contactsCount, EntityStrings.Contacts)); sb.Append("<br/>"); } return(StatusCodeTextResult(sb, HttpStatusCode.BadRequest)); } DataContext.Companies.Remove(licensor); try { await DataContext.SaveChangesAsync(this); } catch (Exception ex) { var sb = new StringBuilder(); sb.Append(MessageStrings.CanNotDelete); sb.Append(licensor.CompanyName); sb.Append("<br/>"); AppendExceptionMsg(ex, sb); return(StatusCodeTextResult(sb, HttpStatusCode.InternalServerError)); } return(new HttpStatusCodeResult(HttpStatusCode.OK)); }
private void UpdateDispatchInfo() { Settlement settlement = SettlementsRepo.GetById((int)gridExSettlementsList.GetCheckedRows()[0].Cells["id"].Value); Licensor licensor = LicensorsRepo.GetById((int)gridExSettlementsDetails.GetDataRows()[0].Cells["tLicencjodawcaCafreOfId"].Value); settlement.Email = licensor.Email; settlement.DispatchDate = DateTime.Now; SettlementsRepo.Update(settlement); }
public async Task <ActionResult> Create(bool?modal) { var licensor = new Licensor(); await SetLicensorDefaults(licensor); SetSelectLists(licensor); if (modal ?? false) { ViewBag.Modal = true; return(PartialView("_Create", licensor)); } return(View(licensor)); }
public async Task <ActionResult> GetLicensor(int?id) { if (id == null) { return(BadRequestTextResult()); } Licensor licensor = await FindAsyncLicensor(id.Value); if (licensor == null) { return(NotFoundTextResult()); } return(Json(new LicensorDTO(licensor), JsonRequestBehavior.AllowGet)); }
private void PrepareDraftMail(bool reportHasSumRow) { Licensor licensor = LicensorsRepo.GetById((int)gridExSettlementsDetails.GetDataRows()[1].Cells["tLicencjodawcaCafreOfId"].Value); string timeStamp = DateTime.Now.ToString("yyyyMMddHHmmss"); string detailsReportPath = string.Format("{0}{1}_RaportZbiorczy.xls", ConfigurationSettings.AppSettings["mail_attachmentDirectory"], timeStamp); string shortReportPath = string.Format("{0}{1}_RaportSkrocony.pdf", ConfigurationSettings.AppSettings["mail_attachmentDirectory"], timeStamp); List <string> attachments = new List <string>(); attachments.Add(detailsReportPath); attachments.Add(shortReportPath); ExcelHelper.CreateReport_SettlementsDetails(gridExSettlementsDetails, detailsReportPath, reportHasSumRow); ExcelHelper.CreateReport_Short(gridExSettlementsDetails, shortReportPath); OutlookHelper.SaveDraft(attachments, licensor.Email); MessageBox.Show("Szkic maila zostal przygotowany wraz załącznikami.", "Eksport do email", MessageBoxButtons.OK, MessageBoxIcon.Information); }
public async Task <ActionResult> Details(int?id, bool?modal) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Licensor licensor = await FindAsyncLicensor(id.Value); if (licensor == null) { return(HttpNotFound()); } await PutCanUserInViewBag(); if (modal ?? false) { return(PartialView("_Details", licensor)); } return(View(licensor)); }
public async Task <ActionResult> Edit(int?id, bool?modal) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Licensor licensor = await FindAsyncLicensor(id.Value); if (licensor == null) { return(HttpNotFound()); } SetSelectLists(licensor); if (modal ?? false) { ViewBag.Modal = true; return(PartialView("_Edit", licensor)); } return(View(licensor)); }
protected virtual Task SetLicensorDefaults(Licensor licensor) { return(Task.FromResult(default(object))); }
partial void SetSelectLists(Licensor licensor);
partial void OnEditSaved(Licensor licensor);
partial void OnEditSaving(Licensor licensor);
partial void OnCreateSaved(Licensor licensor);
partial void OnCreateSaving(Licensor licensor);