Exemplo n.º 1
0
 private void btnFinalize_Click(object sender, EventArgs e)
 {
     try
     {
         StockOBNewDB sobdb  = new StockOBNewDB();
         DialogResult dialog = MessageBox.Show("Are you sure to Finalize the document ?", "Yes", MessageBoxButtons.YesNo);
         if (dialog == DialogResult.Yes)
         {
             if (sobdb.FinalizeStockOB(prevsboh))
             {
                 MessageBox.Show(" Document Finalized");
                 closeAllPanels();
                 listOption = 1;
                 FilteredStockOBList(listOption);
                 setButtonVisibility("btnEditPanel"); //activites are same for cance, forward,approce and reverse
             }
             else
             {
                 MessageBox.Show("Failed to Finalize");
             }
         }
     }
     catch (Exception)
     {
     }
 }
Exemplo n.º 2
0
        private void FilteredStockOBList(int opt)
        {
            try
            {
                grdList.Rows.Clear();
                StockOBNewDB            AccDB  = new StockOBNewDB();
                List <stockObNewHeader> SBList = StockOBNewDB.getStockOblist(opt);
                if (opt == 1)
                {
                    lblActionHeader.Text = "List of Action Pending Documents";
                }
                //else if (opt == 2)
                //    lblActionHeader.Text = "List of Approved Documents";
                else if (opt == 2 || opt == 6)
                {
                    lblActionHeader.Text = "List of Approved Documents";
                }
                foreach (stockObNewHeader sobh in SBList)
                {
                    grdList.Rows.Add();
                    grdList.Rows[grdList.RowCount - 1].Cells["DocumentID"].Value     = sobh.DocumentID;
                    grdList.Rows[grdList.RowCount - 1].Cells["DocumentNo"].Value     = sobh.DocumentNo;
                    grdList.Rows[grdList.RowCount - 1].Cells["DocumentName"].Value   = sobh.DocumentName;
                    grdList.Rows[grdList.RowCount - 1].Cells["DocumentDate"].Value   = sobh.DocumentDate;
                    grdList.Rows[grdList.RowCount - 1].Cells["FYID"].Value           = sobh.FYID;
                    grdList.Rows[grdList.RowCount - 1].Cells["StoreLocation"].Value  = sobh.StoreLocation;
                    grdList.Rows[grdList.RowCount - 1].Cells["Value"].Value          = sobh.Value;
                    grdList.Rows[grdList.RowCount - 1].Cells["Status"].Value         = sobh.Status;
                    grdList.Rows[grdList.RowCount - 1].Cells["DocumentStatus"].Value = sobh.DocumentStatus;
                    grdList.Rows[grdList.RowCount - 1].Cells["CreateTime"].Value     = sobh.CreateTime;
                    grdList.Rows[grdList.RowCount - 1].Cells["CreateUser"].Value     = sobh.CreateUser;
                    grdList.Rows[grdList.RowCount - 1].Cells["Creator"].Value        = sobh.CreatorName;
                    grdList.Rows[grdList.RowCount - 1].Cells["Remarks"].Value        = sobh.Remarks;
                    grdList.Rows[grdList.RowCount - 1].Cells["TransferStatus"].Value = sobh.Transferstatus;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error in StockOB Listing");
            }
            setButtonVisibility("init");
            pnlList.Visible = true;

            try
            {
                grdList.Columns["gCreateUser"].Visible = true;
                grdList.Columns["Creator"].Visible     = true;
            }
            catch (Exception ex)
            {
            }
        }
Exemplo n.º 3
0
        private void btnTransfer_Click(object sender, EventArgs e)
        {
            string FYID = cmbFY.SelectedItem.ToString().Trim().Substring(0, cmbFY.SelectedItem.ToString().Trim().IndexOf(':')).Trim();

            if (!StockOBNewDB.checkAvailabilityOfFY(FYID))
            {
                DialogResult dialog = MessageBox.Show("Stock For this year is available , Are you sure to Transfer ?", "Yes", MessageBoxButtons.YesNo);
                if (dialog == DialogResult.Yes)
                {
                    List <stockObNewHeader> SBList = StockOBNewDB.getStockOblistForTransfer(FYID);
                    if (StockOBNewDB.TransferStockOB(SBList, FYID))
                    {
                        if (StockOBNewDB.changeTransferStatus(FYID))
                        {
                            MessageBox.Show("stock Updated");
                            listStockOBList(FYID);
                        }
                        else
                        {
                            MessageBox.Show("Failed to Update Transfer Status");
                        }
                    }
                    else
                    {
                        MessageBox.Show("Failed to Update Stock");
                    }
                }
            }
            else
            {
                List <stockObNewHeader> SBList = StockOBNewDB.getStockOblistForTransfer(FYID);
                if (StockOBNewDB.TransferStockOB(SBList, FYID))
                {
                    if (StockOBNewDB.changeTransferStatus(FYID))
                    {
                        MessageBox.Show("stock Updated");
                        listStockOBList(FYID);
                    }
                    else
                    {
                        MessageBox.Show("Failed to Update Transfer Status");
                    }
                }
                else
                {
                    MessageBox.Show("Failed to Update Stock");
                }
            }
        }
Exemplo n.º 4
0
 private void listStockOBList(string FYID)
 {
     try
     {
         grdList.Rows.Clear();
         StockOBNewDB            AccDB  = new StockOBNewDB();
         List <stockObNewHeader> SBList = StockOBNewDB.getStockOblist(3);
         int i = 1;
         foreach (stockObNewHeader sobh in SBList)
         {
             if (sobh.FYID.Equals(FYID))
             {
                 grdList.Rows.Add();
                 grdList.Rows[grdList.RowCount - 1].Cells["LineNo"].Value            = i;
                 grdList.Rows[grdList.RowCount - 1].Cells["FYID"].Value              = sobh.FYID;
                 grdList.Rows[grdList.RowCount - 1].Cells["DocumentNo"].Value        = sobh.DocumentNo;
                 grdList.Rows[grdList.RowCount - 1].Cells["DocumentDate"].Value      = sobh.DocumentDate;//.ToString("dd-MM-yyyy");
                 grdList.Rows[grdList.RowCount - 1].Cells["StoreLocation"].Value     = sobh.StoreLocation;
                 grdList.Rows[grdList.RowCount - 1].Cells["StoreLocationName"].Value = sobh.StoreLocationName;
                 grdList.Rows[grdList.RowCount - 1].Cells["Value"].Value             = sobh.Value;
                 i++;
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("Error in Stock OB Listing");
     }
     try
     {
         enableBottomButtons();
         grdList.Visible = true;
         pnlList.Visible = true;
         //btnNew.Visible = false;
     }
     catch (Exception ex)
     {
     }
 }
Exemplo n.º 5
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("Finalize") || columnName.Equals("Edit") || columnName.Equals("View"))
                {
                    clearData();
                    setButtonVisibility(columnName);
                    docID = grdList.Rows[e.RowIndex].Cells[0].Value.ToString();
                    int rowID = e.RowIndex;
                    btnSave.Text = "Update";
                    DataGridViewRow row = grdList.Rows[rowID];
                    prevsboh               = new stockObNewHeader();
                    prevsboh.DocumentID    = grdList.Rows[e.RowIndex].Cells["DocumentID"].Value.ToString();
                    prevsboh.DocumentNo    = Convert.ToInt32(grdList.Rows[e.RowIndex].Cells["DocumentNo"].Value.ToString());
                    prevsboh.DocumentDate  = DateTime.Parse(grdList.Rows[e.RowIndex].Cells["DocumentDate"].Value.ToString());
                    prevsboh.FYID          = grdList.Rows[e.RowIndex].Cells["FYID"].Value.ToString();
                    prevsboh.StoreLocation = grdList.Rows[e.RowIndex].Cells["StoreLocation"].Value.ToString();

                    prevsboh.Value        = Convert.ToInt32(grdList.Rows[e.RowIndex].Cells["Value"].Value.ToString());
                    prevsboh.Remarks      = grdList.Rows[e.RowIndex].Cells["Remarks"].Value.ToString();
                    txtDocNo.Text         = prevsboh.DocumentNo.ToString();
                    dtDocDate.Value       = prevsboh.DocumentDate;
                    cmbFYID.SelectedIndex = cmbFYID.FindString(prevsboh.FYID);

                    cmbStoreLocation.SelectedIndex =
                        Structures.ComboFUnctions.getComboIndex(cmbStoreLocation, prevsboh.StoreLocation);
                    //cmbStoreLocation.SelectedIndex = cmbStoreLocation.FindString(prevsboh.StoreLocation);
                    txtRemarks.Text = prevsboh.Remarks;
                    dtDocDate.Value = prevsboh.DocumentDate;
                    //txtcredittotal.Text = prevsboh.Value.ToString();
                    List <stockObNewDetail> sobdetail = StockOBNewDB.getstockObNewDetail(prevsboh);
                    grdStockOBDetail.Rows.Clear();
                    int    i  = 0;
                    double dd = 0;
                    foreach (stockObNewDetail sobd in sobdetail)
                    {
                        if (!AddStockOBDetailRow())
                        {
                            MessageBox.Show("Error found in stock Detail. Please correct before updating the details");
                        }
                        else
                        {
                            grdStockOBDetail.Rows[i].Cells["LineNo"].Value        = i + 1;
                            grdStockOBDetail.Rows[i].Cells["item"].Value          = sobd.StockItemID;
                            grdStockOBDetail.Rows[i].Cells["Description"].Value   = sobd.StockItemName;
                            grdStockOBDetail.Rows[i].Cells["ModelNo"].Value       = sobd.ModelNo;
                            grdStockOBDetail.Rows[i].Cells["ModelName"].Value     = sobd.ModelName;
                            grdStockOBDetail.Rows[i].Cells["Quantity"].Value      = sobd.Quantity;
                            grdStockOBDetail.Rows[i].Cells["PurchasePrice"].Value = sobd.Price;
                            grdStockOBDetail.Rows[i].Cells["ItemValue"].Value     = sobd.Quantity * sobd.Price;

                            dd = dd + Convert.ToDouble(grdStockOBDetail.Rows[i].Cells["ItemValue"].Value);
                            i++;
                        }
                    }
                    txtcredittotal.Text    = dd.ToString();;
                    btnSave.Text           = "Update";
                    pnlList.Visible        = false;
                    txtcredittotal.Visible = true;
                    lbltotal.Visible       = true;
                    pnlAddEdit.Visible     = true;
                    btnSave.Text           = "Update";
                    pnlList.Visible        = false;
                    pnlAddEdit.Visible     = true;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(this.ToString() + "-" + System.Reflection.MethodBase.GetCurrentMethod().Name + "() : Error");
            }
        }
Exemplo n.º 6
0
        private void btnSave_Click_1(object sender, EventArgs e)
        {
            Boolean status = true;

            try
            {
                StockOBNewDB                sobDB = new StockOBNewDB();
                stockObNewHeader            sobh  = new stockObNewHeader();
                System.Windows.Forms.Button btn   = sender as System.Windows.Forms.Button;
                string btnText = btnSave.Text;
                if (!verifyAndReworkAccGridRows())
                {
                    MessageBox.Show("Error found in StockOB details. Please correct before updating the details");
                    return;
                }
                try
                {
                    sobh.DocumentID = docID;
                    sobh.FYID       = cmbFYID.SelectedItem.ToString().Trim().Substring(0, cmbFYID.SelectedItem.ToString().Trim().IndexOf(':')).Trim();
                    //sobh.StoreLocation = cmbStoreLocation.SelectedItem.ToString().Substring(0, cmbStoreLocation.SelectedItem.ToString().IndexOf('-'));
                    sobh.StoreLocation = ((Structures.ComboBoxItem)cmbStoreLocation.SelectedItem).HiddenValue;
                    sobh.Remarks       = txtRemarks.Text;
                    sobh.Value         = Convert.ToDouble(txtcredittotal.Text);
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Validation failed");
                    status = false;
                    return;
                }
                if (btnText.Equals("Save"))
                {
                    // sobh.DocumentNo = DocumentNumberDB.getNewNumber(docID, 1);
                    sobh.DocumentStatus = 1;
                    sobh.DocumentDate   = UpdateTable.getSQLDateTime();
                }
                else
                {
                    sobh.DocumentNo     = Convert.ToInt32(txtDocNo.Text);
                    sobh.DocumentStatus = prevsboh.DocumentStatus;
                    sobh.DocumentDate   = prevsboh.DocumentDate;
                }
                if (!sobDB.validateStockOB(sobh))
                {
                    MessageBox.Show("Validation Failed");
                    status = false;
                    return;
                }

                if (btnText.Equals("Save"))
                {
                    if (!sobDB.verifyFYLoc(sobh.FYID, sobh.StoreLocation))
                    {
                        MessageBox.Show("For this Financial Year and Location Document already Available.Reenter not allow.");
                        return;
                    }
                    List <stockObNewDetail> StockList = getStockOBDetails(sobh);
                    if (sobDB.InsertStockHeaderAndDetail(sobh, StockList))
                    {
                        MessageBox.Show("Details Added");
                        closeAllPanels();
                        listOption = 1;
                        FilteredStockOBList(listOption);
                        pnlAddEdit.Visible = false;
                    }
                    else
                    {
                        MessageBox.Show("Failed to insert StockOB Detail");
                        status = false;
                    }
                    if (!status)
                    {
                        MessageBox.Show("Failed to Insert");
                        status = false;
                    }
                }
                else if (btnText.Equals("Update"))
                {
                    List <stockObNewDetail> StockList = getStockOBDetails(sobh);
                    if (sobDB.updateStockHeaderAndDetail(sobh, StockList))
                    {
                        MessageBox.Show(" details updated");
                        closeAllPanels();
                        listOption = 1;
                        FilteredStockOBList(listOption);
                    }

                    else
                    {
                        status = false;
                    }
                    if (!status)
                    {
                        MessageBox.Show("Failed to update");
                    }
                }
                else
                {
                    MessageBox.Show("Validation failed");
                    status = false;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Validation failed");
                status = false;
            }
            if (status)
            {
                setButtonVisibility("btnEditPanel"); //activites are same for cancel, forward,approve, reverse and save
            }
        }