コード例 #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";
                }
            }
        }
コード例 #2
0
ファイル: ShowWorkOrder.cs プロジェクト: suhasrake/CSLERP
 private void ShowAllDetails()
 {
     try
     {
         WorkOrderDB     WOdb = new WorkOrderDB();
         workorderheader vd   = WOdb.getFilteredWorkOrderHeadersList(docID, tempno, tempdate).FirstOrDefault();
         if (vd != null)
         {
             txtDocID.Text             = vd.DocumentID;
             txtTrackingNo.Text        = vd.WONo.ToString();
             dtTrackingDate.Value      = vd.WODate;
             txtrefno.Text             = vd.ReferenceInternalOrder;
             cmbCustomer.SelectedIndex = Structures.ComboFUnctions.getComboIndex(cmbCustomer, vd.CustomerID);
             txtPONo.Text                 = vd.WORequestNo.ToString();
             dtPODate.Value               = vd.WORequestDate;
             dtDeliveryDate.Value         = vd.StartDate;
             cmbOfficeID.SelectedIndex    = Structures.ComboFUnctions.getComboIndex(cmbOfficeID, vd.OfficeID);
             cmbProjectID.SelectedIndex   = cmbProjectID.FindString(vd.ProjectID);
             cmbPaymentMode.SelectedIndex = Structures.ComboFUnctions.getComboIndex(cmbPaymentMode, vd.PaymentMode);
             cmbCurrency.SelectedIndex    = Structures.ComboFUnctions.getComboIndex(cmbCurrency, vd.CurrencyID);
             dtValidateDate.Value         = vd.TargetDate;
             txtpaymentTerms.Text         = getPaymentTermsExplained(vd.PaymentTerms);
             txtproductValue.Text         = vd.ServiceValueINR.ToString();
             txtTaxvalue.Text             = vd.TaxAmountINR.ToString();
             txtPOvalue.Text              = vd.TotalAmountINR.ToString();
         }
         workorderheader popih = new workorderheader();
         popih.DocumentID    = docID;
         popih.TemporaryNo   = tempno;
         popih.TemporaryDate = tempdate;
         List <workorderdetail> POPIDetail = WorkOrderDB.getWorkOrderDetails(popih);
         grdPRDetail.Rows.Clear();
         int    i     = 0;
         double count = 0;
         foreach (workorderdetail pop in POPIDetail)
         {
             grdPRDetail.Rows.Add();
             grdPRDetail.Rows[i].Cells["LineNo"].Value   = grdPRDetail.Rows.Count;
             grdPRDetail.Rows[i].Cells["Item"].Value     = pop.StockItemID;
             grdPRDetail.Rows[i].Cells["ItemDesc"].Value = pop.Description;
             grdPRDetail.Rows[i].Cells["TaxCode"].Value  = pop.TaxCode;
             grdPRDetail.Rows[i].Cells["Quantity"].Value = pop.Quantity;
             grdPRDetail.Rows[i].Cells["Price"].Value    = pop.Price;
             grdPRDetail.Rows[i].Cells["Tax"].Value      = pop.Tax;
             double valu = pop.Price * pop.Quantity + pop.Tax;
             grdPRDetail.Rows[i].Cells["Value"].Value = valu;
             count += valu;
             i++;
         }
         txtTotalValue.Text = count.ToString();
     }
     catch (Exception ex)
     {
         MessageBox.Show("Error in POInward");
     }
 }
コード例 #3
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)
            {
            }
        }
コード例 #4
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");
            }
        }