private void toolStripButtonFromPR_Click(object sender, EventArgs e) { IList addedPI = new ArrayList(); for (int i = 0; i < itemsDataGrid.Rows.Count; i++) { SalesReturn pi = (SalesReturn)itemsDataGrid[invoiceNoColumn.Index, i].Tag; if (pi == null) { continue; } addedPI.Add(pi.ID); } using (SearchSRForARCreditNoteForm frm = new SearchSRForARCreditNoteForm( (Customer)supplierkryptonComboBox.SelectedItem, addedPI, m_mainForm.CurrentUser, dateKryptonDateTimePicker.Value)) { frm.ShowDialog(); IList result = frm.RESULT; foreach (SalesReturn item in result) { int row = itemsDataGrid.Rows.Add(); itemsDataGrid[invoiceNoColumn.Index, row].Tag = item; itemsDataGrid[invoiceNoColumn.Index, row].Value = item.CODE; itemsDataGrid[invoiceDateColumn.Index, row].Value = item.TRANSACTION_DATE; itemsDataGrid[amountColumn.Index, row].Value = item.TOTAL_AMOUNT_FROM_SO; itemsDataGrid[notesColumn.Index, row].Value = "Wizard from PR# " + item.CODE; ReCalculateNetTotal(); } } }
public bool insertNewEntity(SalesReturn s) { int rowsAffected = 0; SqlParameter[] parameters = new SqlParameter[] { new SqlParameter("@SalesReturnID", SqlDbType.NVarChar), new SqlParameter("@SalesOutID", SqlDbType.NVarChar), new SqlParameter("@CreateDate", SqlDbType.NVarChar), new SqlParameter("@ReturnType", SqlDbType.NVarChar), new SqlParameter("@StoreHouseID", SqlDbType.Int), new SqlParameter("@HouseDetailID", SqlDbType.Int), new SqlParameter("@TradeDate", SqlDbType.NVarChar), new SqlParameter("@TotalPrice", SqlDbType.Float), new SqlParameter("@Deposits", SqlDbType.Float), new SqlParameter("@UserName", SqlDbType.NVarChar), new SqlParameter("@Description", SqlDbType.NVarChar), new SqlParameter("@State", SqlDbType.Int) }; parameters[0].Value = s.SalesReturnID; parameters[1].Value = s.SalesOutID; parameters[2].Value = s.CreateDate; parameters[3].Value = s.ReturnType; parameters[4].Value = s.StoreHouseID; parameters[5].Value = s.HouseDetailID; parameters[6].Value = s.TradeDate; parameters[7].Value = s.TotalPrice; parameters[8].Value = s.Deposits; parameters[9].Value = s.UserName; parameters[10].Value = s.Description; parameters[11].Value = s.State; SQLHelper.RunProcedure("p_SalesReturn_insertNewEntity", parameters, out rowsAffected); List <VSalesOutDetail> list = new List <VSalesOutDetail>(); SalesReturnDetailDAL ldal = new SalesReturnDetailDAL(); list = new SalesOutDetailDAL().getBySalesOutID(s.SalesOutID); for (int i = 0; i < list.Count; i++) { VSalesOutDetail detail = list[i]; SalesReturnDetail b = new SalesReturnDetail(); b.Price = detail.Price; b.ProductsID = detail.ProductsID; b.Quantity = detail.Quantity; b.Description = ""; b.SalesReturnID = s.SalesReturnID; ldal.insertNewEitity(b); } return(1 == rowsAffected); }
public SalesReturnViewModel GetSalesReturn(int invoiceID) { SalesReturn salesReturn = _salesReturnRepository.GetMany(x => x.InvoiceId == invoiceID && x.Status == (int)DbConstant.DefaultDataStatus.Active).FirstOrDefault(); SalesReturnViewModel viewModel = new SalesReturnViewModel(); return(Map(salesReturn, viewModel)); }
private void AddResult() { try { for (int i = 0; i < gridData.Rows.Count; i++) { bool check = Convert.ToBoolean(gridData[checkColumn.Index, i].Value); if (!check) { continue; } SalesReturn pi = (SalesReturn)gridData.Rows[i].Tag; if (RESULT.Count > 0) { SalesReturn p1 = (SalesReturn)RESULT[0]; if (p1.CURRENCY.ID != pi.CURRENCY.ID) { throw new Exception("Please select same currency"); } } RESULT.Add(pi); } } catch (Exception x) { KryptonMessageBox.Show(x.Message); } }
public void modifyEntryTest() { ConnectionManager c = new ConnectionManager(); MySqlConnection connection = c.connectDatabase("Database = proximoDB; Data Source = us-cdbr-azure-central-a.cloudapp.net; User Id = b5fb261919a40c; Password = aff5b96f"); DateTime dt1 = new DateTime(2015, 01, 01); DateTime dt2 = new DateTime(2017, 01, 01); c.openConnection(connection); List <object> l = c.retrieveEntry(connection, dt1, dt2, "orderEntry"); c.closeConnection(connection); c.openConnection(connection); ((DailySalesDetails)l[1]).setDate(DateTime.Now); SalesEntry se = new SalesEntry(); DailySalesDetails ds = new DailySalesDetails(); SalesReturn sr = new SalesReturn(); ReturnEntry re = new ReturnEntry(); sr.addReturnEntry(re); sr.ReturnerID = 750; ds.SubmitterID = 565; ds.addEntry(se); se.Quantity = 50; System.DateTime now = System.DateTime.Now; ds.setDate(now); //c.modifyEntry(connection, ds, l[1]); }
public void storeEntryTest() { ConnectionManager c = new ConnectionManager(); MySqlConnection connection = c.connectDatabase("Database = proximoDB; Data Source = us-cdbr-azure-central-a.cloudapp.net; User Id = b5fb261919a40c; Password = aff5b96f"); SalesEntry se = new SalesEntry(); DailySalesDetails ds = new DailySalesDetails(); SalesReturn sr = new SalesReturn(); ReturnEntry re = new ReturnEntry(); Order newOrder = new Order(); newOrder.OrderId = 4578; newOrder.OrderRequestedDate = System.DateTime.Now; sr.addReturnEntry(re); sr.ReturnerID = 750; ds.SubmitterID = 565; ds.addEntry(se); se.Quantity = 50; se.Product = new Product(); c.openConnection(connection); System.DateTime now = System.DateTime.Now; ds.setDate(now); bool b = c.storeEntry(connection, ds); c.closeConnection(connection); }
private void gridData_CellMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e) { if (gridData.SelectedRows.Count > 0) { SALES_RETURN = (SalesReturn)gridData.SelectedRows[0].Tag; this.Close(); } }
private void OKkryptonButton_Click(object sender, EventArgs e) { if (gridData.SelectedRows.Count > 0) { SALES_RETURN = (SalesReturn)gridData.SelectedRows[0].Tag; this.Close(); } }
public void InsertSalesReturn(SalesReturnColumnModel model) { try { using (this.unitOfWork) { SalesReturn item = new SalesReturn() { MemoNumber = model.MemoNumber, CustomerId = model.CustomerId, ReturnDate = model.ReturnDate, AmountReturn = model.AmountReturn, Adjustment = model.Adjustment, TotalCreditAmount = model.TotalCreditAmount, Remarks = model.Remarks, IsDeleted = model.IsDeleted, RecordedBy = model.RecordedByUser, ApprovedBy = model.ApprovedByUser, AmountUsed = 0 }; if (model.Details.Count > 0) { foreach (SalesReturnDetailModel d in model.Details) { SalesReturnDetail detail = new SalesReturnDetail() { PartDetailId = d.PartDetailId, InvoiceNumber = d.InvoiceNumber, Quantity = d.Quantity, UnitPrice = d.UnitPrice, TotalAmount = d.TotalAmount, Balance = d.TotalAmount }; item.SalesReturnDetail.Add(detail); AutoPartDetail autoDetail = db.AutoPartDetail.FirstOrDefault(a => a.Id == d.PartDetailId); if (autoDetail != null) { autoDetail.Quantity += d.Quantity; } } } this.unitOfWork.Context.AddToSalesReturn(item); string action = string.Format("Added new Sales Return - {0}", item.MemoNumber); this.actionLogController.AddToLog(action, UserInfo.UserId); this.unitOfWork.SaveChanges(); } } catch (Exception ex) { throw ex; } }
protected void GrdReport_RowDataBound(object sender, GridViewRowEventArgs e) { try { if (e.Row.RowType == DataControlRowType.DataRow) { SystemOpening += Convert.ToDecimal(DataBinder.Eval(e.Row.DataItem, "SystemOpening")); ActualOpening += Convert.ToDecimal(DataBinder.Eval(e.Row.DataItem, "ActualOpening")); Purchase += Convert.ToDecimal(DataBinder.Eval(e.Row.DataItem, "Purchase")); Sales += Convert.ToDecimal(DataBinder.Eval(e.Row.DataItem, "Sales")); SalesReturn += Convert.ToDecimal(DataBinder.Eval(e.Row.DataItem, "SalesReturn")); Inward += Convert.ToDecimal(DataBinder.Eval(e.Row.DataItem, "Inward")); Outward += Convert.ToDecimal(DataBinder.Eval(e.Row.DataItem, "Outward")); OutwardReturn += Convert.ToDecimal(DataBinder.Eval(e.Row.DataItem, "OutwardReturn")); TransferIN += Convert.ToDecimal(DataBinder.Eval(e.Row.DataItem, "TransferIN")); TransferOUT += Convert.ToDecimal(DataBinder.Eval(e.Row.DataItem, "TransferOUT")); Damaged += Convert.ToDecimal(DataBinder.Eval(e.Row.DataItem, "Damage")); PurReturn += Convert.ToDecimal(DataBinder.Eval(e.Row.DataItem, "ReturnToSupplier")); Deviation += Convert.ToDecimal(DataBinder.Eval(e.Row.DataItem, "Deviation")); SystemClosing += Convert.ToDecimal(DataBinder.Eval(e.Row.DataItem, "SystemClosing")); ActualClosing += Convert.ToDecimal(DataBinder.Eval(e.Row.DataItem, "ActualClosing")); SystemAmount += Convert.ToDecimal(DataBinder.Eval(e.Row.DataItem, "SystemAmount")); ActualAmount += Convert.ToDecimal(DataBinder.Eval(e.Row.DataItem, "ActualAmount")); UNITActualAmount += Convert.ToDecimal(DataBinder.Eval(e.Row.DataItem, "STOCKINHANDWITHUNITCONVERTSYSTEM")); UNITOutwardReturn += Convert.ToDecimal(DataBinder.Eval(e.Row.DataItem, "STOCKINHANDWITHUNITCONVERTACTUAL")); } if (e.Row.RowType == DataControlRowType.Footer) { e.Row.Cells[6].Text = "Total"; e.Row.Cells[7].Text = SystemOpening.ToString("0.00"); e.Row.Cells[8].Text = ActualOpening.ToString("0.00"); e.Row.Cells[9].Text = Purchase.ToString("0.00"); e.Row.Cells[11].Text = Sales.ToString("0.00"); e.Row.Cells[12].Text = SalesReturn.ToString("0.00"); e.Row.Cells[13].Text = Inward.ToString("0.00"); e.Row.Cells[14].Text = Outward.ToString("0.00"); e.Row.Cells[15].Text = OutwardReturn.ToString("0.00"); e.Row.Cells[16].Text = TransferIN.ToString("0.00"); e.Row.Cells[17].Text = TransferOUT.ToString("0.00"); e.Row.Cells[18].Text = Damaged.ToString("0.00"); e.Row.Cells[10].Text = PurReturn.ToString("0.00"); e.Row.Cells[19].Text = Deviation.ToString("0.00"); e.Row.Cells[20].Text = SystemClosing.ToString("0.00"); e.Row.Cells[21].Text = ActualClosing.ToString("0.00"); e.Row.Cells[23].Text = UNITActualAmount.ToString("0.00"); e.Row.Cells[24].Text = UNITOutwardReturn.ToString("0.00"); e.Row.Cells[25].Text = SystemAmount.ToString("0.00"); e.Row.Cells[26].Text = ActualAmount.ToString("0.00"); } } catch (Exception ex) { } }
public IActionResult DeleteSalesReturn(long id) { SalesReturn SalesReturn = return_repo.Find(id); if (SalesReturn == null) { return(NotFound()); } return_repo.Delete(SalesReturn); return(Ok()); }
public SalesReturn getSalesreturn(SqlConnection con, int ReturnMID) { SalesReturn obSalesReturn = new SalesReturn(); DataTable dt = new DataTable(); try { SqlDataAdapter da = new SqlDataAdapter("SELECT * FROM T_Sales_Return WHERE ReturnMID = @ReturnMID", con); da.SelectCommand.Parameters.Add("@ReturnMID", SqlDbType.Int).Value = ReturnMID; da.Fill(dt); da.Dispose(); if (dt.Rows.Count == 0) { return(null); } obSalesReturn.ReturnMID = dt.Rows[0].Field <int>("ReturnMID"); obSalesReturn.CurrencyID = Convert.ToInt32(dt.Rows[0].Field <int>("CurrencyID")); obSalesReturn.SalesInvoiceID = dt.Rows[0].Field <int>("SalesInvoiceID"); obSalesReturn.InvoiceNo = dt.Rows[0].Field <string>("InvoiceNo"); obSalesReturn.ChalanNo = dt.Rows[0].Field <string>("ChalanNo"); obSalesReturn.ReturnDate = dt.Rows[0].Field <DateTime>("ReturnDate"); obSalesReturn.CustomerAccount = dt.Rows[0].Field <int>("CustomerAccount"); obSalesReturn.SalesAccount = dt.Rows[0].Field <int>("SalesAccount"); obSalesReturn.ReturnAmount = Convert.ToDouble(dt.Rows[0].Field <object>("ReturnAmount")); if (dt.Rows[0].Field <object>("TransRefID") == null || dt.Rows[0].Field <object>("TransRefID") == DBNull.Value) { obSalesReturn.TransRefID = 0; } else { obSalesReturn.TransRefID = dt.Rows[0].Field <int>("TransRefID"); } if (dt.Rows[0].Field <object>("StockRefID") == null || dt.Rows[0].Field <object>("StockRefID") == DBNull.Value) { obSalesReturn.StockRefID = 0; } else { obSalesReturn.StockRefID = dt.Rows[0].Field <int>("StockRefID"); } obSalesReturn.Remarks = dt.Rows[0].Field <string>("Remarks"); obSalesReturn.Rate = Convert.ToDouble(dt.Rows[0].Field <object>("Rate")); } catch (Exception ex) { throw new Exception(ex.Message); } return(obSalesReturn); }
public async Task <long> PostAsync(string tenant, SalesReturn model) { string connectionString = FrapidDbServer.GetConnectionString(tenant); const string sql = @"EXECUTE sales.post_return @TransactionMasterId, @OfficeId, @UserId, @LoginId, @ValueDate, @BookDate, @StoreId, @CounterId, @CustomerId, @PriceTypeId, @ReferenceNumber, @StatementReference, @Details, @ShipperId, @Discount, @TranId OUTPUT ;"; using (var connection = new SqlConnection(connectionString)) { using (var command = new SqlCommand(sql, connection)) { command.Parameters.AddWithNullableValue("@TransactionMasterId", model.TransactionMasterId); command.Parameters.AddWithNullableValue("@OfficeId", model.OfficeId); command.Parameters.AddWithNullableValue("@UserId", model.UserId); command.Parameters.AddWithNullableValue("@LoginId", model.LoginId); command.Parameters.AddWithNullableValue("@ValueDate", model.ValueDate); command.Parameters.AddWithNullableValue("@BookDate", model.BookDate); command.Parameters.AddWithNullableValue("@StoreId", model.StoreId); command.Parameters.AddWithNullableValue("@CounterId", model.CounterId); command.Parameters.AddWithNullableValue("@CustomerId", model.CustomerId); command.Parameters.AddWithNullableValue("@PriceTypeId", model.PriceTypeId); command.Parameters.AddWithNullableValue("@ReferenceNumber", model.ReferenceNumber); command.Parameters.AddWithNullableValue("@StatementReference", model.StatementReference); using (var details = new SalesEntry.SqlServer().GetDetails(model.Details)) { command.Parameters.AddWithNullableValue("@Details", details, "sales.sales_detail_type"); } command.Parameters.AddWithNullableValue("@ShipperId", model.ShipperId); command.Parameters.AddWithNullableValue("@Discount", model.Discount); command.Parameters.Add("@TranId", SqlDbType.BigInt).Direction = ParameterDirection.Output; connection.Open(); await command.ExecuteNonQueryAsync().ConfigureAwait(false); return(command.Parameters["@TranId"].Value.To <long>()); } } }
public ActionResult ReturnItems(FormCollection coll) { List <SalesReturnDetail> details = new List <SalesReturnDetail>(); var counter = Convert.ToInt32(coll["counter"]); //attributes required for SalesReturn decimal total = Convert.ToDecimal(coll["SubTotal"]); decimal discount = Convert.ToDecimal(coll["Discount"]); decimal netTotal = Convert.ToDecimal(coll["NetTotal"]); int salesID = Convert.ToInt32(coll["SalesID"]); //populating through each of the occurance of the ReturnedItems for (int i = 1; i <= counter; i++) { var value = coll["Qty_" + i]; if (!string.IsNullOrEmpty(value) && value != "0") { SalesReturnDetail srd = new SalesReturnDetail { StockID = Convert.ToInt32(coll["StockID_" + i]), BatchNo = coll["BatchNo_" + i], Qty = Convert.ToInt32(coll["Qty_" + i]), Rate = Convert.ToDecimal(coll["Rate_" + i]), Amount = Convert.ToDecimal(coll["Amount_" + i]) }; details.Add(srd); } } //populating Sales Return SalesReturn _SalesReturn = new SalesReturn { SalesID = salesID, Subtotal = total, Discount = discount, NetTotal = netTotal, SalesReturnDetails = details, Description = "n/a", ReturnedDate = DateTime.Today }; //Add in Sales And save changes salRetRepo.Add(_SalesReturn); // db.SaveChanges(); return(RedirectToAction("Index")); }
public async Task <long> PostAsync(string tenant, SalesReturn model) { string connectionString = FrapidDbServer.GetConnectionString(tenant); string sql = @"SELECT * FROM sales.post_return ( @TransactionMasterId::bigint, @OfficeId::integer, @UserId::integer, @LoginId::bigint, @ValueDate::date, @BookDate::date, @StoreId::integer, @CounterId::integer, @CustomerId, @PriceTypeId::integer, @ReferenceNumber::national character varying(24), @StatementReference::text, ARRAY[{0}], @ShipperId, @Discount );"; sql = string.Format(sql, this.GetParametersForDetails(model.Details)); using (var connection = new NpgsqlConnection(connectionString)) { using (var command = new NpgsqlCommand(sql, connection)) { command.Parameters.AddWithNullableValue("@TransactionMasterId", model.TransactionMasterId); command.Parameters.AddWithNullableValue("@OfficeId", model.OfficeId); command.Parameters.AddWithNullableValue("@UserId", model.UserId); command.Parameters.AddWithNullableValue("@LoginId", model.LoginId); command.Parameters.AddWithNullableValue("@ValueDate", model.ValueDate); command.Parameters.AddWithNullableValue("@BookDate", model.BookDate); command.Parameters.AddWithNullableValue("@StoreId", model.StoreId); command.Parameters.AddWithNullableValue("@CounterId", model.CounterId); command.Parameters.AddWithNullableValue("@CustomerId", model.CustomerId); command.Parameters.AddWithNullableValue("@PriceTypeId", model.PriceTypeId); command.Parameters.AddWithNullableValue("@ReferenceNumber", model.ReferenceNumber); command.Parameters.AddWithNullableValue("@StatementReference", model.StatementReference); command.Parameters.AddRange(this.AddParametersForDetails(model.Details).ToArray()); command.Parameters.AddWithNullableValue("@ShipperId", model.ShipperId); command.Parameters.AddWithNullableValue("@Discount", model.Discount); connection.Open(); var awaiter = await command.ExecuteScalarAsync().ConfigureAwait(false); return(awaiter.To <long>()); } } }
private string GenRN() { //var context = new ApplicationDbContext(); try { //SalesReturn lastReturn = context.SalesReturns.LastOrDefault(); SalesReturn lastReturn = return_repo.GetLast(); string value = lastReturn.ReturnNumber; string number = Regex.Match(value, "[0-9]+$").Value; return(value.Substring(0, value.Length - number.Length) + (long.Parse(number) + 1).ToString().PadLeft(number.Length, '0')); } catch (NullReferenceException) { return("SRN0000000001"); } }
protected void GrdReport_RowDataBound(object sender, GridViewRowEventArgs e) { try { if (e.Row.RowType == DataControlRowType.DataRow) { Opening += Convert.ToDecimal(DataBinder.Eval(e.Row.DataItem, "Opening")); Purchase += Convert.ToDecimal(DataBinder.Eval(e.Row.DataItem, "Purchase")); Sales += Convert.ToDecimal(DataBinder.Eval(e.Row.DataItem, "Sales")); SalesReturn += Convert.ToDecimal(DataBinder.Eval(e.Row.DataItem, "SalesReturn")); Inward += Convert.ToDecimal(DataBinder.Eval(e.Row.DataItem, "Inward")); Outward += Convert.ToDecimal(DataBinder.Eval(e.Row.DataItem, "Outward")); OutwardReturn += Convert.ToDecimal(DataBinder.Eval(e.Row.DataItem, "OutwardReturn")); TransferIN += Convert.ToDecimal(DataBinder.Eval(e.Row.DataItem, "TransferIN")); TransferOUT += Convert.ToDecimal(DataBinder.Eval(e.Row.DataItem, "TransferOUT")); Damaged += Convert.ToDecimal(DataBinder.Eval(e.Row.DataItem, "Damage")); PurReturn += Convert.ToDecimal(DataBinder.Eval(e.Row.DataItem, "ReturnToSupplier")); Closing += Convert.ToDecimal(DataBinder.Eval(e.Row.DataItem, "Closing")); Amount += Convert.ToDecimal(DataBinder.Eval(e.Row.DataItem, "Amount")); Consumption += Convert.ToDecimal(DataBinder.Eval(e.Row.DataItem, "Consumption")); } if (e.Row.RowType == DataControlRowType.Footer) { e.Row.Cells[6].Text = "Total"; e.Row.Cells[7].Text = Opening.ToString("0.00"); e.Row.Cells[8].Text = Purchase.ToString("0.00"); e.Row.Cells[9].Text = Sales.ToString("0.00"); e.Row.Cells[10].Text = SalesReturn.ToString("0.00"); e.Row.Cells[12].Text = Inward.ToString("0.00"); e.Row.Cells[13].Text = Outward.ToString("0.00"); e.Row.Cells[14].Text = OutwardReturn.ToString("0.00"); e.Row.Cells[16].Text = TransferIN.ToString("0.00"); e.Row.Cells[17].Text = TransferOUT.ToString("0.00"); e.Row.Cells[15].Text = Damaged.ToString("0.00"); e.Row.Cells[11].Text = PurReturn.ToString("0.00"); e.Row.Cells[19].Text = Closing.ToString("0.00"); e.Row.Cells[20].Text = Amount.ToString("0.00"); e.Row.Cells[18].Text = Consumption.ToString("0.00"); } } catch (Exception ex) { } }
protected void init() { string action = Request.Form["action"].ToString(); if (action.Equals("add")) { string str0 = Request.Form["SalesReturnID"].ToString(); string str1 = Request.Form["SalesOutID"].ToString(); string str2 = Request.Form["CreateDate"].ToString(); string str3 = Request.Form["ReturnType"].ToString(); string str5 = Request.Form["StoreHouseID"].ToString(); string str6 = Request.Form["HouseDetailID"].ToString(); string str7 = Request.Form["TradeDate"].ToString(); string str8 = Request.Form["Deposits"].ToString(); string str9 = Request.Form["Description"].ToString(); SalesReturn s = new SalesReturn(); s.ReturnType = str3; s.CreateDate = str2; s.StoreHouseID = int.Parse(str5); s.HouseDetailID = int.Parse(str6); s.TradeDate = str7; s.Deposits = float.Parse(str8); s.Description = str9; s.UserName = getUserName(); s.State = 0; s.SalesOutID = str1; s.SalesReturnID = str0; Leyp.SQLServerDAL.Sales.Factory.getSalesReturnDAL().insertNewEntity(s); Response.Write("00"); Response.End(); } else if (action.Equals("delete")) { string str0 = Request.Form["SalesReturnID"].ToString(); VSalesReturn v = new VSalesReturn(); v = Leyp.SQLServerDAL.Sales.Factory.getSalesReturnDAL().getByID(str0); if (v.UserName.Equals(getUserName())) { Leyp.SQLServerDAL.Sales.Factory.getSalesOutDAL().deleteEitity(str0); Response.Write("00"); Response.End(); } } }
public bool AddNewSalesReturn(SalesReturn Invoice, IList <SalesReturnItems> InvoiceItemList, ref string ErrorMessage) { ErrorMessage = string.Empty; try { Salesreturncontext.SalesReturn.Add(Invoice); Salesreturncontext.SaveChanges(); int currentId = Invoice.Sales_Return_Id; for (int i = 0; i < InvoiceItemList.Count; i++) { InvoiceItemList[i].Sales_Return_Id = currentId; InvoiceItemList[i].BaseDocLink = "Y"; } Salesreturncontext.SalesReturnItems.AddRange(InvoiceItemList); Salesreturncontext.SaveChanges(); return(true); } catch (Exception ex) { ExceptionHandler.LogException(ex); ErrorMessage = ex.Message; return(false); } //catch (DbEntityValidationException dbEx) //{ // var errorList = new List<string>(); // foreach (var validationErrors in dbEx.EntityValidationErrors) // { // foreach (var validationError in validationErrors.ValidationErrors) // { // errorList.Add(String.Format("Property: {0} Error: {1}", validationError.PropertyName, validationError.ErrorMessage)); // } // } // return false; //} }
public void ClearForm() { try { m_prn = new SalesReturn(); textBoxCode.Text = ""; dateKryptonDateTimePicker.Value = DateTime.Today; employeeKryptonComboBox.SelectedIndex = 0; notesKryptonTextBox.Text = ""; supplierkryptonComboBox.SelectedIndex = 0; docdatekryptonDateTimePicker.Value = DateTime.Today; docnokryptonTextBox.Text = ""; itemsDataGrid.Rows.Clear(); errorProvider1.Clear(); } catch (Exception x) { KryptonMessageBox.Show(x.Message, "Message", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
public bool UpdateSalesReturn(SalesReturn Quotation, IList <SalesReturnItems> QuotationItemList, ref string ErrorMessage) { ErrorMessage = string.Empty; try { Salesreturncontext.Entry(Quotation).State = EntityState.Modified; Salesreturncontext.SaveChanges(); foreach (var model in QuotationItemList) { if (model.IsDummy == 1) { Salesreturncontext.Entry(model).State = EntityState.Deleted; Salesreturncontext.SaveChanges(); } else { if (model.Sales_ReturnItem_Id == 0) { model.Sales_Return_Id = Quotation.Sales_Invoice_Id; Salesreturncontext.SalesReturnItems.Add(model); Salesreturncontext.SaveChanges(); } else { Salesreturncontext.Entry(model).State = EntityState.Modified; Salesreturncontext.SaveChanges(); } } } return(true); } catch (Exception ex) { ExceptionHandler.LogException(ex); ErrorMessage = ex.Message; return(false); } }
public void LoadSalesReturnDetails() { SalesReturn sReturn = this.salesReturnController.FetchSalesReturnById(ReturnId); if (sReturn != null) { MemoTextbox.Text = sReturn.MemoNumber; ReturnDatePicker.Value = sReturn.ReturnDate.HasValue ? sReturn.ReturnDate.Value : DateTime.Today; CustomerDropdown.SelectedValue = sReturn.CustomerId; RemarksTextbox.Text = sReturn.Remarks; list = this.salesReturnController.FetchSalesReturnDetails(ReturnId).ToList(); if (list.Any()) { BindDetails(); ComputeTotalCredit(); } } else { PrepareForm(); } }
public async Task <ActionResult> PostAsync(SalesReturn model) { if (!this.ModelState.IsValid) { return(this.InvalidModelState(this.ModelState)); } var meta = await AppUsers.GetCurrentAsync().ConfigureAwait(true); model.UserId = meta.UserId; model.OfficeId = meta.OfficeId; model.LoginId = meta.LoginId; try { long tranId = await SalesReturnEntries.PostAsync(this.Tenant, model).ConfigureAwait(true); return(this.Ok(tranId)); } catch (Exception ex) { return(this.Failed(ex.Message, HttpStatusCode.InternalServerError)); } }
private void searchToolStripButton_Click(object sender, EventArgs e) { IList result = searchToolStripTextBox.Text == string.Empty ? new ArrayList() : r_prn.Search(searchToolStripTextBox.Text); if (result.Count == 1) { m_prn = (SalesReturn)result[0]; m_prn = (SalesReturn)r_prn.Get(m_prn.ID); m_prn.EMPLOYEE = (Employee)r_employee.GetById(m_prn.EMPLOYEE); m_prn.CUSTOMER = (Customer)r_sup.GetById(m_prn.CUSTOMER); setEditMode(EditMode.View); loadData(); setEnableForm(false); } else { using (SearchSalesReturnForm frm = new SearchSalesReturnForm(searchToolStripTextBox.Text, result)) { frm.ShowDialog(); if (frm.SALES_RETURN == null) { return; } else { m_prn = frm.SALES_RETURN; m_prn = (SalesReturn)r_prn.Get(m_prn.ID); m_prn.EMPLOYEE = (Employee)r_employee.GetById(m_prn.EMPLOYEE); m_prn.CUSTOMER = (Customer)r_sup.GetById(m_prn.CUSTOMER); setEditMode(EditMode.View); loadData(); setEnableForm(false); } } } }
public static async Task <long> PostAsync(string tenant, SalesReturn model) { var entry = LocateService(tenant); return(await entry.PostAsync(tenant, model).ConfigureAwait(false)); }
public void Update(SalesReturn SalesReturn) { _SalesReturnRepository.Update(SalesReturn); _UnitOfWork.Commit(); }
public void Create(SalesReturn SalesReturn) { _SalesReturnRepository.Add(SalesReturn); _UnitOfWork.Commit(); }
public static string SelectSingleSalesReturn(long sales_return_id) { try { if (sales_return_id == 0) { return("'Null'"); } List <SalesReturn> _salesReturn = new List <SalesReturn>(); var data = Database._SalesReturnSelect(sales_return_id); foreach (var d in data) { SalesReturn _sr = new SalesReturn(); _sr.ID = d.ID; _sr.CustomerID = d.CustomerID.Value; _sr.CustomerName = d.CustomerName; _sr.Address = d.Address; _sr.ForwarderID = d.DeliverToID.Value; _sr.SalesmanID = d.SalesmanID.Value; _sr.PoNO = d.PONo; _sr.TermID = d.TermID.Value; _sr.RefNo = d.RefNo; _sr.RefSerial = d.RefNoSerial; _sr.Date = d.CreatedDate.Value; _sr.Notes = d.Notes; _sr.TotalAmount = d.TotalAmount.Value; var salesReturnDetails = Database._SalesReturnDetailsSelect(d.ID); List <SalesReturnDetail> salesReturnDetail = new List <SalesReturnDetail>(); foreach (var srd in salesReturnDetails) { SalesReturnDetail _srd = new SalesReturnDetail(); _srd.ID = srd.ID; _srd.ProductID = srd.ProductID.Value; _srd.ProductName = srd.ProductName; _srd.LocationID = srd.LocationID.Value; _srd.LocationName = srd.LocationName; _srd.Quantity = srd.Quantity.Value; _srd.Unit = srd.UnitName; _srd.UnitPrice = srd.UnitPrice.Value; _srd.Discount = srd.Discount; _srd.Amount = srd.Amount.Value; salesReturnDetail.Add(_srd); } _sr.SalesReturnDetails = salesReturnDetail; //-------------------------- var salesReturnPayment = Database._invoicePaymentSalesReturns.Where(x => x.SalesReturnID == d.ID); List <ApplyList> ApplyLists = new List <ApplyList>(); foreach (var srp in salesReturnPayment) { ApplyList _al = new ApplyList(); _al.InvoiceID = srp.InvoiceID.Value; _al.RefNo = Database._Invoices.SingleOrDefault(x => x.ID == srp.InvoiceID).RefNo + Database._Invoices.SingleOrDefault(x => x.ID == srp.InvoiceID).RefNoSerial; _al.Date = Database._Invoices.SingleOrDefault(x => x.ID == srp.InvoiceID).CreatedDate.Value; _al.Description = "Invoices"; var salesman_id = Database._Invoices.SingleOrDefault(x => x.ID == srp.InvoiceID.Value).SalesmanID; _al.Salesman = Database._Employees.SingleOrDefault(x => x.ID == salesman_id).EmployeeName; _al.Balance = (Database._Invoices.SingleOrDefault(x => x.ID == srp.InvoiceID).TotalAmount.Value - srp.Amount.Value); _al.AppliedAmount = srp.Amount.Value; ApplyLists.Add(_al); } _sr.ApplyLists = ApplyLists; _salesReturn.Add(_sr); } if (_salesReturn.Count <= 0) { return("'Null'"); } else { return(JsonConvert.SerializeObject(_salesReturn, Newtonsoft.Json.Formatting.None)); } } catch (Exception) { return(string.Empty); } }
public IActionResult AddSalesReturn([FromBody] SalesReturn model) { model.ReturnNumber = GenRN(); return_repo.Add(model); return(new OkObjectResult(new { SalesReturnID = model.SalesReturnId })); }
private void loadMovement() { movemntkryptonDataGridView.Rows.Clear(); if (m_part.ID == 0) { return; } IList movs = r_part.GetAllEvents(m_part.ID); foreach (EventItem itm in movs) { int r = movemntkryptonDataGridView.Rows.Add(); movemntkryptonDataGridView[dateMovementColumn.Index, r].Value = itm.EVENT.TRANSACTION_DATE; movemntkryptonDataGridView[eventCodeMovementColumn.Index, r].Value = itm.EVENT.CODE; movemntkryptonDataGridView[eventTypeMovementColumn.Index, r].Value = itm.STOCK_CARD_ENTRY_TYPE.ToString(); movemntkryptonDataGridView[QtyMovementColumn.Index, r].Value = itm.GetAmountInSmallestUnit(); movemntkryptonDataGridView[unitMovementColumn.Index, r].Value = m_part.UNIT.CODE; movemntkryptonDataGridView[vendorMovementColumn.Index, r].Value = "-"; switch (itm.STOCK_CARD_ENTRY_TYPE) { case StockCardEntryType.PurchaseOrder: PurchaseOrderItem pi = (PurchaseOrderItem)itm; PurchaseOrder p = (PurchaseOrder)pi.EVENT; p.SUPPLIER = (Supplier)r_sup.GetById(p.SUPPLIER); movemntkryptonDataGridView[vendorMovementColumn.Index, r].Value = p.SUPPLIER.NAME; break; case StockCardEntryType.SalesOrder: SalesOrderItem soi = (SalesOrderItem)itm; SalesOrder so = (SalesOrder)soi.EVENT; so.CUSTOMER = (Customer)r_cus.GetById(so.CUSTOMER); movemntkryptonDataGridView[vendorMovementColumn.Index, r].Value = so.CUSTOMER.NAME; break; case StockCardEntryType.GoodReceiveNote: GoodReceiveNoteItem grni = (GoodReceiveNoteItem)itm; GoodReceiveNote grn = (GoodReceiveNote)grni.EVENT; grn.SUPPLIER = (Supplier)r_sup.GetById(grn.SUPPLIER); movemntkryptonDataGridView[vendorMovementColumn.Index, r].Value = grn.SUPPLIER.NAME; break; case StockCardEntryType.DeliveryOrder: DeliveryOrderItem doi = (DeliveryOrderItem)itm; DeliveryOrder dor = (DeliveryOrder)doi.EVENT; dor.CUSTOMER = (Customer)r_cus.GetById(dor.CUSTOMER); movemntkryptonDataGridView[vendorMovementColumn.Index, r].Value = dor.CUSTOMER.NAME; break; case StockCardEntryType.SupplierInvoice: SupplierInvoiceItem sii = (SupplierInvoiceItem)itm; SupplierInvoice si = (SupplierInvoice)sii.EVENT; si.SUPPLIER = (Supplier)r_sup.GetById(si.SUPPLIER); movemntkryptonDataGridView[vendorMovementColumn.Index, r].Value = si.SUPPLIER.NAME; break; case StockCardEntryType.CustomerInvoice: CustomerInvoiceItem cii = (CustomerInvoiceItem)itm; CustomerInvoice ci = (CustomerInvoice)cii.EVENT; ci.CUSTOMER = (Customer)r_cus.GetById(ci.CUSTOMER); movemntkryptonDataGridView[vendorMovementColumn.Index, r].Value = ci.CUSTOMER.NAME; break; case StockCardEntryType.PurchaseReturn: PurchaseReturnItem pri = (PurchaseReturnItem)itm; PurchaseReturn pr = (PurchaseReturn)pri.EVENT; pr.SUPPLIER = (Supplier)r_sup.GetById(pr.SUPPLIER); movemntkryptonDataGridView[vendorMovementColumn.Index, r].Value = pr.SUPPLIER.NAME; break; case StockCardEntryType.SalesReturn: SalesReturnItem sri = (SalesReturnItem)itm; SalesReturn sr = (SalesReturn)sri.EVENT; sr.CUSTOMER = (Customer)r_cus.GetById(sr.CUSTOMER); movemntkryptonDataGridView[vendorMovementColumn.Index, r].Value = sr.CUSTOMER.NAME; break; } movemntkryptonDataGridView[statusMovementColumn.Index, r].Value = itm.EVENT.POSTED.ToString(); } UserSetting.AddNumberToGrid(movemntkryptonDataGridView); }