public static int Save(tblMRNoteDTO tblMRNoteDTO) { using (var dbObject = new BRCTransportDBEntities()) { var tblMRNote = tblMRNoteDTO.ToEntity(); if (tblMRNoteDTO.MRId == 0) { dbObject.tblMRNotes.Add(tblMRNote); } else { tblMRNote = dbObject.tblMRNotes.Find(tblMRNoteDTO.MRId); tblMRNote.MrNo = tblMRNoteDTO.MrNo; tblMRNote.BillId = tblMRNoteDTO.BillId; tblMRNote.MRDate = tblMRNoteDTO.MRDate; tblMRNote.RecievedFrom = tblMRNoteDTO.RecievedFrom; tblMRNote.LocationFrom = tblMRNoteDTO.LocationFrom; tblMRNote.LocationTo = tblMRNoteDTO.LocationTo; tblMRNote.NoofPackages = tblMRNoteDTO.NoofPackages; tblMRNote.Weight = tblMRNoteDTO.Weight; tblMRNote.AmountRecieved = tblMRNoteDTO.AmountRecieved; tblMRNote.WayOfRecieve = tblMRNoteDTO.WayOfRecieve; tblMRNote.Fright = tblMRNoteDTO.Fright; tblMRNote.StCharges = tblMRNoteDTO.StCharges; tblMRNote.Hamali = tblMRNoteDTO.Hamali; tblMRNote.Other1 = tblMRNoteDTO.Other1; tblMRNote.Other2 = tblMRNoteDTO.Other2; tblMRNote.Other3 = tblMRNoteDTO.Other3; tblMRNote.Other4 = tblMRNoteDTO.Other4; tblMRNote.TotalAmount = tblMRNoteDTO.TotalAmount; } dbObject.SaveChanges(); return(tblMRNote.MRId); } }
/// <summary> /// Check validation /// </summary> private void CheckValidation(tblMRNoteDTO tblMRNoteDTO) { var resultCheckDuplicateMRNo = MRNoteBusinessLogic.CheckDuplicateMRNo(tblMRNoteDTO.MRId, tblMRNoteDTO.MrNo ?? 0); if (resultCheckDuplicateMRNo) { ModelState.AddModelError("MrNo", "MrNo already exists."); } }
private void btnSave_Click(object sender, EventArgs e) { if (IsFormValidate()) { tblMRNoteDTO dto = new tblMRNoteDTO(); if (MRId > 0) { dto.MRId = MRId; } dto.MrNo = Convert.ToInt32(txtMRno.Text); dto.BillId = Convert.ToInt32(txtbillno.Text); dto.MRDate = Convert.ToDateTime(dpDate.Text); dto.RecievedFrom = txtRecievefrom.Text; dto.LocationFrom = txtfrom.Text; dto.LocationTo = txtto.Text; dto.BillNo = Convert.ToInt32(txtbillno.Text); dto.BillDate = dpbilldate.Text; dto.BillAmount = Convert.ToDouble(txtBillAmount.Text); dto.NoofPackages = txtNoofPackage.Text; dto.Weight = txtWeight.Text; dto.AmountRecieved = txtRecievedAmount.Text.Trim() == "" ? 0 : Convert.ToDouble(txtRecievedAmount.Text); dto.WayOfRecieve = cmbPaymentType.SelectedText; dto.Fright = txtFright.Text.Trim() == "" ? 0 : Convert.ToDouble(txtFright.Text); dto.StCharges = txtstch.Text.Trim() == "" ? 0 : Convert.ToDouble(txtstch.Text); dto.Hamali = txtHamali.Text.Trim() == "" ? 0 : Convert.ToDouble(txtHamali.Text); dto.Other1 = txtOther1.Text.Trim() == "" ? 0 : Convert.ToDouble(txtOther1.Text); dto.Other2 = txtOther2.Text.Trim() == "" ? 0 : Convert.ToDouble(txtOther2.Text); dto.Other3 = txtOther3.Text.Trim() == "" ? 0 : Convert.ToDouble(txtOther3.Text); dto.Other4 = txtOther4.Text.Trim() == "" ? 0 : Convert.ToDouble(txtOther4.Text); dto.TotalAmount = txtTotal.Text.Trim() == "" ? 0 : Convert.ToDouble(txtTotal.Text); dto.CreationDate = DateTime.Now; var result = MRNoteBusinessLogic.Save(dto); if (result > 0) { if (MRId > 0) { this.Close(); } else { CleanData(); } } else { MessageBox.Show("Transaction Fail"); } } }
public ActionResult Save(int id) { tblMRNoteDTO tblMRNoteDTO; if (id == 0) { tblMRNoteDTO = new tblMRNoteDTO(); tblMRNoteDTO.MrNo = MRNoteBusinessLogic.GetMRNo() + 1; } else { tblMRNoteDTO = MRNoteBusinessLogic.Get(id); } tblMRNoteDTO.PaymentType = new List <SelectListItem>(); tblMRNoteDTO.PaymentType.Add(new SelectListItem { Value = "Cash", Text = "Cash" }); tblMRNoteDTO.PaymentType.Add(new SelectListItem { Value = "Cheque", Text = "Cheque" }); return(View(tblMRNoteDTO)); }
public ActionResult Save(tblMRNoteDTO tblMRNoteDTO) { if (ModelState.IsValid) { CheckValidation(tblMRNoteDTO); if (ModelState.IsValid) { var result = MRNoteBusinessLogic.Save(tblMRNoteDTO); if (result > 0) { return(RedirectToAction("Index")); } } } tblMRNoteDTO.PaymentType = new List <SelectListItem>(); tblMRNoteDTO.PaymentType.Add(new SelectListItem { Value = "Cash", Text = "Cash" }); tblMRNoteDTO.PaymentType.Add(new SelectListItem { Value = "Cheque", Text = "Cheque" }); return(View(tblMRNoteDTO)); }
public static int Save(tblMRNoteDTO tblMRNoteDTO) { return(MRNoteRepository.Save(tblMRNoteDTO)); }