public Boolean EditDispatchOrderSumamry(DispatchOrderModel dispatchOrderModel) { using (_context = new HSSNInventoryEntities()) { try { var data = _context.DispatchOrders.FirstOrDefault( a => a.DispatchOrderId == dispatchOrderModel.DispatchOrderId); if (data != null) { //data.DispatchOrderId = dispatchOrderModel.DispatchOrderId; //data.DispatchOrderNumber = dispatchOrderModel.DispatchOrderNumber; //data.DealerId = dispatchOrderModel.DealerId; //data.DispatchOrderDate = dispatchOrderModel.DispatchOrderDate; //data.BankGuaranteeAmount = dispatchOrderModel.BankGuaranteeAmount; data.IsCheckedByManager =Convert.ToBoolean( dispatchOrderModel.IsCheckedByManager); //data.CheckedBy = dispatchOrderModel.CheckedBy; data.WhetherDoApproved = dispatchOrderModel.WhetherDoApproved; //data.ApprovedBy = dispatchOrderModel.ApprovedBy; //data.NetDueAmount = dispatchOrderModel.NetDueAmount; //data.OverDueAmount = dispatchOrderModel.OverDueAmount; //data.DispatchOrderDate = dispatchOrderModel.DispatchOrderDate; //data.OrderRequestedBy = dispatchOrderModel.OrderRequestedBy; } _context.Entry(data).State = EntityState.Modified; _context.SaveChanges(); //dispatchOrderModel.DispatchOrderId =data.DispatchOrderId; return true; } catch (Exception e) { Console.WriteLine(e); return false; //new DispatchOrderModel(); } } }
private void btnApproved_Click(object sender, EventArgs e) { var model = new FinanceDispatchModel() { EntryDate = Convert.ToDateTime(DateTime.Now.ToShortDateString()), DispatchOrderId = (int)LVDispatchOrder.SelectedItem.Value, CreatedBy = 1, CreatedDate = Convert.ToDateTime(DateTime.Now.ToShortDateString()), ModifiedbY = 1, ModifiedDate = Convert.ToDateTime(DateTime.Now.ToShortDateString()), }; var model2 = new DispatchOrderModel() { DispatchOrderId = (int)LVDispatchOrder.SelectedItem.Value, WhetherDoApproved = true, ApprovedBy = 1, }; _dispatchOrderService.EditDispatchOrderSumamry(model2); var griddata = datafnuc(); var financeDispatchId = _fineDispatchService.saveData(model); _financeDispatchDetailService.SaveFinanceDispatchDetail(griddata, financeDispatchId); //_commonService.saveProductstockupdte(4, 2, 2, 5, "IN"); Notify(); grdDispatchOrderdetail.Rows.Clear(); grdDispatchOrderdetail.Refresh(); grdFinanceDetail.Rows.Clear(); grdFinanceDetail.Refresh(); ListviewDispatchOrder(); }
private DispatchOrderModel SaveDispatchOrderSumamry(DispatchOrderModel dispatchOrderModel) { using (_context = new HSSNInventoryEntities()) { try { var dispatchOrderSummaryModel = new DispatchOrder() { DispatchOrderNumber = dispatchOrderModel.DispatchOrderNumber, DealerId = dispatchOrderModel.DealerId, BankGuaranteeAmount = dispatchOrderModel.BankGuaranteeAmount, NetDueAmount = dispatchOrderModel.NetDueAmount, OverDueAmount = dispatchOrderModel.OverDueAmount, DispatchOrderDate = dispatchOrderModel.DispatchOrderDate, OrderRequestedBy = dispatchOrderModel.OrderRequestedBy, }; _context.Entry(dispatchOrderSummaryModel).State = EntityState.Added; _context.SaveChanges(); dispatchOrderModel.DispatchOrderId = dispatchOrderSummaryModel.DispatchOrderId; return dispatchOrderModel; } catch (Exception e) { Console.WriteLine(e); return new DispatchOrderModel(); } } }
public bool SaveDispatchOrder(DispatchOrderModel dispatchOrderModel) { try { if (dispatchOrderModel.DispatchOrderId == 0) { using (var scope = new TransactionScope()) { dispatchOrderModel.DispatchOrderId = SaveDispatchOrderSumamry(dispatchOrderModel).DispatchOrderId; if (dispatchOrderModel.DispatchOrderId != 0) { SaveDispatchOrderDetails(dispatchOrderModel.DispatchOrderDetailModels, dispatchOrderModel.DispatchOrderId); //update serical number _commonService.UpdateSerialNumberVoucherType("DO"); } scope.Complete(); } } else { //write code for edited data using (var scope = new TransactionScope()) { if (EditDispatchOrderSumamry(dispatchOrderModel) == true) { if (DeleteDispatchOrderDetail(dispatchOrderModel.DispatchOrderId)) { SaveDispatchOrderDetails(dispatchOrderModel.DispatchOrderDetailModels, dispatchOrderModel.DispatchOrderId); } scope.Complete(); } } } } catch (Exception e) { Console.WriteLine(e); } return true; }
private void txtDispatchNumber_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { dispatchOrderModel= _dispatchOrderService.GetDispatchOrderDetailByDispatchOrderId(Convert.ToInt32(txtDispatchNumber.Text)); dtDispatchDate.EnglishDate = dispatchOrderModel.DispatchOrderDate; cmbDealer.SelectedValue = dispatchOrderModel.DealerId; txtBankGuaranteeAmt.Value = dispatchOrderModel.BankGuaranteeAmount; txtNetDueAmt.Value = dispatchOrderModel.NetDueAmount; txtOverDueAmt.Value = dispatchOrderModel.OverDueAmount; grdDisplay.DataSource = dispatchOrderModel.DispatchOrderDetailModels; SerialNumber(); } }
private void btnSave_Click(object sender, EventArgs e) { var dispatchOrderDetailModels = grdDisplay.Rows.Select(row => new DispatchOrderDetailModel() { ProductId = Convert.ToInt32(row.Cells["ProductId"].Value), Quantity = Convert.ToInt32(row.Cells["Quantity"].Value), Rate = Convert.ToInt32(row.Cells["Rate"].Value), UnitId = 1 }).ToList(); var modelData = new DispatchOrderModel() { DispatchOrderNumber = Convert.ToInt32(txtDispatchNumber.Text), DispatchOrderDate = dtDispatchDate.EnglishDate, DealerId = Convert.ToInt32(cmbDealer.SelectedValue), BankGuaranteeAmount = txtBankGuaranteeAmt.Value, OverDueAmount = txtOverDueAmt.Value, NetDueAmount = txtNetDueAmt.Value, OrderRequestedBy = UserDetailModel.UserDetailId, DispatchOrderDetailModels = dispatchOrderDetailModels }; if (OpMode == "Edit") { modelData.DispatchOrderId = dispatchOrderModel.DispatchOrderId; modelData.OrderRequestedBy = dispatchOrderModel.OrderRequestedBy; } _dispatchOrderService.SaveDispatchOrder(modelData); grdDisplay.Rows.Clear(); grdDisplay.Refresh(); btnAdd.Enabled = false; RadMessageBox.Show("Saved Successfully", "DispatchOrder", MessageBoxButtons.OK); Notify(); }
private void btnApproved_Click(object sender, EventArgs e) { var model = new DispatchOrderModel() { DispatchOrderId = (int)LVdispatchorder.SelectedItem.Value, IsCheckedByManager = true, CheckedBy = (int)LVdispatchorder.SelectedItem.Value, }; _dispatchOrderService.UpdateDispatchOrderSumamry(model); RadMessageBox.Show("Approved Success", "Manager Mode", MessageBoxButtons.OK); grdDispatchorderdetail.Rows.Clear(); grdDispatchorderdetail.Refresh(); ListDispatchOrder(); }