internal int InsertCustomerInvoiceItem(CustomerInvoiceItem item, IDbConnection connection, IDbTransaction txn) { try { string sql = @"insert into CustomerInvoiceItem(CustInvoiceId,ProjectId,PaymentScheduleid,ScheduledAmount,InvoiceAmount) Values (@CustInvoiceId,@ProjectId,@Paymentid,@Amount,@InvoiceAmount); SELECT CAST(SCOPE_IDENTITY() as int)"; var id = connection.Query <int>(sql, item, txn).FirstOrDefault(); return(id); } catch (Exception) { throw; } }
private IList getItems() { IList items = new ArrayList(); for (int i = 0; i < itemsDataGrid.Rows.Count; i++) { Part p = (Part)itemsDataGrid[codeColumn.Index, i].Tag; if (itemsDataGrid[unitColumn.Index, i].Value == null) { continue; } Unit u = (Unit)Utils.FindEntityInList(itemsDataGrid[unitColumn.Index, i].Value.ToString(), m_units); if ((p == null) || (u == null)) { continue; } CustomerInvoiceItem st = (CustomerInvoiceItem)itemsDataGrid.Rows[i].Tag; if (st == null) { st = new CustomerInvoiceItem(); } itemsDataGrid.Rows[i].Tag = st; st.EVENT = m_si; st.PART = p; st.WAREHOUSE = (Warehouse)Utils.FindEntityInList(itemsDataGrid[warehouseColumn.Index, i].Value.ToString(), m_warehouses); st.QYTAMOUNT = Convert.ToDouble(itemsDataGrid[QtyColumn.Index, i].Value); st.UNIT = u; st.PRICE = Convert.ToDouble(itemsDataGrid[priceColumn.Index, i].Value); st.DISC_PERCENT = Convert.ToDouble(itemsDataGrid[discpercentColumn.Index, i].Value); st.DISC_AMOUNT = Convert.ToDouble(itemsDataGrid[discAmountColumn.Index, i].Value); st.TOTAL_DISCOUNT = Convert.ToDouble(itemsDataGrid[totalDiscColumn.Index, i].Value); st.NOTES = itemsDataGrid[notesColumn.Index, i].Value == null ? "" : itemsDataGrid[notesColumn.Index, i].Value.ToString(); st.DISC_ABC = itemsDataGrid[discabcColumn.Index, i].Value == null ? "" : itemsDataGrid[discabcColumn.Index, i].Value.ToString(); st.DISC_A = splitDiscString(st.DISC_ABC, 0); st.DISC_B = splitDiscString(st.DISC_ABC, 1); st.DISC_C = splitDiscString(st.DISC_ABC, 2); st.SUBTOTAL = Convert.ToDouble(itemsDataGrid[totalAmountColumn.Index, i].Value); DeliveryOrderItem grn = (DeliveryOrderItem)itemsDataGrid[GRNNoColumn.Index, i].Tag; st.DO_ITEM = grn; if (st.QYTAMOUNT == 0) { continue; } items.Add(st); } return(items); }
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); }
public ActionResult Print(int Id) { ReportDocument rd = new ReportDocument(); rd.Load(Path.Combine(Server.MapPath("~/Reports"), "CustomerInvoice.rpt")); DataSet ds = new DataSet(); ds.Tables.Add("Head"); ds.Tables.Add("Items"); // //-------HEAD ds.Tables["Head"].Columns.Add("DocumentNo"); ds.Tables["Head"].Columns.Add("DocumentDate"); ds.Tables["Head"].Columns.Add("Location"); ds.Tables["Head"].Columns.Add("InsuredName"); ds.Tables["Head"].Columns.Add("SpecialRemarks"); //-------DT ds.Tables["Items"].Columns.Add("EffectiveDate"); ds.Tables["Items"].Columns.Add("InsuranceType"); ds.Tables["Items"].Columns.Add("PolicyOrEndorseNo"); ds.Tables["Items"].Columns.Add("Company"); ds.Tables["Items"].Columns.Add("Premium"); ds.Tables["Items"].Columns.Add("Remarks"); CustomerInvoiceRepository repo = new CustomerInvoiceRepository(); var Head = repo.GetCustomerInvoiceHdDetails(Id); DataRow dr = ds.Tables["Head"].NewRow(); dr["DocumentNo"] = Head.CusInvoiceRefNo; dr["DocumentDate"] = Head.CusInvoiceDate.Value.ToString("dd-MMM-yyyy"); dr["InsuredName"] = Head.CusName; dr["SpecialRemarks"] = Head.SpecialRemarks; ds.Tables["Head"].Rows.Add(dr); var Items = repo.GetCustomerInvoicePrint(Id); foreach (var item in Items) { var CustomerInvoiceItem = new CustomerInvoiceItem { EffectiveDate = item.EffectiveDate, TranType = item.TranType, PolicyNo = item.PolicyNo, InsCmpName = item.InsCmpName, TotalPremium = item.TotalPremium, Remarks = item.Remarks }; DataRow dri = ds.Tables["Items"].NewRow(); dri["EffectiveDate"] = CustomerInvoiceItem.EffectiveDate.Value.ToString("dd-MMM-yyyy"); dri["InsuranceType"] = CustomerInvoiceItem.TranType; dri["PolicyOrEndorseNo"] = CustomerInvoiceItem.PolicyNo; dri["Company"] = CustomerInvoiceItem.InsCmpName; dri["Premium"] = CustomerInvoiceItem.TotalPremium; dri["Remarks"] = CustomerInvoiceItem.Remarks; ds.Tables["Items"].Rows.Add(dri); } ds.WriteXml(Path.Combine(Server.MapPath("~/XML"), "CustomerInvoice.xml"), XmlWriteMode.WriteSchema); rd.SetDataSource(ds); Response.Buffer = false; Response.ClearContent(); Response.ClearHeaders(); try { Stream stream = rd.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat); stream.Seek(0, SeekOrigin.Begin); return(File(stream, "application/pdf")); } catch (Exception ex) { throw; } }