Esempio n. 1
0
        private void grdList_CellContentClick_1(object sender, DataGridViewCellEventArgs e)
        {
            try
            {
                if (e.RowIndex < 0)
                {
                    return;
                }
                grdList.Rows[e.RowIndex].Selected = true;
                ////grdList.CurrentRow.DefaultCellStyle.BackColor = Color.LightSeaGreen;
                string columnName = grdList.Columns[e.ColumnIndex].Name;

                if (columnName.Equals("QtyDetails") || columnName.Equals("ClosePO"))
                {
                    poheader poph       = new poheader();
                    int      totalvalue = Convert.ToInt32(grdList.Rows[e.RowIndex].Cells["TotalValueBilled"].Value);
                    poph.TemporaryNo   = Convert.ToInt32(grdList.Rows[e.RowIndex].Cells["gTemporaryNo"].Value.ToString());
                    poph.TemporaryDate = DateTime.Parse(grdList.Rows[e.RowIndex].Cells["gTemporaryDate"].Value.ToString());
                    poph.PODate        = DateTime.Parse(grdList.Rows[e.RowIndex].Cells["gTrackingDate"].Value.ToString());
                    poph.PONo          = Convert.ToInt32(grdList.Rows[e.RowIndex].Cells["gTrackingNo"].Value.ToString());
                    poph.CustomerName  = grdList.Rows[e.RowIndex].Cells["gCustomerName"].Value.ToString();

                    if (columnName.Equals("QtyDetails"))
                    {
                        showStockPOQuantity(poph);
                    }
                    if (columnName.Equals("ClosePO"))
                    {
                        PurchaseOrderDB popihdb = new PurchaseOrderDB();
                        if (popihdb.ClosePOPICheck(poph))
                        {
                            MessageBox.Show("PO Closed");
                            btnView.PerformClick();
                        }
                        else
                        {
                            string dstr = "PO No:" + poph.PONo + "\n" +
                                          "PO Date:" + poph.PODate.ToString("dd-MM-yyyy") + "\n" +
                                          "Customer:" + poph.CustomerName + "\n" +
                                          "Are you sure to Close the document ?";
                            DialogResult dialog = MessageBox.Show(dstr, "Close PO", MessageBoxButtons.YesNo);
                            if (dialog == DialogResult.Yes)
                            {
                                if (popihdb.ClosePOPI2(poph))
                                {
                                    MessageBox.Show("PO Closed");
                                    btnView.PerformClick();
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(this.ToString() + "-" + System.Reflection.MethodBase.GetCurrentMethod().Name + "() : Error");
            }
        }
Esempio n. 2
0
 private void ShowAllDetails()
 {
     try
     {
         PurchaseOrderDB pdb = new PurchaseOrderDB();
         poheader        poh = pdb.getFilteredPurchaseOrderHeaderlist(docID, tempno, tempdate).FirstOrDefault();
         if (poh != null)
         {
             txtDocID.Text = poh.DocumentID;
             //txtTrackingNo.Text = poh.TrackingNo.ToString();
             //dtTrackingDate.Value = poh.TrackingDate;
             txtDevileryPeriod.Text    = poh.DeliveryPeriod.ToString();
             cmbCustomer.SelectedIndex = Structures.ComboFUnctions.getComboIndex(cmbCustomer, poh.CustomerID);
             txtPONo.Text                        = poh.PONo.ToString();
             dtPODate.Value                      = poh.PODate;
             cmbCurrency.SelectedIndex           = Structures.ComboFUnctions.getComboIndex(cmbCurrency, poh.CurrencyID);
             cmbPaymentMode.SelectedIndex        = Structures.ComboFUnctions.getComboIndex(cmbPaymentMode, poh.ModeOfPayment);
             cmbFreightTerms.SelectedIndex       = Structures.ComboFUnctions.getComboIndex(cmbFreightTerms, poh.FreightTerms);
             cmbTaxterms.SelectedIndex           = Structures.ComboFUnctions.getComboIndex(cmbTaxterms, poh.TaxTerms);
             cmbTransportationMode.SelectedIndex = Structures.ComboFUnctions.getComboIndex(cmbTransportationMode, poh.TransportationMode);
             txtValidityperiod.Text              = poh.validityPeriod.ToString();
             txtFreightCharge.Text               = poh.FreightCharge.ToString();
             txtpaymentTerms.Text                = getPaymentTermsExplained(poh.PaymentTerms);
             txtproductValue.Text                = poh.ProductValueINR.ToString();
             txtTaxvalue.Text                    = poh.TaxAmountINR.ToString();
             txtPOvalue.Text                     = poh.POValueINR.ToString();
         }
         poheader popd = new poheader();
         popd.DocumentID    = docID;
         popd.TemporaryNo   = tempno;
         popd.TemporaryDate = tempdate;
         List <podetail> pod = PurchaseOrderDB.getPurchaseOrderDetails(popd);
         grdPRDetail.Rows.Clear();
         int    i     = 0;
         double count = 0;
         foreach (podetail 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. 3
0
 private void GetPurchase(int purchaseOrderID)
 {
     try
     {
         purchaseOrder = PurchaseOrderDB.GetPurchase(purchaseOrderID);
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, ex.GetType().ToString());
     }
 }
Esempio n. 4
0
        private void DeleteBtn_Click(object sender, EventArgs e)
        {
            if (purchaseOrderIDTextBox.Text.Length == 0)
            {
                MessageBox.Show("Please select an order first.");
                return;
            }


            int purchaseOrderID = Convert.ToInt32(purchaseOrderIDTextBox.Text);

            this.GetPurchase(purchaseOrderID);

            DialogResult result = MessageBox.Show("Delete " + purchaseOrder.purchaseOrderID + "?",
                                                  "Confirm Delete", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (result == DialogResult.Yes)
            {
                try
                {
                    if (!PurchaseOrderDB.DeletePurchase(purchaseOrder))
                    {
                        MessageBox.Show("Another user has updated or deleted " +
                                        "that purchase order.", "Database Error");
                        this.GetPurchase(purchaseOrder.purchaseOrderID);
                        if (purchaseOrder != null)
                        {
                            this.Display();
                        }
                        else
                        {
                            this.ClearControls();
                        }
                    }
                    else
                    {
                        this.ClearControls();
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Can't delete due to referencial integrity.");
                    //MessageBox.Show(ex.Message, ex.GetType().ToString());
                }
            }
        }
Esempio n. 5
0
 private void ShowAllDetails()
 {
     if (docID == "POPRODUCTINWARD" || docID == "POPRODUCTINWARD")
     {
         try
         {
             POPIHeaderDB popihdb = new POPIHeaderDB();
             popiheader   vd      = popihdb.getPOPIHeader(tempno, tempdate, docID).FirstOrDefault();
             if (vd != null)
             {
                 txtDocID.Text             = vd.DocumentID;
                 txtTrackingNo.Text        = vd.TrackingNo.ToString();
                 dtTrackingDate.Value      = vd.TrackingDate;
                 txtrefno.Text             = vd.ReferenceNo;
                 cmbCustomer.SelectedIndex = Structures.ComboFUnctions.getComboIndex(cmbCustomer, vd.CustomerID);
                 txtPONo.Text                  = vd.CustomerPONO;
                 dtPODate.Value                = vd.CustomerPODate;
                 dtDeliveryDate.Value          = vd.DeliveryDate;
                 cmbOfficeID.SelectedIndex     = Structures.ComboFUnctions.getComboIndex(cmbOfficeID, vd.OfficeID);
                 cmbProjectID.SelectedIndex    = cmbProjectID.FindString(vd.ProjectID);
                 cmbPaymentMode.SelectedIndex  = Structures.ComboFUnctions.getComboIndex(cmbPaymentMode, vd.PaymentMode);
                 cmbFreightTerms.SelectedIndex = Structures.ComboFUnctions.getComboIndex(cmbFreightTerms, vd.FreightTerms);
                 cmbCurrency.SelectedIndex     = Structures.ComboFUnctions.getComboIndex(cmbCurrency, vd.CurrencyID);
                 txtFreightCharge.Text         = vd.FreightCharge.ToString();
                 dtValidateDate.Value          = vd.ValidityDate;
                 txtpaymentTerms.Text          = getPaymentTermsExplained(vd.PaymentTerms);
                 txtproductValue.Text          = vd.ProductValueINR.ToString();
                 txtTaxvalue.Text              = vd.TaxAmountINR.ToString();
                 txtPOvalue.Text               = vd.POValueINR.ToString();
             }
             popiheader popih = new popiheader();
             popih.DocumentID    = docID;
             popih.TemporaryNo   = tempno;
             popih.TemporaryDate = tempdate;
             List <popidetail> POPIDetail = POPIHeaderDB.getPOPIDetail(popih);
             grdPRDetail.Rows.Clear();
             int    i     = 0;
             double count = 0;
             foreach (popidetail 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.StockItemName;
                 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");
         }
     }
     else if (docID == "PURCHASEORDER")
     {
         try
         {
             PurchaseOrderDB pdb = new PurchaseOrderDB();
             poheader        poh = pdb.getFilteredPurchaseOrderHeaderlist(docID, tempno, tempdate).FirstOrDefault();
             if (poh != null)
             {
                 txtDocID.Text = poh.DocumentID;
                 //txtTrackingNo.Text = poh.TrackingNo.ToString();
                 //dtTrackingDate.Value = poh.TrackingDate;
                 //txtrefno.Text = poh.ReferenceNo;
                 cmbCustomer.SelectedIndex = Structures.ComboFUnctions.getComboIndex(cmbCustomer, poh.CustomerID);
                 //txtPONo.Text = poh.CustomerPONO;
                 //dtPODate.Value = poh.CustomerPODate;
                 //dtDeliveryDate.Value = poh.DeliveryDate;
                 //cmbOfficeID.SelectedIndex = Structures.ComboFUnctions.getComboIndex(cmbOfficeID, poh.OfficeID);
                 //cmbProjectID.SelectedIndex = cmbProjectID.FindString(poh.ProjectID);
                 //dtValidateDate.Value = poh.ValidityDate;
                 txtpaymentTerms.Text = getPaymentTermsExplained(poh.PaymentTerms);
                 txtproductValue.Text = poh.ProductValueINR.ToString();
                 txtTaxvalue.Text     = poh.TaxAmountINR.ToString();
                 txtPOvalue.Text      = poh.POValueINR.ToString();
             }
             poheader popd = new poheader();
             popd.DocumentID    = docID;
             popd.TemporaryNo   = tempno;
             popd.TemporaryDate = tempdate;
             List <podetail> pod = PurchaseOrderDB.getPurchaseOrderDetails(popd);
             grdPRDetail.Rows.Clear();
             int    i     = 0;
             double count = 0;
             foreach (podetail 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");
         }
     }
     else if (docID == "WORKORDER")
     {
         try
         {
         }
         catch (Exception ex)
         {
             MessageBox.Show("Error in WorkOrder");
         }
     }
     else if (docID == "POGENERAL")
     {
         try
         {
         }
         catch (Exception ex)
         {
             MessageBox.Show("Error in POgeneral");
         }
     }
     else if (docID == "POINVOICEIN" || docID == "WOINVOICEIN" || docID == "POGENERALINVOICEIN")
     {
         try
         {
         }
         catch (Exception ex)
         {
             MessageBox.Show("Error in InvoiceIn");
         }
     }
     else if (docID == "PRODUCTINVOICEOUT" || docID == "SERVICEINVOICEOUT")
     {
         try
         {
         }
         catch (Exception ex)
         {
             MessageBox.Show("Error in InvoiceOut");
         }
     }
 }
Esempio n. 6
0
        private void btnView_Click(object sender, EventArgs e)
        {
            grdList.Visible = true;
            grdList.Rows.Clear();
            //------
            double totalPOValue = 0.0;
            double totalInvoiceValue = 0.0;
            double balanceAmount = 0.0, Invoiceamt = 0.0, Paymntamunt = 0.0;

            //------
            //pnlAddEdit.Visible = true;
            setButtonVisibility("Edit");
            try
            {
                StringBuilder query = new StringBuilder();

                query.Append("select TemporaryNo,TemporaryDate,PONo,PODate,CustomerName,ProductValueINR from ViewPOHeader ");
                if (cmbTrack.SelectedIndex != -1)
                {
                    string str = "where PODate >= '" + dtFrom.Value.ToString("yyyy-MM-dd") + "' and PODate <='" + dtTo.Value.ToString("yyyy-MM-dd") + "'";
                    if (cmbTrack.SelectedItem.ToString() == "Open")
                    {
                        str += "and Status=1 and DocumentStatus = 99";
                    }
                    else if (cmbTrack.SelectedItem.ToString() == "Closed")
                    {
                        str += " and Status=7 and DocumentStatus = 99";
                    }
                    else
                    {
                        str += "and Status in (1,7) and DocumentStatus = 99 ";
                    }
                    query.Append(str);
                }

                if (cmbCustomer.SelectedItem.ToString() != "All")
                {
                    query.Append(" and CustomerID='" + ((Structures.ComboBoxItem)cmbCustomer.SelectedItem).HiddenValue + "'");
                }
                query.Append(" Order by PONo,PODate");
                PurchaseOrderDB        popihdb     = new PurchaseOrderDB();
                InvoiceInHeaderDB      InvoDb      = new InvoiceInHeaderDB();
                PaymentVoucherDB       PaymtvDB    = new PaymentVoucherDB();
                List <poheader>        POPIHeaders = popihdb.ListPopiFilters2(query.ToString());
                List <MRNHeader2>      pop         = popihdb.getMRNHeaderdata();
                List <invoiceinheader> Invoices    = InvoDb.getInvoicedata();
                List <paymentvoucher>  Payments    = PaymtvDB.getPaymentdata();
                foreach (poheader popih in POPIHeaders)
                {
                    grdList.Rows.Add();
                    grdList.Rows[grdList.RowCount - 1].Cells["gTemporaryNo"].Value     = popih.TemporaryNo;
                    grdList.Rows[grdList.RowCount - 1].Cells["gTemporaryDate"].Value   = popih.TemporaryDate;
                    grdList.Rows[grdList.RowCount - 1].Cells["gTrackingNo"].Value      = popih.PONo;
                    grdList.Rows[grdList.RowCount - 1].Cells["gTrackingDate"].Value    = popih.PODate;
                    grdList.Rows[grdList.RowCount - 1].Cells["gCustomerName"].Value    = popih.CustomerName;
                    grdList.Rows[grdList.RowCount - 1].Cells["POValueINR"].Value       = popih.ProductValueINR;
                    grdList.Rows[grdList.RowCount - 1].Cells["TotalValueBilled"].Value = 0;
                    totalPOValue += popih.ProductValueINR;
                    if (popih.PONo != 0 && popih.PODate != DateTime.MinValue)
                    {
                        var        results = pop.Where(oh => oh.PONos.Contains("" + popih.PONo + "") && oh.PODates.Contains("" + popih.PODate.ToString("yyyy-MM-dd") + "")).ToList();
                        int[]      MRNNos  = results.Select(i => i.MRNNo).ToArray();
                        DateTime[] MrnDats = results.Select(i => i.MRNDate).ToArray();
                        var        AVC     = from x in Invoices
                                             where MRNNos.Contains(x.MRNNo) && MrnDats.Contains(x.MRNDate)
                                             select x;
                        string [] ABCCD = AVC.Select(i => i.DocumentID.ToString() + Main.delimiter1 + i.DocumentNo.ToString() + Main.delimiter1 + i.DocumentDate.ToString("yyyy-MM-dd") + Main.delimiter2).ToArray();
                        var       AVC2  = from x in Payments
                                          where ABCCD.Contains(x.BillDetails)
                                          select x;

                        double iamt = results.Sum(item => item.MRNValue);
                        Invoiceamt  = AVC.Sum(item => item.InvoiceValueINR);
                        Paymntamunt = AVC2.Sum(item => Convert.ToDouble(item.VoucherAmountINR));


                        grdList.Rows[grdList.RowCount - 1].Cells["TotalValueBilled"].Value = iamt;
                        totalInvoiceValue += iamt;
                    }
                    balanceAmount = Convert.ToDouble(grdList.Rows[grdList.RowCount - 1].Cells["POValueINR"].Value) - Convert.ToDouble(grdList.Rows[grdList.RowCount - 1].Cells["TotalValueBilled"].Value);
                    grdList.Rows[grdList.RowCount - 1].Cells["BalanceAmount"].Value = balanceAmount;
                    grdList.Rows[grdList.RowCount - 1].Cells["InvoiceAmt"].Value    = Invoiceamt;
                    grdList.Rows[grdList.RowCount - 1].Cells["Payamt"].Value        = Paymntamunt;
                    grdList.Rows[grdList.RowCount - 1].Cells["AmtBalance"].Value    = Invoiceamt - Paymntamunt;;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error in PO Product Inward Report Listing");
                grdList.Rows.Clear();
            }
            if (grdList.Rows.Count <= 0)
            {
                btnExportToExcel.Visible = false;
                grdList.Visible          = false;
                pnlTotal.Visible         = false;
                MessageBox.Show("No Data to Show");
            }
            else
            {
                lblPOValue.Text      = Math.Round(totalPOValue / 100000, 2).ToString() + " Lakhs";
                lblBilledValue.Text  = Math.Round(totalInvoiceValue / 100000, 2).ToString() + " Lakhs";
                lblBalanceValue.Text = Math.Round((totalPOValue - totalInvoiceValue) / 100000, 2).ToString() + " Lakhs";
                lblPOCount.Text      = " PO Count:" + grdList.Rows.Count;
                pnlTotal.Visible     = true;
            }
        }
Esempio n. 7
0
        private DataGridView fillgrddetail(poheader poph)
        {
            DataGridView grdDetail = new DataGridView();

            try
            {
                grdDetail.RowHeadersVisible = false;

                DataGridViewTextBoxColumn dgvtx0 = new DataGridViewTextBoxColumn();
                dgvtx0.Width   = 50;
                dgvtx0.Name    = "SlNo";
                dgvtx0.Visible = true;
                grdDetail.Columns.Add(dgvtx0);

                DataGridViewTextBoxColumn dgvtx1 = new DataGridViewTextBoxColumn();
                dgvtx1.Name    = "LineNo";
                dgvtx1.Visible = false;
                grdDetail.Columns.Add(dgvtx1);

                DataGridViewTextBoxColumn dgvtx2 = new DataGridViewTextBoxColumn();
                dgvtx2.Width = 200;
                dgvtx2.Name  = "Product";
                grdDetail.Columns.Add(dgvtx2);

                DataGridViewTextBoxColumn dgvtx3 = new DataGridViewTextBoxColumn();
                dgvtx3.Width = 200;
                dgvtx3.Name  = "Description";
                grdDetail.Columns.Add(dgvtx3);

                DataGridViewTextBoxColumn dgvtx4 = new DataGridViewTextBoxColumn();
                dgvtx4.Width = 80;
                dgvtx4.Name  = "MRNNo";
                grdDetail.Columns.Add(dgvtx4);

                DataGridViewTextBoxColumn dgvtx5 = new DataGridViewTextBoxColumn();
                dgvtx5.Width = 100;
                dgvtx5.Name  = "MRNDate";
                grdDetail.Columns.Add(dgvtx5);

                DataGridViewTextBoxColumn dgvtx7 = new DataGridViewTextBoxColumn();
                dgvtx7.Width = 70;
                dgvtx7.DefaultCellStyle.Format = "N0";
                dgvtx7.Name = "Quantity";
                grdDetail.Columns.Add(dgvtx7);

                DataGridViewTextBoxColumn dgvtx8 = new DataGridViewTextBoxColumn();
                dgvtx8.Width = 70;
                dgvtx8.DefaultCellStyle.Format = "N2";
                dgvtx8.Name = "Price";
                grdDetail.Columns.Add(dgvtx8);

                DataGridViewTextBoxColumn dgvtx9 = new DataGridViewTextBoxColumn();
                dgvtx9.DefaultCellStyle.Format = "N2";
                dgvtx9.Name = "Value";
                grdDetail.Columns.Add(dgvtx9);

                DataGridViewTextBoxColumn dgvtx10 = new DataGridViewTextBoxColumn();
                dgvtx10.Width = 70;
                dgvtx10.DefaultCellStyle.Format = "N0";
                dgvtx10.Name       = "BilledQty";
                dgvtx10.HeaderText = "Recived Qty";
                grdDetail.Columns.Add(dgvtx10);

                DataGridViewTextBoxColumn dgvtx11 = new DataGridViewTextBoxColumn();
                dgvtx11.Width = 70;
                dgvtx11.DefaultCellStyle.Format = "N0";
                dgvtx11.Name       = "BalanceQty";
                dgvtx11.HeaderText = "Balance Qty";
                grdDetail.Columns.Add(dgvtx11);

                {
                    List <podetail> POPIDetail = PurchaseOrderDB.getPOPIDetailqty2(poph);
                    grdDetail.Rows.Clear();

                    var results = from p in POPIDetail
                                  group p by p.RowID into g
                                  select new
                    {
                        RowId          = g.Key,
                        StockItemName  = g.FirstOrDefault().StockItemName,
                        Description    = g.FirstOrDefault().Description,
                        Quantity       = g.FirstOrDefault().Quantity,
                        Price          = g.FirstOrDefault().Price,
                        BilledQuantity = g.Sum(S => S.BilledQuantity),
                        MRNNo          = g.Select(S => S.MRNNo).ToArray(),
                        MRNDate        = g.Select(S => S.MRNDate).ToArray()
                    };


                    int i = 0;
                    foreach (var popid in results)
                    {
                        try
                        {
                            grdDetail.Rows.Add();
                            grdDetail.Rows[i].Cells["SLNo"].Value        = grdDetail.RowCount - 1;
                            grdDetail.Rows[i].Cells["LineNo"].Value      = popid.RowId;
                            grdDetail.Rows[i].Cells["Product"].Value     = popid.StockItemName;
                            grdDetail.Rows[i].Cells["Description"].Value = popid.Description;
                            grdDetail.Rows[i].Cells["MRNNo"].Value       = string.Join(",", popid.MRNNo);
                            grdDetail.Rows[i].Cells["MRNDate"].Value     = string.Join(",", popid.MRNDate);
                            grdDetail.Rows[i].Cells["Quantity"].Value    = popid.Quantity;
                            grdDetail.Rows[i].Cells["Description"].Value = popid.Description;
                            grdDetail.Rows[i].Cells["Price"].Value       = popid.Price;
                            grdDetail.Rows[i].Cells["Value"].Value       = popid.Quantity * popid.Price;
                            grdDetail.Rows[i].Cells["BilledQty"].Value   = popid.BilledQuantity;
                            grdDetail.Rows[i].Cells["BalanceQty"].Value  = Convert.ToDouble(popid.Quantity) - Convert.ToDouble(popid.BilledQuantity);
                            i++;
                            // productvalue = productvalue + popid.Quantity * popid.Price;
                            //  taxvalue = taxvalue + popid.Tax;
                        }

                        catch (Exception ex)
                        {
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error in PO Quantity filling");
            }
            return(grdDetail);
        }
Esempio n. 8
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");
            }
        }