Esempio n. 1
0
        private void addGridRows()
        {
            string str = "";

            for (int i = 0; i < Headers.Length; i++)
            {
                switch (i)
                {
                case 0:
                    str = POPIHeaderDB.getPOPIDtlsForProjectTrans(txtProjectID.Text);
                    break;

                case 1:
                    str = WorkOrderDB.getWODtlsForProjectTrans(txtProjectID.Text);
                    break;

                case 2:
                    str = InvoiceOutHeaderDB.getIOHDtlsForProjectTrans(txtProjectID.Text);
                    break;

                case 3:
                    str = PaymentVoucherDB.getPVHDtlsForProjectTrans(txtProjectID.Text, 1);
                    break;

                case 4:
                    str = PaymentVoucherDB.getPVHDtlsForProjectTrans(txtProjectID.Text, 2);
                    break;

                case 5:
                    str = "";
                    break;

                case 6:
                    str = PaymentVoucherDB.getPVHDtlsForProjectTrans(txtProjectID.Text, 3);
                    break;

                case 7:
                    str = ReceiptVoucherDB.getRVDtlsForProjectTrans(txtProjectID.Text);
                    break;

                default:
                    break;
                }

                if (str.Length != 0)
                {
                    grdMainList.Rows.Add();
                    grdMainList.Rows[grdMainList.RowCount - 1].Cells["Received"].Value = Headers[i];
                    grdMainList.Rows[grdMainList.RowCount - 1].Cells["gNo"].Value      = str.Substring(0, str.IndexOf('-'));
                    grdMainList.Rows[grdMainList.RowCount - 1].Cells["Value"].Value    = str.Substring(str.IndexOf('-') + 1);
                }
                else
                {
                    grdMainList.Rows.Add();
                    grdMainList.Rows[grdMainList.RowCount - 1].Cells["Received"].Value = Headers[i];
                    grdMainList.Rows[grdMainList.RowCount - 1].Cells["gNo"].Value      = "0";
                    grdMainList.Rows[grdMainList.RowCount - 1].Cells["Value"].Value    = "0";
                }
            }
        }
