public void SetAction(BtnEvent pAction, string pPkValue) { fAction = pAction; switch (fAction) { case BtnEvent.Open: btn_save.Text = "&CLOSE"; obj = CCreditnote_exten.PKId(pPkValue); list = CCreditnoteitems_exten.FKId(pPkValue); this.EnableControls(false); break; case BtnEvent.New: btn_save.Text = "&SAVE"; obj = CCreditnote.GetNew; list = CCreditnoteitems.GetNew; this.EnableControls(true); break; case BtnEvent.Edit: btn_save.Text = "&UPDATE"; obj = CCreditnote_exten.PKId(pPkValue); list = CCreditnoteitems_exten.FKId(pPkValue); this.EnableControls(true); break; case BtnEvent.Delete: btn_save.Text = "CONFIRM\r\n&DELETE"; obj = CCreditnote_exten.PKId(pPkValue); list = CCreditnoteitems_exten.FKId(pPkValue); this.EnableControls(false); break; case BtnEvent.Print: btn_save.Text = "&PRINT"; obj = CCreditnote_exten.PKId(pPkValue); list = CCreditnoteitems_exten.FKId(pPkValue); this.EnableControls(false); print_panel.Show(); break; } LoadData(obj); Loaditems(list); }
private static Print_CreditnoteList ReturnCreditnote(string Id, List <PrintCopies> printcopies) { Creditnote invoice = CCreditnote_exten.PKId(Id); List <Creditnoteitems> invoiceitems = CCreditnoteitems_exten.FKId(Id); Company company = CCompany_exten.PKId(Current.Company_id); Party party = CParty_exten.SearchName(invoice.Party_id, new DAL()); Company_bank cmpbank = CCompany_bank_exten.PKId("1"); Print_CreditnoteList list = new Print_CreditnoteList(); for (int i = 0; i < printcopies.Count; i++) { Print_Creditnote row = new Print_Creditnote(); row.COPY_NAME = printcopies[i].Copies; row.SALES_TYPE = invoice.Salestype_id; row.TAX_TYPE = invoice.Taxtype_id; row.COMPANY_NAME = company.Display_name; row.COMPANY_ADDRESS_1 = company.Street1 + ", " + company.Street2; row.COMPANY_ADDRESS_2 = company.City_id + "- " + company.Pincode_id + ", " + company.State_id + " - (" + Ccoreplus.GetStateCode(company.State_id) + ") . Email :- " + company.Email; row.COMPANY_PHONE = company.Phone; row.COMPANY_CELL1 = company.Cell1; row.COMPANY_CELL2 = company.Cell2; row.COMPANY_EMAIL = company.Email; row.COMPANY_WEBSITE = company.Website; if (company.Gstin.Trim().Length != 0) { row.COMPANY_GSTIN = "GSTIN : " + company.Gstin; if (company.Cell1.Trim().Length != 0) { row.COMPANY_GSTIN = "GSTIN : " + company.Gstin + " , Mobile : " + company.Cell1; if (company.Cell2.Trim().Length != 0) { row.COMPANY_GSTIN = "GSTIN : " + company.Gstin + " , Mobile : " + company.Cell1 + ", " + company.Cell2; } } } else { row.COMPANY_GSTIN = ""; } row.CREDITNOTE_ID = invoice.Creditnote_id; row.CREDITNOTE_NO = ":. " + invoice.Creditnote_no; row.CREDITNOTE_DATE = ": " + ConvertTO.Date2S(invoice.Creditnote_date); row.PARTY_NAME = party.Party_name; row.PARTY_STREET_1 = party.Street_1 + ","; if (party.Street_2.Trim().Length != 0) { row.PARTY_STREET_2 = party.Street_2 + ","; } if (party.Pincode_id.Trim().Length == 6) { row.PARTY_CITY = party.City_id + " - :" + party.Pincode_id + ","; } else { row.PARTY_CITY = party.City_id + ","; } row.PARTY_STATE = party.State_id + " - (" + Ccoreplus.GetStateCode(party.State_id) + ")."; row.PARTY_STATE_CODE = ""; row.PARTY_COUNTRY = party.Country_id; row.PARTY_PINCODE = party.Pincode_id; if (party.Gstin.Trim().Length != 0) { row.PARTY_GSTIN = "GSTIN :" + party.Gstin; } row.TOTAL_QTY = invoice.Total_qty.ToString(); row.TAXABLE_VALUE = invoice.Total_taxable_amount.ToString(); if (Customised.TaxType == Core.SGST) { row.CGST_PERCENT = " Add CGST " + (invoiceitems[0].Cgst_percent.ToString()) + " %"; row.SGST_PERCENT = " Add SGST " + (invoiceitems[0].Sgst_percent.ToString()) + " %"; row.TOTAL_CGST = invoice.Total_cgst.ToString(); row.TOTAL_SGST = invoice.Total_sgst.ToString(); } else if (Customised.TaxType == Core.IGST) { row.CGST_PERCENT = ""; row.SGST_PERCENT = " Add IGST " + (invoiceitems[0].Igst_percent.ToString()) + " %"; row.TOTAL_CGST = ""; row.TOTAL_SGST = invoice.Total_igst.ToString(); } row.TOTAL_SUB = invoice.Grandtotal.ToString(); row.LEDGER = CLedger_exten.GetName_Id(invoice.Ledger_id); if (invoice.Additional != 0) { row.ADDITIONAL = invoice.Additional.ToString(); } else { row.ADDITIONAL = ""; } row.ROUNDS = invoice.Rounds.ToString(); row.GSTTOTAL = invoice.Gsttotal.ToString(); row.GRANDTOTAL = invoice.Grandtotal.ToString(); row.AMOUNT_IN_WORDS = "Rupees : " + Global.AmountInWords(invoice.Grandtotal); row.NOTES = invoice.Notes; row.ENTRY_BY = invoice.User_id; row.FORSIGN = company.Display_name; if (Customised.InvoiceWithBankDetails) { row.ACCOUNT_NO = "A/C NO : " + cmpbank.Account_number; row.IFSC_CODE = "IFSC CODE : " + cmpbank.Ifsc_code; row.BANK_NAME = "BANK NAME : " + cmpbank.Company_bank_name; row.BRANCH = "BRANCH : " + cmpbank.Branch_name; } else { row.ACCOUNT_NO = ""; row.IFSC_CODE = ""; row.BANK_NAME = ""; row.BRANCH = ""; } row.TERMS_1 = Message.TERMS_1; row.TERMS_2 = Message.TERMS_2; row.TERMS_3 = Message.TERMS_3; row.TERMS_4 = Customised.Terms_4; list.Add(row); } return(list); }
private void Save_Event(string info) { if (Validation() != false) { switch (fAction) { case BtnEvent.Open: if (info != Core.saveprint) { this.Hide(); Form_NeedToRefresh(); } else { Print_copies(); this.Hide(); Form_NeedToRefresh(); } break; case BtnEvent.New: try { var vData = CollectData(); dalsession = new DAL(); dalsession.BeginTransaction(); CCreditnote.Insert(vData, dalsession); vId = DAL.GetIdentity(dalsession); var itemsList = Collectitems(vId); CCreditnoteitems.Insert(itemsList, dalsession); //if (Customise.Creditnote_poid_dcid == true) //{ // //CDc_refered.Refered(itemsList, itemsList, dalsession); //} dalsession.Commit(); if (info != Core.saveprint) { MessageBox.Show(this.FindForm(), "Record Saved Successfully.", "Save...", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); } else { Print_copies(); this.Hide(); Form_NeedToRefresh(); } //this.Hide(); //Form_NeedToRefresh(); SetAction(BtnEvent.New, null); txt_invoice_no.Focus(); } catch (Exception ex) { if (dalsession != null) { dalsession.Rollback(); } MessageBox.Show(this.FindForm(), "Something Goes Wrong \r\n" + ex.Message, "Could Not Save...", MessageBoxButtons.OK, MessageBoxIcon.Error); SetFocus(); return; } break; case BtnEvent.Edit: try { var vData = CollectData(); dalsession = new DAL(); dalsession.BeginTransaction(); var olditemslist = CCreditnoteitems_exten.FK_withoutJoin(vId, new DAL()); CCreditnoteitems.Delete(vId, dalsession); CCreditnote.Update(vData, dalsession); var itemsList = Collectitems(vId); CCreditnoteitems.Insert(itemsList, dalsession); //if (Customise.Creditnote_poid_dcid == true) //{ // CDc_refered.Refered(itemsList, olditemslist, dalsession); //} dalsession.Commit(); if (info != Core.saveprint) { MessageBox.Show(this.FindForm(), "Record Updated Successfully.", "Update...", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); } else { Print_copies(); } this.Hide(); Form_NeedToRefresh(); } catch (Exception ex) { if (dalsession != null) { dalsession.Rollback(); } MessageBox.Show(this.FindForm(), "Something Goes Wrong \r\n" + ex.Message, "Could Not Update...", MessageBoxButtons.OK, MessageBoxIcon.Error); SetFocus(); return; } break; case BtnEvent.Delete: try { dalsession = new DAL(); dalsession.BeginTransaction(); CCreditnoteitems.Delete(vId, dalsession); CCreditnote.Delete(vId, dalsession); var olditemslist = CCreditnoteitems_exten.FK_withoutJoin(vId, new DAL()); //if (Customise.Creditnote_poid_dcid == true) //{ // CDc_refered.Refered(olditemslist, olditemslist, dalsession); //} dalsession.Commit(); MessageBox.Show(this.FindForm(), "Record Deleted Successfully.", "Delete...", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); this.Hide(); Form_NeedToRefresh(); } catch (Exception ex) { if (dalsession != null) { dalsession.Rollback(); } MessageBox.Show(this.FindForm(), "Something Goes Wrong \r\n" + ex.Message, "Could Not Update...", MessageBoxButtons.OK, MessageBoxIcon.Error); SetFocus(); return; } break; case BtnEvent.Print: Print_copies(); this.Hide(); Form_NeedToRefresh(); break; } } }
public static Print_invoiceItemsList GetData(string p_id) { Print_invoiceItemsList list = new Print_invoiceItemsList(); // List <Creditnoteitems> inv_item_list = new List <Creditnoteitems>(); inv_item_list = CCreditnoteitems_exten.FKId(p_id); for (int r = 0; r <= inv_item_list.Count - 1; r++) { Print_invoiceitemsRow row = new Print_invoiceitemsRow(); // row.CREDITNOTE_ITEM_ID = inv_item_list[r].Creditnoteitems_id; row.CREDITNOTE_ID = inv_item_list[r].Creditnote_id; row.SL_NO = (r + 1).ToString(); row.PO_NO = inv_item_list[r].Po_no + ""; row.DC_NO = inv_item_list[r].Dc_no + ""; row.PRODUCT_ID = Checks.RemoveEscape(inv_item_list[r].Product_id + ""); row.HSN_CODE_ID = Ccoreplus.GetHsncode_name(inv_item_list[r].Product_id); if (inv_item_list[r].Sizes_id == "") { row.SIZES = ""; } else { row.SIZES = inv_item_list[r].Sizes_id + ""; } if (inv_item_list[r].Colours_id == "") { row.COLOURS = ""; } else { row.COLOURS = inv_item_list[r].Colours_id + ""; } if (inv_item_list[r].Qty == "0") { row.QTY = ""; } else { row.QTY = inv_item_list[r].Qty.ToString(); } if (inv_item_list[r].Price == 0) { row.PRICE = ""; } else { row.PRICE = ConvertTO.Decimal2d(inv_item_list[r].Price.ToString()); } decimal vAmount = 0M; decimal vTaxableValue = 0M; decimal vQty = ConvertTO.Decimal(row.QTY); decimal vPrice = Global.ToDecimal(row.PRICE); decimal vcgst_per = Global.ToDecimal(inv_item_list[r].Cgst_percent); decimal vsgst_per = Global.ToDecimal(inv_item_list[r].Sgst_percent); decimal vigst_per = Global.ToDecimal(inv_item_list[r].Igst_percent); vTaxableValue = vQty * vPrice; decimal vCGST = decimal.Round(((vTaxableValue * vcgst_per) / 100), 2); decimal vSGST = decimal.Round(((vTaxableValue * vsgst_per) / 100), 2); decimal vIGST = decimal.Round(((vTaxableValue * vigst_per) / 100), 2); vAmount = vTaxableValue + vCGST + vSGST + vIGST; if (vTaxableValue == 0) { row.TAXABLEVALUE = ""; } else { row.TAXABLEVALUE = ConvertTO.Decimal2d(vTaxableValue.ToString()); } if (vcgst_per == 0) { row.CGST_PERCENT = ""; } else { row.CGST_PERCENT = ConvertTO.DecimalToS(vcgst_per.ToString()); } if (vCGST == 0) { row.CGST_AMOUNT = ""; } else { row.CGST_AMOUNT = ConvertTO.Decimal2d(vCGST.ToString()); } if (vsgst_per == 0) { row.SGST_PERCENT = ""; } else { row.SGST_PERCENT = ConvertTO.DecimalToS(vsgst_per.ToString()); } if (vSGST == 0) { row.SGST_AMOUNT = ""; } else { row.SGST_AMOUNT = ConvertTO.Decimal2d(vSGST.ToString()); } if (vigst_per == 0) { row.IGST_PERCENT = ""; } else { row.IGST_PERCENT = ConvertTO.DecimalToS(vigst_per.ToString()); } if (vIGST == 0) { row.IGST_AMOUNT = ""; } else { row.IGST_AMOUNT = ConvertTO.Decimal2d(vIGST.ToString()); } if (vAmount == 0) { row.SUB_TOTAL = ""; } else { row.SUB_TOTAL = ConvertTO.Decimal2d(vAmount.ToString()); } // list.Add(row); // } // return(list); }