private void ShowAllDetails() { try { InvoiceInHeaderDB pdb = new InvoiceInHeaderDB(); invoiceinheader iih = new invoiceinheader(); iih.DocumentID = docID; iih.TemporaryNo = tempno; iih.TemporaryDate = tempdate; invoiceinheader poh = pdb.getFilteredInvoiceInHeaderList(docID, tempno, tempdate).FirstOrDefault(); payList = InvoiceInHeaderDB.getInvoiceInAdvPaymentDetails(tempno, tempdate, docID); decimal TotalAdv = payList.Sum(pay => pay.Amount); expList = InvoiceInHeaderDB.getExpenseDetialForInvoiceIN(iih); decimal TotalExp = expList.Sum(exp => exp.Amount); if (poh != null) { txtDocID.Text = poh.DocumentID; txtMRNno.Text = poh.MRNNo.ToString(); dtMRNDate.Value = poh.MRNDate; txtSupInvceNo.Text = poh.SupplierInvoiceNo.ToString(); dtSuplrInvcDate.Value = poh.SupplierInvoiceDate; txtDocNo.Text = poh.DocumentNo.ToString(); dtDocDate.Value = poh.DocumentDate; cmbCustomer.SelectedIndex = Structures.ComboFUnctions.getComboIndex(cmbCustomer, poh.CustomerID); txtAdvncPaymntVoucher.Text = TotalAdv.ToString(); txtExpenses.Text = TotalExp.ToString(); cmbCurrency.SelectedIndex = Structures.ComboFUnctions.getComboIndex(cmbCurrency, poh.CurrencyID); txtFreightCharge.Text = poh.FreightCharge.ToString(); txtproductValue.Text = poh.ProductValueINR.ToString(); txtTaxvalue.Text = poh.ProductTaxINR.ToString(); txtInvoicevalue.Text = poh.InvoiceValueINR.ToString(); if (poh.PONos != "") { txtPONo.Text = poh.PONos.ToString(); txtPODates.Text = poh.PODates; } } invoiceinheader popd = new invoiceinheader(); popd.DocumentID = docID; popd.TemporaryNo = tempno; popd.TemporaryDate = tempdate; List <invoiceindetail> pod = InvoiceInHeaderDB.getInvoiceDetail(popd); grdPRDetail.Rows.Clear(); int i = 0; double count = 0; foreach (invoiceindetail po in pod) { grdPRDetail.Rows.Add(); grdPRDetail.Rows[i].Cells["LineNo"].Value = grdPRDetail.Rows.Count; grdPRDetail.Rows[i].Cells["Item"].Value = po.StockItemID; grdPRDetail.Rows[i].Cells["ItemDesc"].Value = po.StockItemName; grdPRDetail.Rows[i].Cells["TaxCode"].Value = po.TaxCode; grdPRDetail.Rows[i].Cells["Quantity"].Value = po.Quantity; grdPRDetail.Rows[i].Cells["Price"].Value = po.Price; grdPRDetail.Rows[i].Cells["Tax"].Value = po.Tax; double valu = po.Price * po.Quantity + po.Tax; grdPRDetail.Rows[i].Cells["Value"].Value = valu; count += valu; i++; } txtTotalValue.Text = count.ToString(); } catch (Exception ex) { MessageBox.Show("Error in POOut"); } }
private void grdList_CellContentClick(object sender, DataGridViewCellEventArgs e) { try { if (e.RowIndex < 0) { return; } DocumentUnlockDB dudb = new DocumentUnlockDB(); string columnName = grdList.Columns[e.ColumnIndex].Name; if (columnName.Equals("Unlock")) { prevdc.TemporaryNo = Convert.ToInt32(grdList.Rows[e.RowIndex].Cells["TempNo"].Value); prevdc.TemporaryDate = Convert.ToDateTime(grdList.Rows[e.RowIndex].Cells["TempDate"].Value); prevdc.TableName = grdList.Rows[e.RowIndex].Cells["TableName"].Value.ToString(); string frwdList = grdList.Rows[e.RowIndex].Cells["ForwarderList"].Value.ToString(); if (frwdList == null) { MessageBox.Show("Failed to retrive Forwardlist"); return; } DialogResult dialog = MessageBox.Show("Are you sure to Unlock the document ?\n\nDocument Type\t: " + selectedDocName + "\nTemporary No\t: " + prevdc.TemporaryNo + "\nTemprary Date\t: " + prevdc.TemporaryDate.ToString("yyyy-MM-dd") + "\n" , "Confirmation", MessageBoxButtons.YesNo); if (dialog == DialogResult.No) { return; } string[] strArr = frwdList.Split(Main.delimiter2); int DocStat = strArr.Count(); ////if document is MRN, do not reverse if any issue from the MRN. ////if Invoice out, reverse all quantity before reversing the document if (selectedDocID == "MRN") { if (MRNHeaderDB.checkForIssuesFromMRN(prevdc.TemporaryNo, prevdc.TemporaryDate)) { //no issues (purchase return and Invoice) from MRN MessageBox.Show("Stock has been issued from MRN. Reversal request denied"); return; } else { if (dudb.updateDocForUnlockingMRN(prevdc, DocStat)) { MessageBox.Show("Document Unlocked with Updating Stock sucessfully."); grdList.Rows.RemoveAt(e.RowIndex); return; } else { MessageBox.Show("Document Failed to Unlocked"); return; } } } else if (selectedDocID == "POPRODUCTINWARD" || selectedDocID == "POSERVICEINWARD") { string result = POPIHeaderDB.checkForInvoiceIssuesForPOPI(prevdc.TemporaryNo, prevdc.TemporaryDate, selectedDocID); if (result == "error" || result.Length != 0) { if (result == "error") { return; } //Inivoice Prepared For this PO string InvPrepared = ""; string[] invArr = result.Split(Main.delimiter1); foreach (string str in invArr) { if (str.Length != 0) { string[] invNoDate = str.Split(';'); InvPrepared = InvPrepared + "\nTemporary No: " + invNoDate[0] + " Temporary Date: " + Convert.ToDateTime(invNoDate[1]).ToString("yyyy-MM-dd"); } } MessageBox.Show("Inivoice Prepared For this PO. Reversal request denied.\n" + InvPrepared, "Invoice Prepared Details"); return; } else { if (dudb.updateDocForUnlocking(prevdc, DocStat, selectedDocID)) { MessageBox.Show("PO Document Unlocked"); grdList.Rows.RemoveAt(e.RowIndex); return; } else { MessageBox.Show("Failed to unlock Document"); return; } } } else if (selectedDocID == "PRODUCTINVOICEOUT" || selectedDocID == "PRODUCTEXPORTINVOICEOUT" || selectedDocID == "SERVICEINVOICEOUT" || selectedDocID == "SERVICEEXPORTINVOICEOUT") { invoiceoutheader iohTemp = new invoiceoutheader(); iohTemp.TemporaryNo = prevdc.TemporaryNo; iohTemp.TemporaryDate = prevdc.TemporaryDate; iohTemp.DocumentID = selectedDocID; if (InvoiceOutHeaderDB.isInvoiceOutReceiptPreparedForInvOut(iohTemp)) { MessageBox.Show("Receipt Adjusted against this Invoice . Not allowed to Unlock."); return; } //return; if (dudb.updateDocForUnlockingInvoiceOUT(prevdc, DocStat, selectedDocID)) { if (selectedDocID == "PRODUCTINVOICEOUT" || selectedDocID == "PRODUCTEXPORTINVOICEOUT") { MessageBox.Show("Document Unlocked with Updating Stock sucessfully."); } else { MessageBox.Show("Document Unlocked sucessfully."); } grdList.Rows.RemoveAt(e.RowIndex); return; } else { MessageBox.Show("Document Failed to Unlocked"); return; } } else if (selectedDocID == "GTN") { if (GTNDB.checkForIssuesOfGTNInStock(prevdc.TemporaryNo, prevdc.TemporaryDate)) { //no issues (purchase return and Invoice) from MRN MessageBox.Show("Stock has been issued from GTN. Reversal request denied"); return; } else { if (dudb.updateDocForUnlockingGTN(prevdc, DocStat)) { MessageBox.Show("Document Unlocked with Updating Stock sucessfully."); grdList.Rows.RemoveAt(e.RowIndex); return; } else { MessageBox.Show("Document Failed to Unlocked"); return; } } } else if (selectedDocID == "POINVOICEIN" || selectedDocID == "WOINVOICEIN" || selectedDocID == "POGENERALINVOICEIN") { invoiceinheader iihTemp = new invoiceinheader(); iihTemp.TemporaryNo = prevdc.TemporaryNo; iihTemp.TemporaryDate = prevdc.TemporaryDate; iihTemp.DocumentID = selectedDocID; if (InvoiceInHeaderDB.isInvoiceInPaymentPreparedForInvIN(iihTemp)) { MessageBox.Show("Payment Adjusted against this Invoice . Not allowed to Unlock."); return; } if (dudb.updateDocForUnlockingInvoiceIN(prevdc, DocStat, selectedDocID)) { MessageBox.Show("Document Unlocked"); grdList.Rows.RemoveAt(e.RowIndex); return; } else { MessageBox.Show("Document Failed to Unlocked"); return; } } else if (selectedDocID == "WORKORDER") { workorderheader wohtemp = new workorderheader(); wohtemp.TemporaryNo = prevdc.TemporaryNo; wohtemp.TemporaryDate = prevdc.TemporaryDate; wohtemp.DocumentID = selectedDocID; workorderheader woh = WorkOrderDB.getWONOAndDateOFWO(wohtemp); if (WorkOrderDB.isInvoicePreparedForWO(woh.WONo, woh.WODate)) { MessageBox.Show("invoice received against this work order . Not allowed to Unlock."); return; } if (dudb.updateDocForUnlocking(prevdc, DocStat, selectedDocID)) { MessageBox.Show("Document Unlocked"); grdList.Rows.RemoveAt(e.RowIndex); return; } else { MessageBox.Show("Document Failed to Unlocked"); return; } } else if (selectedDocID == "PURCHASEORDER") { poheader pohtemp = new poheader(); pohtemp.TemporaryNo = prevdc.TemporaryNo; pohtemp.TemporaryDate = prevdc.TemporaryDate; pohtemp.DocumentID = selectedDocID; poheader poh = PurchaseOrderDB.getPONOAndDateOFPOOut(pohtemp); if (PurchaseOrderDB.isMRNPreparedForPO(poh.PONo, poh.PODate)) { MessageBox.Show("MRN received against this Purchase order . Not allowed to Unlock."); return; } if (dudb.updateDocForUnlocking(prevdc, DocStat, selectedDocID)) { MessageBox.Show("Document Unlocked"); grdList.Rows.RemoveAt(e.RowIndex); return; } else { MessageBox.Show("Document Failed to Unlocked"); return; } } else if (selectedDocID == "POGENERAL") { pogeneralheader pohtemp = new pogeneralheader(); pohtemp.TemporaryNo = prevdc.TemporaryNo; pohtemp.TemporaryDate = prevdc.TemporaryDate; pohtemp.DocumentID = selectedDocID; pogeneralheader poh = PurchaseOrderGeneralDB.getPONOAndDateOFPOGen(pohtemp); if (PurchaseOrderGeneralDB.isInvoicePreparedForPOGeneral(poh.PONo, poh.PODate)) { MessageBox.Show("invoice received against this Purchase order . Not allowed to Unlock."); return; } if (dudb.updateDocForUnlocking(prevdc, DocStat, selectedDocID)) { MessageBox.Show("Document Unlocked"); grdList.Rows.RemoveAt(e.RowIndex); return; } else { MessageBox.Show("Document Failed to Unlocked"); return; } } else if (dudb.updateDocForUnlocking(prevdc, DocStat, selectedDocID)) { MessageBox.Show("Document Unlocked"); grdList.Rows.RemoveAt(e.RowIndex); } else { MessageBox.Show("Failed to unlock Document"); } } } catch (Exception ex) { MessageBox.Show("Exception : Failed to unlock Document"); } }
private void ShowAllDetails() { try { if (JVdocID == "PJV") { invoiceinheader iih = new invoiceinheader(); iih.DocumentID = InvDociD; iih.TemporaryNo = InvTemporaryNo; iih.TemporaryDate = InvTemporaryDate; PJVHeader pjvh = PJVDB.getPJVHeaderPerInvoiceIN(iih); if (pjvh.TemporaryNo == 0) { MessageBox.Show("PJV Not prepared"); return; } txtTemporarryNo.Text = pjvh.TemporaryNo.ToString(); dtTempDate.Value = pjvh.TemporaryDate; txtJournalNo.Text = pjvh.JournalNo.ToString(); dtJournalDate.Value = pjvh.JournalDate; txtINVTempNo.Text = pjvh.InvTempNo.ToString(); dtINVTempDate.Value = pjvh.InvTempDate; txtnarration.Text = pjvh.Narration.ToString(); List <PJVDetail> PJVDetail = PJVDB.getPJVDetail(pjvh); grdPRDetail.Rows.Clear(); int i = 0; decimal totCredit = 0; decimal totDebit = 0; foreach (PJVDetail vd in PJVDetail) { AddPRDetailRow(); grdPRDetail.Rows[i].Cells["AccountCode"].Value = vd.AccountCode; grdPRDetail.Rows[i].Cells["AccountName"].Value = vd.AccountName; grdPRDetail.Rows[i].Cells["AmountDebit"].Value = vd.AmountDebit; totDebit = totDebit + vd.AmountDebit; grdPRDetail.Rows[i].Cells["AmountCredit"].Value = vd.AmountCredit; totCredit = totCredit + vd.AmountCredit; grdPRDetail.Rows[i].Cells["PartyCode"].Value = vd.SLCode; grdPRDetail.Rows[i].Cells["PartyName"].Value = vd.SLName; grdPRDetail.Rows[i].Cells["gSLType"].Value = vd.SLType; i++; } txtTotalCreditAmnt.Text = totCredit.ToString(); txtTotalDebitAmnt.Text = totDebit.ToString(); txtAmountInWords.Text = NumberToString.convert(txtTotalDebitAmnt.Text); } else if (JVdocID == "SJV") { invoiceoutheader ioh = new invoiceoutheader(); ioh.DocumentID = InvDociD; ioh.TemporaryNo = InvTemporaryNo; ioh.TemporaryDate = InvTemporaryDate; SJVHeader sjvh = SJVDB.getSJVHeaderPerInvoiceOut(ioh); if (sjvh.TemporaryNo == 0) { MessageBox.Show("SJV Not prepared"); return; } txtTemporarryNo.Text = sjvh.TemporaryNo.ToString(); dtTempDate.Value = sjvh.TemporaryDate; txtJournalNo.Text = sjvh.JournalNo.ToString(); dtJournalDate.Value = sjvh.JournalDate; txtINVTempNo.Text = sjvh.InvTempNo.ToString(); dtINVTempDate.Value = sjvh.InvTempDate; txtnarration.Text = sjvh.Narration.ToString(); List <SJVDetail> SJVdetail = SJVDB.getSJVDetail(sjvh); grdPRDetail.Rows.Clear(); int i = 0; decimal totCredit = 0; decimal totDebit = 0; foreach (SJVDetail vd in SJVdetail) { AddPRDetailRow(); grdPRDetail.Rows[i].Cells["AccountCode"].Value = vd.AccountCode; grdPRDetail.Rows[i].Cells["AccountName"].Value = vd.AccountName; grdPRDetail.Rows[i].Cells["AmountDebit"].Value = vd.AmountDebit; totDebit = totDebit + vd.AmountDebit; grdPRDetail.Rows[i].Cells["AmountCredit"].Value = vd.AmountCredit; totCredit = totCredit + vd.AmountCredit; grdPRDetail.Rows[i].Cells["PartyCode"].Value = vd.SLCode; grdPRDetail.Rows[i].Cells["PartyName"].Value = vd.SLName; grdPRDetail.Rows[i].Cells["gSLType"].Value = vd.SLType; i++; } txtTotalCreditAmnt.Text = totCredit.ToString(); txtTotalDebitAmnt.Text = totDebit.ToString(); txtAmountInWords.Text = NumberToString.convert(txtTotalDebitAmnt.Text); } } catch (Exception ex) { MessageBox.Show("Error in showing details"); } }