Esempio n. 2
0
        public Boolean updateDocForUnlockingInvoiceOUT(DocUnlock du, int docStat, string docID)
        {
            Boolean status   = true;
            string  utString = "";

            try
            {
                string updateSQL = "update " + du.TableName +
                                   " set Status = 96,ApproveUser=NULL,DocumentStatus= " + docStat +
                                   " where TemporaryNo = " + du.TemporaryNo +
                                   " and TemporaryDate = '" + du.TemporaryDate.ToString("yyyy-MM-dd") + "' and DocumentID = '" + docID + "'";
                utString = utString + updateSQL + Main.QueryDelimiter;
                utString = utString +
                           ActivityLogDB.PrepareActivityLogQquerString("update", du.TableName, "", updateSQL) +
                           Main.QueryDelimiter;
                InvoiceOutHeaderDB ionDB = new InvoiceOutHeaderDB();
                if (docID == "PRODUCTINVOICEOUT" || docID == "PRODUCTEXPORTINVOICEOUT")
                {
                    invoiceoutheader ioh = new invoiceoutheader();
                    ioh.DocumentID    = docID;
                    ioh.TemporaryNo   = du.TemporaryNo;
                    ioh.TemporaryDate = du.TemporaryDate;
                    List <invoiceoutdetail> IOList = InvoiceOutHeaderDB.getInvoiceOutDetail(ioh);
                    foreach (invoiceoutdetail iod in IOList)
                    {
                        updateSQL = "update stock set PresentStock = ((select PresentStock from Stock where RowID = " + iod.StockReferenceNo + ")+" + iod.Quantity + ")," +
                                    " IssueQuantity =  ((select IssueQuantity from Stock where RowID = " + iod.StockReferenceNo + ")-" + iod.Quantity + ")" +
                                    " where RowID = " + iod.StockReferenceNo;
                        utString = utString + updateSQL + Main.QueryDelimiter;
                        utString = utString +
                                   ActivityLogDB.PrepareActivityLogQquerString("update", "Stock", "", updateSQL) +
                                   Main.QueryDelimiter;
                    }
                }
                //Updating SJVHeader
                updateSQL = "update SJVHeader " +
                            " set Status = 96,ApproveUser=NULL,DocumentStatus= 1" +
                            " where InvTempNo = " + du.TemporaryNo +
                            " and InvTempDate = '" + du.TemporaryDate.ToString("yyyy-MM-dd") + "' and InvDocumentID = '" + docID + "'";
                utString = utString + updateSQL + Main.QueryDelimiter;
                utString = utString +
                           ActivityLogDB.PrepareActivityLogQquerString("update", "SJVHeader", "", updateSQL) +
                           Main.QueryDelimiter;
                //return false;
                if (!UpdateTable.UT(utString))
                {
                    status = false;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(this.ToString() + "-" + System.Reflection.MethodBase.GetCurrentMethod().Name + "() : Error");
                status = false;
            }
            return(status);
        }
        public static ListView getInvoiceOutListView()
        {
            ListView lv = new ListView();

            try
            {
                lv.View               = View.Details;
                lv.LabelEdit          = true;
                lv.AllowColumnReorder = true;
                lv.CheckBoxes         = true;
                lv.FullRowSelect      = true;
                lv.GridLines          = true;
                lv.Sorting            = System.Windows.Forms.SortOrder.Ascending;
                InvoiceOutHeaderDB      IODB   = new InvoiceOutHeaderDB();
                List <invoiceoutheader> IOList = IODB.getinvoiceforproduct();
                ////int index = 0;
                lv.Columns.Add("Select", -2, HorizontalAlignment.Left);
                lv.Columns.Add("DocumentID", -2, HorizontalAlignment.Left);
                lv.Columns.Add("Document Name", -2, HorizontalAlignment.Left);
                lv.Columns.Add("Invoice No", -2, HorizontalAlignment.Left);
                lv.Columns.Add("Invoice Date", -2, HorizontalAlignment.Left);
                lv.Columns.Add("Consignee", -2, HorizontalAlignment.Left);
                lv.Columns.Add("Invoice Amount", -2, HorizontalAlignment.Left);
                foreach (invoiceoutheader ioh in IOList)
                {
                    ListViewItem item1 = new ListViewItem();
                    item1.Checked = false;
                    item1.SubItems.Add(ioh.DocumentID.ToString());
                    item1.SubItems.Add(ioh.DocumentName.ToString());
                    item1.SubItems.Add(ioh.InvoiceNo.ToString());
                    item1.SubItems.Add(ioh.InvoiceDate.ToString());
                    item1.SubItems.Add(ioh.ConsigneeID + "-" + ioh.ConsigneeName);
                    item1.SubItems.Add(ioh.InvoiceAmount.ToString());
                    lv.Items.Add(item1);
                }
            }
            catch (Exception)
            {
            }
            return(lv);
        }
Esempio n. 4
0
        private void btnView_Click(object sender, EventArgs e)
        {
            try
            {
                txtTotalPOValue.Text      = "";
                txtTotalInvoiceValue.Text = "";
                showGridColumns();
                if (rdbNormal.Checked != true && rdbLakhs.Checked != true && rdbThousands.Checked != true)
                {
                    rdbNormal.Checked = true;
                }
                POPIHeaderDB       RPODb = new POPIHeaderDB();
                InvoiceOutHeaderDB IODb = new InvoiceOutHeaderDB();
                DateTime           fromDate = dtFromDate.Value;
                DateTime           toDate = dtToDate.Value;
                int opt1 = 0; int opt2 = 0; int opt3 = 0; int opt4 = 0;
                // opt1 : PO Wise , opt2 : Sevice Wise  , opt3 : Party Wise ,  opt4 : Region WIse
                party  = 0;
                region = 0;
                if (chkProductPO.Checked == true)
                {
                    opt1 = 1;
                }
                if (chkservicePO.Checked == true)
                {
                    opt2 = 1;
                }
                if (chkPartWise.Checked == true)
                {
                    opt3  = 1;
                    party = 1;
                }
                if (chkRegionWise.Checked == true)
                {
                    opt4   = 1;
                    region = 1;
                }
                if (opt1 != 1 && opt2 != 1)
                {
                    MessageBox.Show("select PO Type");
                    return;
                }
                if (opt3 == 1 && opt4 == 1)
                {
                    MessageBox.Show("Either select party or region.");
                    return;
                }
                if (opt3 == 1 || opt4 == 1)
                {
                    if (opt3 == 1)
                    {
                        grdDetailList.Columns["gRegion"].Visible = false;
                        PODetailList = RPODb.getPODetailForpartWise(opt1, opt2, fromDate, toDate);
                        List <ReportPO> IODetailList1 = IODb.getIODetailForpartWise(opt1, opt2, fromDate, toDate);
                        InvoiceDetailList = getInvoiceDetailListGroupByFilter(IODetailList1, 1);
                    }
                    else
                    {
                        grdDetailList.Columns["gParty"].Visible = false;
                        PODetailList = RPODb.getDetailForRegionWise(opt1, opt2, fromDate, toDate);
                        List <ReportPO> IODetailList1 = IODb.getIODetailForRegionWise(opt1, opt2, fromDate, toDate);
                        InvoiceDetailList = getInvoiceDetailListGroupByFilter(IODetailList1, 2);
                    }
                }
                else if (opt1 == 1 || opt2 == 1)
                {
                    grdDetailList.Columns["gRegion"].Visible = false;
                    grdDetailList.Columns["gParty"].Visible  = false;
                    PODetailList = RPODb.getDetailForDocumentWise(opt1, opt2, fromDate, toDate);

                    List <ReportPO> IODetailList1 = IODb.getIODetailForDocumentWise(opt1, opt2, fromDate, toDate);
                    InvoiceDetailList = getInvoiceDetailListGroupByFilter(IODetailList1, 3);
                }
                else
                {
                    MessageBox.Show("Select one ");
                    return;
                }


                //foreach (ReportPO rpo in InvoiceDetailList)
                //{
                //    var sel =
                //}
                txtTotalPOValue.Visible      = true;
                lblPOTotal.Visible           = true;
                txtTotalInvoiceValue.Visible = true;
                lblInvoiceTotal.Visible      = true;
                grdDetailList.Visible        = true;
                btnClose.Visible             = true;
                //btnShowChart.Visible = true;
                addItemsInGridDetail(PODetailList, InvoiceDetailList);
            }
            catch (Exception ex)
            {
            }
        }
Esempio n. 5
0
        public void PrintIO(invoiceoutheader ioh, List <invoiceoutdetail> IODetails, string taxStr, string podocID)
        {
            try
            {
                Dictionary <string, string> companyInfo = getCompanyInformation();
                string[] pos        = ioh.TrackingNos.Split(';');
                int      b          = 0;
                int[]    a          = (from s in pos where int.TryParse(s, out b) select b).ToArray();
                int      min        = a.Min();
                string[] dates      = ioh.TrackingDates.Split(';');
                string   poStr      = "";
                string   billingAdd = "";
                string   othRef     = "";
                for (int i = 0; i < pos.Length - 1; i++)
                {
                    string   custPOStr = POPIHeaderDB.getCustomerPOAndDateForInvoiceOut(Convert.ToInt32(pos[i]), Convert.ToDateTime(dates[i]), podocID);
                    string[] custPO    = custPOStr.Split(Main.delimiter1);
                    ////if (Convert.ToInt32(pos[i]) == min)
                    ////billingAdd = custPO[2];
                    poStr  = poStr + custPO[0] + ", Date: " + String.Format("{0:dd MMMM, yyyy}", Convert.ToDateTime(custPO[1])) + "\n";
                    othRef = othRef + pos[i] + ",";
                }
                companybank cb         = CompanyBankDB.getCompBankDetailForIOPrint(ioh.BankAcReference);
                customer    custDetail = CustomerDB.getCustomerDetailForPO(ioh.ConsigneeID);

                string[] companyBillingAdd = CompanyAddressDB.getCompTopBillingAdd(Login.companyID);
                string   ConsgAdd          = "Consignee:\n" + custDetail.name + Main.delimiter2 + "\n" + ioh.DeliveryAddress + "\n";
                string   buyer             = "Buyer:\n" + custDetail.name + Main.delimiter2 + "\n" + custDetail.BillingAddress + "\n";
                if (custDetail.StateName.ToString().Length != 0)
                {
                    ConsgAdd = ConsgAdd + "Sate Name:" + custDetail.StateName;
                    buyer    = buyer + "Sate Name:" + custDetail.StateName;
                    if (custDetail.StateCode.ToString().Length != 0)
                    {
                        ConsgAdd = ConsgAdd + " ,\nState Code:" + custDetail.StateCode;
                        buyer    = buyer + " ,\nState Code:" + custDetail.StateCode;
                    }
                }
                else
                {
                    if (custDetail.StateCode.ToString().Length != 0)
                    {
                        ConsgAdd = ConsgAdd + "\nState Code:" + custDetail.StateCode;
                        buyer    = buyer + "\nState Code:" + custDetail.StateCode;
                    }
                }
                if (custDetail.OfficeName.ToString().Length != 0)
                {
                    ConsgAdd = ConsgAdd + "\nGST:" + custDetail.OfficeName; // For GST Code
                    buyer    = buyer + "\nGST:" + custDetail.OfficeName;    // For GST Code
                }
                if (CustomerDB.getCustomerPANForInvoicePrint(ioh.ConsigneeID).Length != 0)
                {
                    ConsgAdd = ConsgAdd + "\nPAN:" + custDetail.OfficeName; // For PAN Code
                    buyer    = buyer + "\nPAN:" + custDetail.OfficeName;    // For PAN Code
                }

                string HeaderString = buyer +

                                      Main.delimiter1 + "Invoice No : " + ioh.InvoiceNo + " , Date: " + String.Format("{0:dd MMMM, yyyy}", ioh.InvoiceDate) +
                                      Main.delimiter1 + "Buyer's Reference : " + poStr.Trim() +
                                      Main.delimiter1 + "Mode of Dispatch : " + ioh.TransportationModeName +
                                      Main.delimiter1 + "Terms of Payment : " + ioh.TermsOfPayment + Main.delimiter1 + //Description : Name of terms of payment

                                      ConsgAdd +

                                      Main.delimiter1 + "Supplier's Reference : " + othRef.Trim().Substring(0, othRef.Length - 1) +
                                      Main.delimiter1 + "Reverse Charge : " + ioh.ReverseCharge +
                                      Main.delimiter1 + ioh.SpecialNote;

                string footer1   = "Amount in words\n\n";
                string ColHeader = "";
                if (ioh.DocumentID == "PRODUCTINVOICEOUT" || ioh.DocumentID == "PRODUCTEXPORTINVOICEOUT")
                {
                    ColHeader = "SI No.;Description of Goods;HSN;Quantity;Unit;Unit Rate;Amount";
                }
                else
                {
                    ColHeader = "SI No.;Description of Goods;SAC;Quantity;Unit;Unit Rate;Amount";
                }
                CompanyDetailDB compDB   = new CompanyDetailDB();
                cmpnydetails    det      = compDB.getdetails().FirstOrDefault(comp => comp.companyID == 1);
                string          compName = "";
                if (det != null)
                {
                    compName = det.companyname;
                }
                string footer2 = "\n\nAccount Name : " + compName + "\nAccount No : " + cb.AccountCode + "\nAccount Type : " + cb.AccountType + "\nBank : " + cb.BankName + "\nBranch : " + cb.BranchName + "\nIFSC : " + cb.CreateUser;
                //"\nSWIFT Code : " + cb.CompanyID +
                string footer3         = "For Cellcomm Solutions Limited;Authorised Signatory";
                double totQuant        = 0.00;
                double totAmnt         = 0.00;
                int    n               = 1;
                string ColDetailString = "";
                var    count           = IODetails.Count();

                foreach (invoiceoutdetail iod in IODetails)
                {
                    if (ioh.DocumentID == "PRODUCTINVOICEOUT")
                    {
                        iod.HSNCode = iod.HSNCode.Substring(0, 4);
                    }
                    else if (ioh.DocumentID == "SERVICEINVOICEOUT")
                    {
                        iod.HSNCode = iod.HSNCode.Substring(0, 6);
                    }
                    if (n == count)
                    {
                        //if (ioh.DocumentID == "PRODUCTINVOICEOUT")
                        ColDetailString = ColDetailString + n + Main.delimiter1 + iod.CustomerItemDescription + Main.delimiter1 + iod.HSNCode + Main.delimiter1 + iod.Quantity + Main.delimiter1
                                          + iod.Unit + Main.delimiter1 + iod.Price + Main.delimiter1 + (iod.Quantity * iod.Price);
                        //else
                        //    ColDetailString = ColDetailString + n + Main.delimiter1 + iod.CustomerItemDescription + Main.delimiter1 + iod.HSNCode.Substring(0, 4) + Main.delimiter1 + iod.Quantity + Main.delimiter1
                        //                   + iod.Price + Main.delimiter1 + (iod.Quantity * iod.Price);
                    }
                    else
                    {
                        //if (ioh.DocumentID == "PRODUCTINVOICEOUT")
                        ColDetailString = ColDetailString + n + Main.delimiter1 + iod.CustomerItemDescription + Main.delimiter1 + iod.HSNCode + Main.delimiter1 + iod.Quantity + Main.delimiter1
                                          + iod.Unit + Main.delimiter1 + iod.Price + Main.delimiter1 + (iod.Quantity * iod.Price) + Main.delimiter2;
                        //else
                        //    ColDetailString = ColDetailString + n + Main.delimiter1 + iod.CustomerItemDescription + Main.delimiter1 + iod.HSNCode.Substring(0, 4) + Main.delimiter1 + iod.Quantity + Main.delimiter1
                        //                   + iod.Price + Main.delimiter1 + (iod.Quantity * iod.Price) + Main.delimiter2;
                    }
                    totQuant = totQuant + iod.Quantity;
                    totAmnt  = totAmnt + (iod.Quantity * iod.Price);
                    n++;
                }

                try
                {
                    SaveFileDialog sfd = new SaveFileDialog();
                    sfd.Title            = "Save As PDF";
                    sfd.Filter           = "Pdf files (*.Pdf)|*.pdf";
                    sfd.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
                    if (ioh.status == 0 && ioh.DocumentStatus < 99)
                    {
                        sfd.FileName = ioh.DocumentID + "-Temp-" + ioh.TemporaryNo;
                    }
                    else
                    {
                        sfd.FileName = ioh.DocumentID + "-" + ioh.InvoiceNo;
                    }

                    if (sfd.ShowDialog() == DialogResult.Cancel || sfd.FileName == "")
                    {
                        return;
                    }
                    FileStream fs  = new FileStream(sfd.FileName, FileMode.Create, FileAccess.Write);
                    Rectangle  rec = new Rectangle(PageSize.A4);
                    rec.Bottom = 10;
                    iTextSharp.text.Document doc = new iTextSharp.text.Document(rec);
                    PdfWriter writer             = PdfWriter.GetInstance(doc, fs);
                    MyEvent   evnt = new MyEvent();
                    writer.PageEvent = evnt;

                    doc.Open();
                    Font font1 = FontFactory.GetFont("Arial", 8, iTextSharp.text.Font.NORMAL, BaseColor.BLACK);
                    Font font2 = FontFactory.GetFont("Arial", 8, iTextSharp.text.Font.BOLD, BaseColor.BLACK);
                    Font font3 = FontFactory.GetFont("Arial", 8, iTextSharp.text.Font.ITALIC, BaseColor.BLACK);
                    Font font4 = FontFactory.GetFont("Arial", 5, iTextSharp.text.Font.NORMAL, BaseColor.BLACK);

                    String URL = "Cellcomm2.JPG";
                    iTextSharp.text.Image img = iTextSharp.text.Image.GetInstance(URL);
                    img.Alignment = Element.ALIGN_LEFT;

                    PdfPTable tableHeader = new PdfPTable(2);

                    tableHeader.WidthPercentage = 100;
                    PdfPCell  cellImg = new PdfPCell();
                    Paragraph pp      = new Paragraph();
                    pp.Add(new Chunk(img, 0, 0));
                    cellImg.AddElement(pp);
                    cellImg.Border = 0;
                    tableHeader.AddCell(cellImg);

                    PdfPCell  cellAdd = new PdfPCell();
                    Paragraph ourAddr = new Paragraph("");

                    if (det != null)
                    {
                        ourAddr.Add(new Chunk(det.companyname + "\n", font2));
                        ourAddr.Add(new Chunk(det.companyAddress.Replace("\r\n", "\n"), font4));
                        StringBuilder sb = new StringBuilder();
                        sb.Append("\nGST : " + companyInfo["GST"] + "\nState Code for GST : " + companyInfo["StateCode"] + "\nCIN : " + companyInfo["CIN"] + "\nPAN : " + companyInfo["PAN"]);
                        ourAddr.Add(new Chunk(sb.ToString(), font4));
                        ourAddr.Alignment = Element.ALIGN_RIGHT;
                        ourAddr.SetLeading(0.0f, 1.5f);
                    }
                    cellAdd.AddElement(ourAddr);
                    cellAdd.Border = 0;
                    tableHeader.AddCell(cellAdd);

                    Paragraph ParagraphDocumentName = new Paragraph(new Phrase("Tax Invoice", font2));
                    ParagraphDocumentName.Alignment = Element.ALIGN_CENTER;

                    PrintPurchaseOrder prog      = new PrintPurchaseOrder();
                    string[]           HeaderStr = HeaderString.Split(Main.delimiter1);

                    PdfPTable TableAddress = new PdfPTable(7);

                    TableAddress.SpacingBefore   = 20f;
                    TableAddress.WidthPercentage = 100;
                    float[] HWidths = new float[] { 1f, 8f, 1.5f, 2f, 1.5f, 2f, 3f };
                    TableAddress.SetWidths(HWidths);
                    PdfPCell cell;
                    int[]    arr = { 3, 7, 9, 10 };
                    float    wid = 0;
                    for (int i = 0; i < HeaderStr.Length; i++)
                    {
                        if (i == 0 || i == 5)
                        {
                            string[] format = HeaderStr[i].Split(Main.delimiter2);
                            Phrase   phr    = new Phrase();
                            phr.Add(new Chunk(format[0], font2));
                            phr.Add(new Chunk(format[1], font1));
                            cell = new PdfPCell(phr);
                            if (i == 0)
                            {
                                cell.Rowspan = 4;
                            }
                            else
                            {
                                cell.Rowspan = 3;
                            }
                            cell.Colspan             = 2;
                            cell.HorizontalAlignment = 0; //0=Left, 1=Centre, 2=Right
                            TableAddress.AddCell(cell);
                        }
                        else
                        {
                            cell               = new PdfPCell(new Phrase(HeaderStr[i].Trim(), font1));
                            cell.Colspan       = 5;
                            cell.MinimumHeight = wid;
                            TableAddress.AddCell(cell);
                        }
                    }
                    string[] ColHeaderStr = ColHeader.Split(';');

                    PdfPTable TableItemDetail = new PdfPTable(7);
                    TableItemDetail.DefaultCell.HorizontalAlignment = PdfPCell.ALIGN_CENTER;
                    TableItemDetail.WidthPercentage = 100;
                    float[] widthProd = new float[] { 1f, 8f, 1.5f, 2f, 1.5f, 2f, 3f };
                    float[] widthServ = new float[] { 1f, 8f, 1.5f, 2f, 0f, 2f, 3f };
                    if (ioh.DocumentID == "PRODUCTINVOICEOUT" || ioh.DocumentID == "PRODUCTEXPORTINVOICEOUT")
                    {
                        TableItemDetail.SetWidths(widthProd);
                    }
                    else
                    {
                        TableItemDetail.SetWidths(widthServ);
                    }


                    //Table Row No : 1 (Header Column)
                    for (int i = 0; i < ColHeaderStr.Length; i++)
                    {
                        if (i == (ColHeaderStr.Length - 1) || i == (ColHeaderStr.Length - 2))
                        {
                            PdfPCell hcell = new PdfPCell(new Phrase(ColHeaderStr[i].Trim() + "\n(" + ioh.CurrencyID + ")", font2));
                            hcell.HorizontalAlignment = PdfPCell.ALIGN_CENTER;
                            TableItemDetail.AddCell(hcell);
                        }
                        else
                        {
                            PdfPCell hcell = new PdfPCell(new Phrase(ColHeaderStr[i].Trim(), font2));
                            hcell.HorizontalAlignment = PdfPCell.ALIGN_CENTER;
                            TableItemDetail.AddCell(hcell);
                        }
                    }
                    //---
                    //Table Row No : 2 (Footer Column)
                    PdfPCell foot = new PdfPCell(new Phrase(""));
                    foot.Colspan        = 7;
                    foot.BorderWidthTop = 0;
                    foot.MinimumHeight  = 0.5f;
                    TableItemDetail.AddCell(foot);

                    TableItemDetail.HeaderRows = 2;
                    TableItemDetail.FooterRows = 1;

                    TableItemDetail.SkipFirstHeader = false;
                    TableItemDetail.SkipLastFooter  = true;
                    //---
                    int     track = 0;
                    decimal dc1   = 0;
                    decimal dc2   = 0;

                    //Table Row No : 3 (Header Column)
                    string[] DetailStr = ColDetailString.Split(Main.delimiter2);
                    float    hg        = 0f;
                    for (int i = 0; i < DetailStr.Length; i++)
                    {
                        track = 0;
                        hg    = TableItemDetail.GetRowHeight(i + 1);
                        string[] str = DetailStr[i].Split(Main.delimiter1);
                        for (int j = 0; j < str.Length; j++)
                        {
                            PdfPCell pcell;
                            if (j == 3 || j == 5 || j == 6)
                            {
                                decimal p = 1;
                                if (Decimal.TryParse(str[j], out p))
                                {
                                    pcell = new PdfPCell(new Phrase(String.Format("{0:0.00}", Convert.ToDecimal(str[j])), font1));
                                }
                                else
                                {
                                    pcell = new PdfPCell(new Phrase(""));
                                }
                                pcell.Border = 0;
                                if (j == 6)
                                {
                                    dc1 = Convert.ToDecimal(str[j]);
                                }
                            }
                            else
                            {
                                if (j == 2)
                                {
                                    if (str[j].Trim().Length == 0)
                                    {
                                        pcell = new PdfPCell(new Phrase("", font1));
                                    }
                                    else
                                    {
                                        pcell = new PdfPCell(new Phrase(str[j], font1));
                                    }
                                }
                                else if (j == 4)
                                {
                                    int m = 1;
                                    if (Int32.TryParse(str[j], out m) == true)
                                    {
                                        if (Convert.ToInt32(str[j]) == 0)
                                        {
                                            pcell = new PdfPCell(new Phrase("", font1));
                                        }
                                        else
                                        {
                                            pcell = new PdfPCell(new Phrase(str[j], font1));
                                        }
                                    }
                                    else
                                    {
                                        pcell = new PdfPCell(new Phrase(str[j], font1));
                                    }
                                }
                                else
                                {
                                    pcell = new PdfPCell(new Phrase(str[j], font1));
                                }
                                pcell.Border = 0;
                            }

                            pcell.MinimumHeight = 10;
                            if (j == 1)
                            {
                                pcell.HorizontalAlignment = PdfPCell.ALIGN_LEFT;
                            }
                            else
                            {
                                pcell.HorizontalAlignment = PdfPCell.ALIGN_CENTER;
                            }
                            pcell.BorderWidthLeft  = 0.01f;
                            pcell.BorderWidthRight = 0.01f;

                            TableItemDetail.AddCell(pcell);
                        }
                    }
                    PdfPCell Temp = new PdfPCell(new Phrase(""));
                    Temp.Border           = 0;
                    Temp.BorderWidthLeft  = 0.01f;
                    Temp.BorderWidthRight = 0.01f;

                    int dd = 0;
                    if (ioh.TaxAmount != 0)
                    {
                        ////Table Row No : 4 (Total Amount)
                        PdfPCell Temp1 = new PdfPCell(new Phrase(""));
                        Temp1.Border           = 0;
                        Temp1.BorderWidthTop   = 0.01f;
                        Temp1.BorderWidthLeft  = 0.01f;
                        Temp1.BorderWidthRight = 0.01f;
                        TableItemDetail.AddCell(Temp1); //blank cell
                        TableItemDetail.AddCell(Temp1);
                        PdfPCell cellCom = new PdfPCell(new Phrase("", font1));
                        cellCom.Colspan             = 4;
                        cellCom.Border              = 0;
                        cellCom.BorderWidthLeft     = 0.01f;
                        cellCom.BorderWidthRight    = 0.01f;
                        cellCom.BorderWidthTop      = 0.01f;
                        cellCom.HorizontalAlignment = PdfPCell.ALIGN_CENTER;
                        TableItemDetail.AddCell(cellCom);

                        PdfPCell cellTot = new PdfPCell(new Phrase(String.Format("{0:0.00}", Convert.ToDecimal(totAmnt)), font2));
                        cellTot.HorizontalAlignment = PdfPCell.ALIGN_CENTER;
                        TableItemDetail.AddCell(cellTot);
                        dd++;

                        string[] tax = taxStr.Split(Main.delimiter2);
                        for (int i = 0; i < tax.Length - 1; i++)
                        {
                            TableItemDetail.AddCell(Temp); //blank cell
                            TableItemDetail.AddCell(Temp);

                            string[] subtax     = tax[i].Split(Main.delimiter1);
                            PdfPCell cellinrtax = new PdfPCell(new Phrase(subtax[0], font1));
                            cellinrtax.Colspan             = 4;
                            cellinrtax.HorizontalAlignment = PdfPCell.ALIGN_RIGHT;
                            TableItemDetail.AddCell(cellinrtax);

                            PdfPCell pcell2;
                            pcell2 = new PdfPCell(new Phrase(String.Format("{0:0.00}", Convert.ToDecimal(subtax[1])), font1));
                            pcell2.HorizontalAlignment = PdfPCell.ALIGN_CENTER;
                            TableItemDetail.AddCell(pcell2);
                            dd++;
                        }
                        double taxAmRnd = Math.Round(ioh.TaxAmount, 0);
                        if (taxAmRnd != ioh.TaxAmount)
                        {
                            TableItemDetail.AddCell(Temp); //blank cell
                            TableItemDetail.AddCell(Temp);
                            PdfPCell cellTotTax = new PdfPCell(new Phrase("", font1));
                            cellTotTax.Colspan          = 4;
                            cellTotTax.Border           = 0;
                            cellTotTax.BorderWidthLeft  = 0.01f;
                            cellTotTax.BorderWidthRight = 0.01f;
                            //cellCom.BorderWidthTop = 0.01f;
                            cellTotTax.HorizontalAlignment = PdfPCell.ALIGN_CENTER;
                            TableItemDetail.AddCell(cellTotTax);

                            PdfPCell cellTotTaxValue = new PdfPCell(new Phrase(String.Format("{0:0.00}", Convert.ToDecimal(totAmnt + ioh.TaxAmount)), font2));
                            cellTotTaxValue.HorizontalAlignment = PdfPCell.ALIGN_CENTER;
                            TableItemDetail.AddCell(cellTotTaxValue);
                            dd++;
                        }
                    }



                    double roundedAmt = Math.Round(ioh.InvoiceAmount, 0);
                    double diffAmount = roundedAmt - ioh.InvoiceAmount;

                    if (diffAmount != 0)
                    {
                        TableItemDetail.AddCell("");
                        TableItemDetail.AddCell("");
                        PdfPCell cellRound = new PdfPCell(new Phrase("Rounding off", font1));
                        cellRound.Colspan             = 4;
                        cellRound.HorizontalAlignment = PdfPCell.ALIGN_RIGHT;
                        TableItemDetail.AddCell(cellRound);
                        TableItemDetail.AddCell(new Phrase(String.Format("{0:0.00}", diffAmount), font1));
                        //table1.AddCell("");
                        dd++;
                    }

                    TableItemDetail.AddCell("");
                    TableItemDetail.AddCell("");
                    PdfPCell cellRoundTot = new PdfPCell(new Phrase("Total", font1));
                    cellRoundTot.Colspan             = 4;
                    cellRoundTot.HorizontalAlignment = PdfPCell.ALIGN_RIGHT;
                    TableItemDetail.AddCell(cellRoundTot);

                    PdfPCell roundTot = new PdfPCell(new Phrase(String.Format("{0:0.00}", roundedAmt), font2));
                    roundTot.HorizontalAlignment = PdfPCell.ALIGN_CENTER;
                    TableItemDetail.AddCell(roundTot);

                    //table1.AddCell("");
                    string   total  = footer1 + NumberToString.convert(roundedAmt.ToString()).Replace("INR", ioh.CurrencyID) + "\n\n";
                    PdfPCell fcell1 = new PdfPCell(new Phrase((total), font1));
                    fcell1.Border              = 0;
                    fcell1.Colspan             = 6;
                    fcell1.HorizontalAlignment = PdfPCell.ALIGN_LEFT;
                    fcell1.BorderWidthLeft     = 0.5f;
                    fcell1.BorderWidthBottom   = 0.5f;
                    fcell1.BorderWidthRight    = 0;
                    fcell1.BorderWidthTop      = 0;
                    TableItemDetail.AddCell(fcell1);

                    PdfPCell fcell4 = new PdfPCell(new Phrase("E. & O.E", font1));
                    fcell4.HorizontalAlignment = PdfPCell.ALIGN_RIGHT;
                    fcell4.Border            = 0;
                    fcell4.BorderWidthBottom = 0.5f;
                    fcell4.BorderWidthRight  = 0.5f;
                    fcell4.BorderWidthLeft   = 0;
                    fcell4.BorderWidthTop    = 0;
                    TableItemDetail.AddCell(fcell4);
                    TableItemDetail.KeepRowsTogether(TableItemDetail.Rows.Count - (dd + 4), TableItemDetail.Rows.Count);
                    //int HSNMappCount = TaxDataTable.Rows.Count + 6;
                    //int itemCount = DetailStr.Length;
                    //int tableCount = table1.Rows.Count;

                    //=================================================
                    //DataTable TaxDataTable = new DataTable("TaxDetails");
                    //DataColumn[] colArr = { new DataColumn("HSN Code"), new DataColumn("Taxable Value"), new DataColumn("CGST %"),
                    //    new DataColumn("CGST Amt"), new DataColumn("SGST %"), new DataColumn("SGST Amt"), new DataColumn("IGST %"),
                    //    new DataColumn("IGST Amt"), new DataColumn("Total Amt") };
                    //TaxDataTable.Columns.AddRange(colArr);

                    //DataRow myDataRow = TaxDataTable.NewRow();
                    //myDataRow[colArr[0]] = "1111";
                    //myDataRow[colArr[1]] = "1000";
                    //myDataRow[colArr[2]] = "9";
                    //myDataRow[colArr[3]] = "200";
                    //myDataRow[colArr[4]] = "9";
                    //myDataRow[colArr[5]] = "200";
                    //myDataRow[colArr[6]] = "14";
                    //myDataRow[colArr[7]] = "600";
                    //myDataRow[colArr[8]] = "2000";
                    //TaxDataTable.Rows.Add(myDataRow);
                    //DataRow myDataRow1 = TaxDataTable.NewRow();
                    //myDataRow1[colArr[0]] = "2222";
                    //myDataRow1[colArr[1]] = "2000";
                    //myDataRow1[colArr[2]] = "9";
                    //myDataRow1[colArr[3]] = "300";
                    //myDataRow1[colArr[4]] = "9";
                    //myDataRow1[colArr[5]] = "400";
                    //myDataRow1[colArr[6]] = "14";
                    //myDataRow1[colArr[7]] = "1300";
                    //myDataRow1[colArr[8]] = "4000";
                    //TaxDataTable.Rows.Add(myDataRow1);
                    //==============================================
                    InvoiceOutHeaderDB iohDB        = new InvoiceOutHeaderDB();
                    DataTable          TaxDataTable = iohDB.taxDetails4Print(IODetails, ioh.DocumentID);


                    PdfPTable TabTaxDetail = new PdfPTable(TaxDataTable.Columns.Count);
                    TabTaxDetail.DefaultCell.HorizontalAlignment = PdfPCell.ALIGN_CENTER;
                    TabTaxDetail.WidthPercentage = 100;
                    //TabTaxDetail.SpacingBefore = 10;
                    PdfPCell cellTax = new PdfPCell();
                    //Adding columns in table
                    List <string>            colListStr    = new List <string>();
                    List <string>            colListSubStr = new List <string>();
                    double                   amtTot        = 0;
                    double                   TaxTot1       = 0;
                    double                   TaxTot2       = 0;
                    double                   TaxTot3       = 0;
                    double                   TaxTot        = 0;
                    Dictionary <int, string> dictTot       = new Dictionary <int, string>();
                    for (int p = 0; p < TaxDataTable.Columns.Count; p++)
                    {
                        if (p != 0 && p != 1 && p != TaxDataTable.Columns.Count - 1)
                        {
                            TaxTot1 = 0;
                            string substr = TaxDataTable.Columns[p].ColumnName;
                            colListStr.Add(substr.Trim());                             //CGST
                            colListSubStr.Add(TaxDataTable.Columns[p].ColumnName);     //CGST% in subList
                            colListSubStr.Add(TaxDataTable.Columns[p + 1].ColumnName); //CGST amount in subList
                            p++;
                            if (p % 2 != 0)
                            {
                                TaxTot1 = TaxDataTable.AsEnumerable().Sum(c => c.Field <double>(TaxDataTable.Columns[p].ColumnName));
                                dictTot.Add(p, String.Format("{0:0.00}", Convert.ToDecimal(TaxTot1)));
                            }
                        }
                        else
                        {
                            colListStr.Add(TaxDataTable.Columns[p].ColumnName);
                            if (p == 1)
                            {
                                amtTot = TaxDataTable.AsEnumerable().Sum(c => c.Field <double>(TaxDataTable.Columns[p].ColumnName));
                                dictTot.Add(p, String.Format("{0:0.00}", Convert.ToDecimal(amtTot)));
                            }
                            if (p == TaxDataTable.Columns.Count - 1)
                            {
                                TaxTot = TaxDataTable.AsEnumerable().Sum(c => c.Field <double>(TaxDataTable.Columns[p].ColumnName));
                                dictTot.Add(p, String.Format("{0:0.00}", Convert.ToDecimal(TaxTot)));
                            }
                        }
                    }
                    foreach (string str in colListStr)
                    {
                        int index = colListStr.FindIndex(x => x == str);
                        if (index == 0 || index == 1 || index == colListStr.Count - 1)
                        {
                            cellTax         = new PdfPCell();
                            cellTax.Rowspan = 2;
                            Paragraph p = new Paragraph(str, font2);
                            p.Alignment = Element.ALIGN_CENTER;
                            cellTax.AddElement(p);
                            TabTaxDetail.AddCell(cellTax);
                        }
                        else
                        {
                            cellTax         = new PdfPCell();
                            cellTax.Colspan = 2;
                            Paragraph p = new Paragraph(str, font2);
                            p.Alignment = Element.ALIGN_CENTER;
                            cellTax.AddElement(p);
                            TabTaxDetail.AddCell(cellTax);
                        }
                    }
                    foreach (string str in colListSubStr)
                    {
                        cellTax = new PdfPCell();
                        Paragraph p = new Paragraph(str, font2);
                        p.Alignment = Element.ALIGN_CENTER;
                        cellTax.AddElement(p);
                        TabTaxDetail.AddCell(cellTax);
                    }
                    int t = 0;
                    foreach (DataRow row in TaxDataTable.Rows)
                    {
                        int l = 0;
                        foreach (DataColumn col in TaxDataTable.Columns)
                        {
                            cellTax = new PdfPCell();
                            if (l == 1 || l % 2 != 0 || l == TaxDataTable.Columns.Count - 1)
                            {
                                Paragraph p = new Paragraph(String.Format("{0:0.00}", Convert.ToDecimal(row[col].ToString())), font1);
                                p.Alignment = Element.ALIGN_CENTER;
                                cellTax.AddElement(p);
                                TabTaxDetail.AddCell(cellTax);
                            }
                            else
                            {
                                Paragraph p = new Paragraph(row[col].ToString(), font1);
                                p.Alignment = Element.ALIGN_CENTER;
                                cellTax.AddElement(p);
                                TabTaxDetail.AddCell(cellTax);
                            }
                            t++;
                            l++;
                        }
                    }
                    for (int k = 0; k < TaxDataTable.Columns.Count; k++)
                    {
                        if (k == 0)
                        {
                            cellTax = new PdfPCell();
                            Paragraph p = new Paragraph("Total", font2);
                            p.Alignment = Element.ALIGN_CENTER;
                            cellTax.AddElement(p);
                            TabTaxDetail.AddCell(cellTax);
                        }
                        else if (dictTot.ContainsKey(k))
                        {
                            cellTax = new PdfPCell();
                            Paragraph p = new Paragraph(dictTot[k], font2);
                            p.Alignment = Element.ALIGN_CENTER;
                            cellTax.AddElement(p);
                            TabTaxDetail.AddCell(cellTax);
                        }
                        else
                        {
                            cellTax = new PdfPCell();
                            Paragraph p = new Paragraph("", font1);
                            p.Alignment = Element.ALIGN_CENTER;
                            cellTax.AddElement(p);
                            TabTaxDetail.AddCell(cellTax);
                        }
                    }
                    //TabTaxDetail.KeepRowsTogether(TabTaxDetail.Rows.Count - 10, TabTaxDetail.Rows.Count);
                    TabTaxDetail.KeepTogether = true;

                    //Bank dtails and authorised Signature
                    PdfPTable tableFooter = new PdfPTable(2);
                    tableFooter.WidthPercentage = 100;
                    Phrase phrs = new Phrase();
                    phrs.Add(new Chunk("\nBank Details for Payment", font2));

                    phrs.Add(new Chunk(footer2, font1));

                    PdfPCell fcell2 = new PdfPCell(phrs);
                    fcell2.HorizontalAlignment = PdfPCell.ALIGN_LEFT;
                    fcell2.BorderWidthRight    = 0;
                    tableFooter.AddCell(fcell2);

                    string[] ft = footer3.Split(';');

                    PdfPCell fcell3 = new PdfPCell();
                    Chunk    ch1    = new Chunk(ft[0], font1);
                    Chunk    ch2    = new Chunk(ft[1], font1);
                    Phrase   phrase = new Phrase();
                    phrase.Add(ch1);
                    for (int i = 0; i < 3; i++)
                    {
                        phrase.Add(Chunk.NEWLINE);
                    }
                    phrase.Add(ch2);

                    Paragraph para = new Paragraph();
                    para.Add(phrase);
                    para.Alignment = Element.ALIGN_RIGHT;
                    fcell3.AddElement(para);
                    fcell3.Border            = 0;
                    fcell3.BorderWidthRight  = 0.5f;
                    fcell3.BorderWidthBottom = 0.5f;
                    fcell3.MinimumHeight     = 50;
                    tableFooter.AddCell(fcell3);

                    PdfPTable tableSub = new PdfPTable(1);
                    tableSub.DefaultCell.Border = 0;
                    tableSub.DefaultCell.HorizontalAlignment = PdfPCell.ALIGN_CENTER;
                    tableSub.AddCell(new Phrase("Subject To Bangalore Jurisdiction", font2));

                    PdfPCell celSub = new PdfPCell(tableSub);
                    celSub.Border  = 0;
                    celSub.Colspan = 2;
                    tableFooter.AddCell(celSub);

                    //=======


                    doc.Add(tableHeader);
                    doc.Add(ParagraphDocumentName);
                    doc.Add(TableAddress);
                    doc.Add(TableItemDetail);
                    doc.Add(TabTaxDetail);
                    doc.Add(tableFooter);


                    doc.Close();

                    if (ioh.status == 0 && ioh.DocumentStatus < 99)
                    {
                        String wmurl = "";
                        wmurl = "004.png";
                        PrintWaterMark.PdfStampWithNewFile(wmurl, sfd.FileName);
                    }
                    if (ioh.status == 98)
                    {
                        String wmurl = "";
                        wmurl = "003.png";
                        PrintWaterMark.PdfStampWithNewFile(wmurl, sfd.FileName);
                    }
                    MessageBox.Show("Document Saved");
                }
                catch (Exception ex)
                {
                    MessageBox.Show(this.ToString() + "-" + System.Reflection.MethodBase.GetCurrentMethod().Name + "() : Error-" + ex.ToString());
                    MessageBox.Show("Failed TO Save");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Exception : " + ex.ToString());
                MessageBox.Show("Failed TO Save");
            }
        }
Esempio n. 6
0
        private void grdList_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            try
            {
                if (e.RowIndex < 0)
                    return;
                string columnName = grdList.Columns[e.ColumnIndex].Name;
                if (columnName.Equals("Print"))
                {
                    //int rowID = e.RowIndex;
                    //////string tempDate = "";
                    ////Edit Button
                    ////MessageBox.Show("You clicked edit button");
                    //btnSave.Text = "Update";
                    //pnlDocumentInner.Visible = true;
                    //pnlDocumentOuter.Visible = true;
                    //pnlDocumentList.Visible = false;
                    //txtCustomerName.Enabled = false;
                    //cmbDocumentStatus.SelectedIndex = cmbDocumentStatus.FindStringExact(grdList.Rows[e.RowIndex].Cells[2].Value.ToString());
                    //DataGridViewRow row = grdList.Rows[rowID];
                    //txtCustomerName.Text = grdList.Rows[e.RowIndex].Cells[0].Value.ToString();
                    //txtTemporaryNo.Text = grdList.Rows[e.RowIndex].Cells[1].Value.ToString();
                    //txtInvoiceAmount.Text = grdList.Rows[e.RowIndex].Cells[2].Value.ToString();
                    string Docid = grdList.Rows[e.RowIndex].Cells[0].Value.ToString();
                    int Tempno = Convert.ToInt32(grdList.Rows[e.RowIndex].Cells[1].Value);
                    DateTime Tempdate = Convert.ToDateTime(grdList.Rows[e.RowIndex].Cells[2].Value);
                   string PODocIdWRTIO = getPODocIDForSelectedIO(Docid);
                    //disableBottomButtons();
                    grdList.Visible = true;
                    btnNew.Visible = true;
                    btnExit.Visible = true;
                    //CSLERP.PrintForms.PrintPurchaseOrder ppo = new CSLERP.PrintForms.PrintPurchaseOrder();
                    PrintInvoiceOut pio = new PrintInvoiceOut();
                    invoiceoutheader ioh = new invoiceoutheader();
                    InvoiceOutHeaderDB iodb = new InvoiceOutHeaderDB();
                    List<invoiceoutheader> InvceOuthdr = iodb.getFilteredInvoiceOutHeaderList(Docid, Tempno, Tempdate);
                    ioh = InvceOuthdr.FirstOrDefault();
                    List<invoiceoutdetail> IODetails = InvoiceOutHeaderDB.getInvoiceOutDetail(ioh);
                    foreach (invoiceoutdetail iod in IODetails)
                    {
                        if (iod.HSNCode.Trim().Length <= 0)
                        {
                            MessageBox.Show("HSN Code not available for " + iod.StockItemName + ". Print aborted....");
                            return;
                        }
                    }
                    getTaxDetails(IODetails);
                    string taxstr = getTasDetailStr();
                    //string taxstr = "";
                    taxDetails4Print(IODetails, ioh.DocumentID);
                    if (ioh.DocumentID == "PRODUCTEXPORTINVOICEOUT" || ioh.DocumentID == "SERVICEEXPORTINVOICEOUT")
                    {
                        PrintExportInvoiceOut expPrint = new PrintExportInvoiceOut();
                        expPrint.PrintExportIO(ioh, IODetails, taxstr, PODocIdWRTIO);
                    }
                    else
                    {
                        pio.PrintIO(ioh, IODetails, taxstr, PODocIdWRTIO);
                    }
                    btnNew.Visible = true;
                    btnExit.Visible = true;
                    return;
                }
            }
            catch (Exception ex)
            {

            }
        }
Esempio n. 7
0
        private void grdMainList_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            try
            {
                if (e.RowIndex < 0)
                {
                    return;
                }
                string columnName = grdMainList.Columns[e.ColumnIndex].Name;
                if (columnName.Equals("Detail"))
                {
                    if (Convert.ToInt32(grdMainList.CurrentRow.Cells["gNo"].Value) == 0)
                    {
                        MessageBox.Show("No of Item is zero");
                        return;
                    }
                    grdDetailList.Rows.Clear();
                    grdDetailList.Visible = true;
                    btnCancel.Visible     = true;

                    string Head = grdMainList.CurrentRow.Cells["Received"].Value.ToString();
                    if (Head.Equals("PO Received"))
                    {
                        List <popiheader> ppopi = POPIHeaderDB.getPOPIINFOForProjectTrans(txtProjectID.Text);
                        int i = 1;
                        grdDetailList.Columns["DocumentNo"].HeaderText   = "Tracking No";
                        grdDetailList.Columns["DocumentDate"].HeaderText = "Tracking Date";
                        grdDetailList.Columns["Customer"].HeaderText     = "Customer";
                        grdDetailList.Columns["CustPODate"].HeaderText   = "CustPODate";
                        grdDetailList.Columns["gValue"].HeaderText       = "Value";
                        grdDetailList.Columns["TaxAmount"].HeaderText    = "Tax Amount";
                        grdDetailList.Columns["CustPONo"].Visible        = true;
                        grdDetailList.Columns["CustPODate"].Visible      = true;
                        grdDetailList.Columns["gValue"].Visible          = true;
                        grdDetailList.Columns["TaxAmount"].Visible       = true;
                        foreach (popiheader popih in ppopi)
                        {
                            grdDetailList.Rows.Add();
                            grdDetailList.Rows[grdDetailList.RowCount - 1].Cells["LineNo"].Value       = i;
                            grdDetailList.Rows[grdDetailList.RowCount - 1].Cells["DocumentNo"].Value   = popih.TrackingNo;
                            grdDetailList.Rows[grdDetailList.RowCount - 1].Cells["DocumentDate"].Value = popih.TrackingDate;
                            grdDetailList.Rows[grdDetailList.RowCount - 1].Cells["Customer"].Value     = popih.CustomerName;
                            grdDetailList.Rows[grdDetailList.RowCount - 1].Cells["gValue"].Value       = popih.ProductValue;
                            grdDetailList.Rows[grdDetailList.RowCount - 1].Cells["TaxAmount"].Value    = popih.TaxAmount;
                            grdDetailList.Rows[grdDetailList.RowCount - 1].Cells["TotalAmount"].Value  = popih.POValue;
                            grdDetailList.Rows[grdDetailList.RowCount - 1].Cells["CustPONo"].Value     = popih.CustomerPONO;
                            grdDetailList.Rows[grdDetailList.RowCount - 1].Cells["CustPODate"].Value   = popih.CustomerPODate;
                            i++;
                        }
                    }
                    else if (Head.Equals("Work Order Issued"))
                    {
                        int i = 1;
                        grdDetailList.Columns["DocumentNo"].HeaderText   = "WO No";
                        grdDetailList.Columns["DocumentDate"].HeaderText = "WO Date";
                        grdDetailList.Columns["Customer"].HeaderText     = "Customer";
                        grdDetailList.Columns["gValue"].HeaderText       = "Value";
                        grdDetailList.Columns["TaxAmount"].HeaderText    = "Tax Amount";
                        grdDetailList.Columns["CustPONo"].Visible        = false;
                        grdDetailList.Columns["CustPODate"].Visible      = false;
                        grdDetailList.Columns["gValue"].Visible          = true;
                        grdDetailList.Columns["TaxAmount"].Visible       = true;
                        List <workorderheader> wohList = WorkOrderDB.getRVINFOForProjectTrans(txtProjectID.Text);
                        foreach (workorderheader woh in wohList)
                        {
                            grdDetailList.Rows.Add();
                            grdDetailList.Rows[grdDetailList.RowCount - 1].Cells["LineNo"].Value       = i;
                            grdDetailList.Rows[grdDetailList.RowCount - 1].Cells["DocumentNo"].Value   = woh.WONo;
                            grdDetailList.Rows[grdDetailList.RowCount - 1].Cells["DocumentDate"].Value = woh.WODate;
                            grdDetailList.Rows[grdDetailList.RowCount - 1].Cells["Customer"].Value     = woh.CustomerName;
                            grdDetailList.Rows[grdDetailList.RowCount - 1].Cells["gValue"].Value       = woh.ServiceValue;
                            grdDetailList.Rows[grdDetailList.RowCount - 1].Cells["TaxAmount"].Value    = woh.TaxAmount;
                            grdDetailList.Rows[grdDetailList.RowCount - 1].Cells["TotalAmount"].Value  = woh.TotalAmount;
                            i++;
                        }
                    }
                    else if (Head.Equals("Material Supplied"))
                    {
                        int i = 1;
                        grdDetailList.Columns["DocumentNo"].HeaderText   = "Invoice No";
                        grdDetailList.Columns["DocumentDate"].HeaderText = "Invoice Date";
                        grdDetailList.Columns["Customer"].HeaderText     = "Customer";
                        grdDetailList.Columns["gValue"].HeaderText       = "Value";
                        grdDetailList.Columns["TaxAmount"].HeaderText    = "Tax Amount";
                        grdDetailList.Columns["CustPONo"].Visible        = false;
                        grdDetailList.Columns["CustPODate"].Visible      = false;
                        grdDetailList.Columns["gValue"].Visible          = true;
                        grdDetailList.Columns["TaxAmount"].Visible       = true;
                        List <invoiceoutheader> iohList = InvoiceOutHeaderDB.getRVINFOForProjectTrans(txtProjectID.Text);
                        foreach (invoiceoutheader ioh in iohList)
                        {
                            grdDetailList.Rows.Add();
                            grdDetailList.Rows[grdDetailList.RowCount - 1].Cells["LineNo"].Value       = i;
                            grdDetailList.Rows[grdDetailList.RowCount - 1].Cells["DocumentNo"].Value   = ioh.InvoiceNo;
                            grdDetailList.Rows[grdDetailList.RowCount - 1].Cells["DocumentDate"].Value = ioh.InvoiceDate;
                            grdDetailList.Rows[grdDetailList.RowCount - 1].Cells["Customer"].Value     = ioh.ConsigneeName;
                            grdDetailList.Rows[grdDetailList.RowCount - 1].Cells["gValue"].Value       = ioh.ProductValue;
                            grdDetailList.Rows[grdDetailList.RowCount - 1].Cells["TaxAmount"].Value    = ioh.TaxAmount;
                            grdDetailList.Rows[grdDetailList.RowCount - 1].Cells["TotalAmount"].Value  = ioh.InvoiceAmount;
                            //grdDetailList.Rows[grdDetailList.RowCount - 1].Cells["CustPONo"].Value = ioh.InvoiceNo;
                            //grdDetailList.Rows[grdDetailList.RowCount - 1].Cells["CustPODate"].Value = ioh.InvoiceDate;
                            i++;
                        }
                    }
                    else if (Head.Equals("Material Payment"))
                    {
                        int i = 1;
                        grdDetailList.Columns["DocumentNo"].HeaderText   = "Voucher No";
                        grdDetailList.Columns["DocumentDate"].HeaderText = "Voucher Date";
                        grdDetailList.Columns["gValue"].HeaderText       = "Bill No";
                        grdDetailList.Columns["TaxAmount"].HeaderText    = "Bill Date";
                        grdDetailList.Columns["CustPONo"].Visible        = false;
                        grdDetailList.Columns["CustPODate"].Visible      = true;
                        grdDetailList.Columns["CustPODate"].HeaderText   = "SLType";
                        grdDetailList.Columns["Customer"].HeaderText     = "SLName";
                        grdDetailList.Columns["gValue"].Visible          = true;
                        grdDetailList.Columns["TaxAmount"].Visible       = true;
                        List <paymentvoucher> pvhList = PaymentVoucherDB.getRVINFOForProjectTrans(txtProjectID.Text, 1);
                        foreach (paymentvoucher pvh in pvhList)
                        {
                            grdDetailList.Rows.Add();
                            grdDetailList.Rows[grdDetailList.RowCount - 1].Cells["LineNo"].Value       = i;
                            grdDetailList.Rows[grdDetailList.RowCount - 1].Cells["DocumentNo"].Value   = pvh.VoucherNo;
                            grdDetailList.Rows[grdDetailList.RowCount - 1].Cells["DocumentDate"].Value = pvh.VoucherDate;
                            grdDetailList.Rows[grdDetailList.RowCount - 1].Cells["CustPODate"].Value   = pvh.SLType;
                            grdDetailList.Rows[grdDetailList.RowCount - 1].Cells["Customer"].Value     = pvh.SLName;
                            grdDetailList.Rows[grdDetailList.RowCount - 1].Cells["gValue"].Value       = pvh.BillNo;
                            grdDetailList.Rows[grdDetailList.RowCount - 1].Cells["TaxAmount"].Value    = pvh.BillDate;
                            grdDetailList.Rows[grdDetailList.RowCount - 1].Cells["TotalAmount"].Value  = pvh.AmountDebit;
                            i++;
                        }
                    }
                    else if (Head.Equals("WO payment"))
                    {
                        int i = 1;
                        grdDetailList.Columns["DocumentNo"].HeaderText   = "Voucher No";
                        grdDetailList.Columns["DocumentDate"].HeaderText = "Voucher Date";
                        grdDetailList.Columns["gValue"].HeaderText       = "Bill No";
                        grdDetailList.Columns["TaxAmount"].HeaderText    = "Bill Date";
                        grdDetailList.Columns["CustPONo"].Visible        = false;
                        grdDetailList.Columns["CustPODate"].Visible      = true;
                        grdDetailList.Columns["CustPODate"].HeaderText   = "SLType";
                        grdDetailList.Columns["Customer"].HeaderText     = "SLName";
                        grdDetailList.Columns["gValue"].Visible          = true;
                        grdDetailList.Columns["TaxAmount"].Visible       = true;
                        List <paymentvoucher> pvhList = PaymentVoucherDB.getRVINFOForProjectTrans(txtProjectID.Text, 2);
                        foreach (paymentvoucher pvh in pvhList)
                        {
                            grdDetailList.Rows.Add();
                            grdDetailList.Rows[grdDetailList.RowCount - 1].Cells["LineNo"].Value       = i;
                            grdDetailList.Rows[grdDetailList.RowCount - 1].Cells["DocumentNo"].Value   = pvh.VoucherNo;
                            grdDetailList.Rows[grdDetailList.RowCount - 1].Cells["DocumentDate"].Value = pvh.VoucherDate;
                            grdDetailList.Rows[grdDetailList.RowCount - 1].Cells["CustPODate"].Value   = pvh.SLType;
                            grdDetailList.Rows[grdDetailList.RowCount - 1].Cells["Customer"].Value     = pvh.SLName;
                            grdDetailList.Rows[grdDetailList.RowCount - 1].Cells["gValue"].Value       = pvh.BillNo;
                            grdDetailList.Rows[grdDetailList.RowCount - 1].Cells["TaxAmount"].Value    = pvh.BillDate;
                            grdDetailList.Rows[grdDetailList.RowCount - 1].Cells["TotalAmount"].Value  = pvh.AmountDebit;
                            i++;
                        }
                    }
                    else if (Head.Equals("Employee Payments"))
                    {
                    }
                    else if (Head.Equals("Other payments"))
                    {
                        int i = 1;
                        grdDetailList.Columns["DocumentNo"].HeaderText   = "Voucher No";
                        grdDetailList.Columns["DocumentDate"].HeaderText = "Voucher Date";
                        grdDetailList.Columns["gValue"].HeaderText       = "Bill No";
                        grdDetailList.Columns["TaxAmount"].HeaderText    = "Bill Date";
                        grdDetailList.Columns["CustPONo"].Visible        = false;
                        grdDetailList.Columns["CustPODate"].Visible      = true;
                        grdDetailList.Columns["CustPODate"].HeaderText   = "SLType";
                        grdDetailList.Columns["Customer"].HeaderText     = "SLName";
                        grdDetailList.Columns["gValue"].Visible          = true;
                        grdDetailList.Columns["TaxAmount"].Visible       = true;
                        List <paymentvoucher> pvhList = PaymentVoucherDB.getRVINFOForProjectTrans(txtProjectID.Text, 3);
                        foreach (paymentvoucher pvh in pvhList)
                        {
                            grdDetailList.Rows.Add();
                            grdDetailList.Rows[grdDetailList.RowCount - 1].Cells["LineNo"].Value       = i;
                            grdDetailList.Rows[grdDetailList.RowCount - 1].Cells["DocumentNo"].Value   = pvh.VoucherNo;
                            grdDetailList.Rows[grdDetailList.RowCount - 1].Cells["DocumentDate"].Value = pvh.VoucherDate;
                            grdDetailList.Rows[grdDetailList.RowCount - 1].Cells["CustPODate"].Value   = pvh.SLType;
                            grdDetailList.Rows[grdDetailList.RowCount - 1].Cells["Customer"].Value     = pvh.SLName;
                            grdDetailList.Rows[grdDetailList.RowCount - 1].Cells["gValue"].Value       = pvh.BillNo;
                            grdDetailList.Rows[grdDetailList.RowCount - 1].Cells["TaxAmount"].Value    = pvh.BillDate;
                            grdDetailList.Rows[grdDetailList.RowCount - 1].Cells["TotalAmount"].Value  = pvh.AmountDebit;
                            i++;
                        }
                    }
                    else if (Head.Equals("Receipts"))
                    {
                        int i = 1;
                        grdDetailList.Columns["DocumentNo"].HeaderText   = "Voucher No";
                        grdDetailList.Columns["DocumentDate"].HeaderText = "Voucher Date";
                        grdDetailList.Columns["CustPONo"].Visible        = false;
                        grdDetailList.Columns["CustPODate"].Visible      = true;
                        grdDetailList.Columns["CustPODate"].HeaderText   = "SLType";
                        grdDetailList.Columns["Customer"].HeaderText     = "SLName";
                        grdDetailList.Columns["gValue"].Visible          = false;
                        grdDetailList.Columns["TaxAmount"].Visible       = false;
                        List <ReceiptVoucherHeader> rvhlist = ReceiptVoucherDB.getRVINFOForProjectTrans(txtProjectID.Text);
                        foreach (ReceiptVoucherHeader rvh in rvhlist)
                        {
                            grdDetailList.Rows.Add();
                            grdDetailList.Rows[grdDetailList.RowCount - 1].Cells["LineNo"].Value       = i;
                            grdDetailList.Rows[grdDetailList.RowCount - 1].Cells["DocumentNo"].Value   = rvh.VoucherNo;
                            grdDetailList.Rows[grdDetailList.RowCount - 1].Cells["DocumentDate"].Value = rvh.VoucherDate;
                            grdDetailList.Rows[grdDetailList.RowCount - 1].Cells["CustPODate"].Value   = rvh.SLType;
                            grdDetailList.Rows[grdDetailList.RowCount - 1].Cells["Customer"].Value     = rvh.SLName;
                            grdDetailList.Rows[grdDetailList.RowCount - 1].Cells["gValue"].Value       = "";
                            grdDetailList.Rows[grdDetailList.RowCount - 1].Cells["TaxAmount"].Value    = "";
                            grdDetailList.Rows[grdDetailList.RowCount - 1].Cells["TotalAmount"].Value  = rvh.VoucherAmount;
                            i++;
                        }
                    }
                    else
                    {
                        grdDetailList.Rows.Clear();
                        grdDetailList.Visible = false;
                        btnCancel.Visible     = false;
                    }
                }
            }
            catch (Exception ex)
            {
            }
        }
