コード例 #1
0
        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));
        }
コード例 #2
0
        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);
        }
コード例 #3
0
        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);
        }
コード例 #4
0
        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));
        }
コード例 #5
0
        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);
        }
コード例 #6
0
        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);
        }
コード例 #7
0
        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));
        }
コード例 #8
0
ファイル: FrmSettlements.cs プロジェクト: mkaszta/foksal
        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);
        }
コード例 #9
0
        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));
        }
コード例 #10
0
        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));
        }
コード例 #11
0
ファイル: FrmSettlements.cs プロジェクト: mkaszta/foksal
        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);
        }
コード例 #12
0
        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));
        }
コード例 #13
0
        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));
        }
コード例 #14
0
 protected virtual Task SetLicensorDefaults(Licensor licensor)
 {
     return(Task.FromResult(default(object)));
 }
コード例 #15
0
 partial void SetSelectLists(Licensor licensor);
コード例 #16
0
 partial void OnEditSaved(Licensor licensor);
コード例 #17
0
 partial void OnEditSaving(Licensor licensor);
コード例 #18
0
 partial void OnCreateSaved(Licensor licensor);
コード例 #19
0
 partial void OnCreateSaving(Licensor licensor);