protected void btnSave_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(txtReceivedBy.Text) || string.IsNullOrWhiteSpace(txtReceivedBy.Text)) { divMessageBox.Visible = true; divMessageBox.Attributes.Add("class", "notify warning"); ltrlMessageHeader.Text = "Warning!"; ltrlMessage.Text = "Received by is Required"; return; } var donationDetails = DonationDetailItems(); if (donationDetails.Count>0) { var donation = new Donation { DonatedBy = DDLDonatedBy.SelectedItem.Text, SupplierId = int.Parse(DDLDonatedBy.SelectedValue), DonatedTo = DDLDonatedTo.SelectedItem.Text, DepartmentId = int.Parse(DDLDonatedTo.SelectedValue), DonationDate = DateTime.Parse(txtDonationDate.Text), DonationId = txtReferenceNumber.Text, ItemCode = "", ReceivedBy = txtReceivedBy.Text, RequisitionNumber = txtRISNumber.Text, Status = Transaction.TransactionStatus.Posted.ToString(), TotalQuantity = int.Parse(txtTotalQuantity.Text), Uid = Guid.NewGuid(), UnitCode ="" }; _donationManager.Save(donation); int donationIdentity = _donationManager.Identity; var details = donationDetails.Select(donationDetail => new DonationDetail { Barcode = donationDetail.Barcode, DonationId = donationIdentity, ItemId = donationDetail.ItemId, Price = donationDetail.Price, Quantity = donationDetail.Quantity, Uid = donationDetail.Uid, UnitId = donationDetail.UnitId }).ToList(); _donationDetailsManager.Save(details); btnSave.Enabled = false; lnkButtonAdd.Enabled = false; divMessageBox.Visible = true; divMessageBox.Attributes.Add("class", "notify info"); ltrlMessageHeader.Text = "Saved Sucessful!"; ltrlMessage.Text = "New Donation Entry has been saved!"; Session.Remove("DONATION_ITEMS"); } else { divMessageBox.Visible = true; divMessageBox.Attributes.Add("class", "notify warning"); ltrlMessageHeader.Text = "Warning!"; ltrlMessage.Text = "No Item to be add!"; } }
protected void btnSave_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(txtReceivedBy.Text) || string.IsNullOrWhiteSpace(txtReceivedBy.Text)) { divMessageBox.Visible = true; divMessageBox.Attributes.Add("class", "notify warning"); ltrlMessageHeader.Text = "Warning!"; ltrlMessage.Text = "Received by is Required"; return; } var donation = new Donation { DonatedBy = DDLDonatedBy.SelectedItem.Text, SupplierId = int.Parse(DDLDonatedBy.SelectedValue), DonatedTo = DDLDonatedTo.SelectedItem.Text, DepartmentId = int.Parse(DDLDonatedTo.SelectedValue), DonationDate = DateTime.Parse(txtDonationDate.Text), DonationId = txtReferenceNumber.Text, ItemCode = "", ReceivedBy = txtReceivedBy.Text, RequisitionNumber = txtRISNumber.Text, Status = Transaction.TransactionStatus.Posted.ToString(), TotalQuantity = int.Parse(txtTotalQuantity.Text), Uid = Donation.Uid, UnitCode = "", Id = DonationId }; _donationManager.Save(donation); divMessageBox.Visible = true; divMessageBox.Attributes.Add("class", "notify info"); ltrlMessageHeader.Text = "Saved Sucessful!"; ltrlMessage.Text = "Donation Entry has been Updated!"; }