Esempio n. 8
0
 private void ShowAllDetails()
 {
     try
     {
         InvoiceOutHeaderDB pdb = new InvoiceOutHeaderDB();
         invoiceoutheader   poh = pdb.getFilteredInvoiceOutHeaderList(docID, tempno, tempdate).FirstOrDefault();
         if (poh != null)
         {
             hide();
             txtDocID.Text                       = poh.DocumentID;
             txtPOTrackingNo.Text                = poh.TrackingNos.ToString();
             txtPOTrackingdate.Text              = poh.TrackingDates;
             cmbCustomer.SelectedIndex           = Structures.ComboFUnctions.getComboIndex(cmbCustomer, poh.ConsigneeID);
             txtInvoiceNo.Text                   = poh.InvoiceNo.ToString();
             dtInvoiceDate.Value                 = poh.InvoiceDate;
             cmbCurrency.SelectedIndex           = Structures.ComboFUnctions.getComboIndex(cmbCurrency, poh.CurrencyID);
             cmbTransporter.SelectedIndex        = Structures.ComboFUnctions.getComboIndex(cmbTransporter, poh.Transporter);
             cmbTransportationMode.SelectedIndex = Structures.ComboFUnctions.getComboIndex(cmbTransportationMode, poh.TransportationMode);
             cmbProject.SelectedIndex            = cmbProject.FindString(poh.ProjectID);
             txtFreightCharge.Text               = poh.FreightCharge.ToString();
             txtpaymentTerms.Text                = poh.TermsOfPayment;
             txtproductValue.Text                = poh.ProductValueINR.ToString();
             txtTaxvalue.Text                    = poh.TaxAmountINR.ToString();
             txtFreightForwarding.Text           = (poh.FreightCharge * poh.INRConversionRate).ToString();
             txtInvoiceAmt.Text                  = poh.InvoiceAmount.ToString();
             txtBankAccount.Text                 = poh.BankAcReference.ToString();
             if ((docID == "PRODUCTEXPORTINVOICEOUT") || (docID == "SERVICEEXPORTINVOICEOUT"))
             {
                 show();
                 cmbOriginCountryID.SelectedIndex           = Structures.ComboFUnctions.getComboIndex(cmbOriginCountryID, poh.OriginCountryID);
                 cmbFinalDestinationCountryID.SelectedIndex = Structures.ComboFUnctions.getComboIndex(cmbFinalDestinationCountryID, poh.FinalDestinatoinCountryID);
                 //cmbFinalDestinationCountryID.SelectedIndex = cmbFinalDestinationCountryID.FindString(previoh.FinalDestinatoinCountryID);
                 txtFinalDestinationPlace.Text = poh.FinalDestinationPlace;
                 //cmbPreCarriageTransMode.SelectedIndex = cmbPreCarriageTransMode.FindString(previoh.PreCarriageTransportationMode);
                 cmbPreCarriageTransMode.SelectedIndex = Structures.ComboFUnctions.getComboIndex(cmbPreCarriageTransMode, poh.PreCarriageTransportationMode);
                 txtPrecarrierReceivedPlace.Text       = poh.PreCarrierReceiptPlace;
                 txtTermsOfDelivery.Text = poh.TermsOfDelivery;
                 txtEntryPort.Text       = poh.EntryPort;
                 txtExitPort.Text        = poh.ExitPort;
                 cmbADCode.SelectedIndex = Structures.ComboFUnctions.getComboIndex(cmbADCode, poh.ADCode);
                 //cmbADCode.SelectedIndex = cmbADCode.FindString(previoh.ADCode);
             }
         }
         invoiceoutheader popd = new invoiceoutheader();
         popd.DocumentID    = docID;
         popd.TemporaryNo   = tempno;
         popd.TemporaryDate = tempdate;
         List <invoiceoutdetail> pod = InvoiceOutHeaderDB.getInvoiceOutDetail(popd);
         grdPRDetail.Rows.Clear();
         int    i     = 0;
         double count = 0;
         foreach (invoiceoutdetail 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");
     }
 }
Esempio n. 9
0
        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");
            }
        }