Пример #1
0
 /// <summary>
 /// Function to add the products to grid
 /// </summary>
 public void AddToGrid()
 {
     BatchBll BllBatch = new BatchBll();
     GodownBll BllGodown = new GodownBll();
     try
     {
         SettingsBll BllSettings = new SettingsBll();
         if (txtProductCode.Text.Trim() == null && txtProductCode.Text.Trim() == string.Empty)
         {
             Messages.InformationMessage("Enter product code");
             txtProductCode.Focus();
         }
         else if (cmbItem.SelectedIndex == -1 && cmbItem.SelectedValue == null)
         {
             Messages.InformationMessage("Select a product");
             cmbItem.Focus();
         }
         else if (Convert.ToDecimal(txtQuantity.Text.Trim()) <= 0 || txtQuantity.Text.Trim() == string.Empty)
         {
             Messages.InformationMessage("Enter quantity");
             txtQuantity.Focus();
         }
         else if (cmbUnit.SelectedValue == null)
         {
             Messages.InformationMessage("Select a unit");
             cmbUnit.Focus();
         }
         else if (BllSettings.SettingsStatusCheck("AllowZeroValueEntry") == "No" && decimal.Parse(txtRate.Text.Trim()) <= 0 || txtRate.Text.Trim() == string.Empty)
         {
             Messages.InformationMessage("Enter rate");
             txtRate.Focus();
         }
         else
         {
             int inCurrentRowIndex = new int();
             bool isExecutef = false;
             if (rowIdToEdit == 0)
             {
                 dgvPointOfSales.Rows.Add();
                 inCurrentRowIndex = dgvPointOfSales.Rows.Count - 1;
                 isExecutef = true;
             }
             else
             {
                 for (int i = 0; i < dgvPointOfSales.Rows.Count; ++i)
                 {
                     if (dgvPointOfSales.Rows[i].Cells["rowId"].Value.ToString() == rowIdToEdit.ToString())
                     {
                         isExecutef = true;
                         inCurrentRowIndex = i;
                         break;
                     }
                 }
             }
             if (!isExecutef)
             {
                 dgvPointOfSales.Rows.Add();
                 inCurrentRowIndex = dgvPointOfSales.Rows.Count - 1;
             }
             ProductInfo infoProduct = new ProductInfo();
             BatchInfo infoBatch = new BatchInfo();
             RackInfo infoRack = new RackInfo();
             ProductCreationBll BllProductCreation = new ProductCreationBll();
             UnitConvertionInfo InfoUnitConvertion = new UnitConvertionInfo();
             infoProduct = BllProductCreation.ProductView(decProductId);
             decimal dcProductBatch = BllBatch.BatchIdViewByProductId(decProductId);
             InfoUnitConvertion = new UnitConvertionBll().UnitViewAllByProductId(decProductId);
             infoBatch = BllBatch.BatchView(dcProductBatch);
             decimal dcGodownId = infoProduct.GodownId;
             GodownInfo infoGodown = new GodownInfo();
             infoGodown = BllGodown.GodownView(dcGodownId);
             decimal dcRackId = infoProduct.RackId;
             infoRack = new RackBll().RackView(dcRackId);
             dgvPointOfSales.Rows[inCurrentRowIndex].Cells["dgvtxtProductCode"].Value = txtProductCode.Text;
             dgvPointOfSales.Rows[inCurrentRowIndex].Cells["dgvtxtProductName"].Value = cmbItem.Text;
             dgvPointOfSales.Rows[inCurrentRowIndex].Cells["dgvtxtQuantity"].Value = txtQuantity.Text;
             dgvPointOfSales.Rows[inCurrentRowIndex].Cells["dgvtxtUnit"].Value = cmbUnit.Text;
             dgvPointOfSales.Rows[inCurrentRowIndex].Cells["dgvtxtRate"].Value = txtRate.Text;
             dgvPointOfSales.Rows[inCurrentRowIndex].Cells["dgvtxtGrossValue"].Value = txtGrossValue.Text;
             dgvPointOfSales.Rows[inCurrentRowIndex].Cells["dgvtxtTaxPercentage"].Value = cmbTax.Text;
             dgvPointOfSales.Rows[inCurrentRowIndex].Cells["dgvtxtTaxAmount"].Value = txtTaxAmount.Text;
             dgvPointOfSales.Rows[inCurrentRowIndex].Cells["dgvtxtNetAmount"].Value = txtNetAmount.Text;
             dgvPointOfSales.Rows[inCurrentRowIndex].Cells["dgvtxtDiscount"].Value = txtDiscountAmount.Text;
             dgvPointOfSales.Rows[inCurrentRowIndex].Cells["dgvtxtTotalAmount"].Value = txtAmount.Text;
             dgvPointOfSales.Rows[inCurrentRowIndex].Cells["dgvtxttaxid"].Value = Convert.ToDecimal(cmbTax.SelectedValue);
             dgvPointOfSales.Rows[inCurrentRowIndex].Cells["dgvtxtProductId"].Value = infoProduct.ProductId;
             dgvPointOfSales.Rows[inCurrentRowIndex].Cells["dgvtxtBatchId"].Value = dcProductBatch;
             dgvPointOfSales.Rows[inCurrentRowIndex].Cells["dgvtxtRackId"].Value = infoProduct.RackId;
             dgvPointOfSales.Rows[inCurrentRowIndex].Cells["dgvtxtGodownId"].Value = infoProduct.GodownId;
             dgvPointOfSales.Rows[inCurrentRowIndex].Cells["dgvtxtUnitId"].Value = Convert.ToDecimal(cmbUnit.SelectedValue);
             dgvPointOfSales.Rows[inCurrentRowIndex].Cells["dgvtxtunitconversionId"].Value = InfoUnitConvertion.UnitconvertionId;
             dgvPointOfSales.Rows[inCurrentRowIndex].Cells["dgvtxtBarcode"].Value = txtBarcode.Text;
             dgvPointOfSales.Rows[inCurrentRowIndex].Cells["dgvtxtBatchno"].Value = infoBatch.BatchNo;
             dgvPointOfSales.Rows[inCurrentRowIndex].Cells["dgvtxtGodownName"].Value = infoGodown.GodownName;
             dgvPointOfSales.Rows[inCurrentRowIndex].Cells["dgvtxtRackName"].Value = infoRack.RackName;
             TotalAmountCalculation();
             ClearGroupbox();
             dgvPointOfSales.CurrentCell = dgvPointOfSales[0, dgvPointOfSales.Rows.Count - 1];
             txtBarcode.Focus();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("POS:34" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
        /// <summary>
        /// On cellLeave of dgvProduct
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void dgvProduct_CellLeave(object sender, DataGridViewCellEventArgs e)
        {
            BatchBll BllBatch = new BatchBll();
            PurchaseOrderBll BllPurchaseOrder = new PurchaseOrderBll();

            try
            {
                if (isValueChange)
                {
                    string strBarcode = string.Empty;
                    string strProductCode = string.Empty;
                    if (e.RowIndex > -1 && e.ColumnIndex > -1)
                    {
                        CheckInvalidEntries(e);
                        if (e.ColumnIndex == dgvProduct.Columns["dgvcmbBatch"].Index)
                        {
                            if (dgvProduct.Rows[e.RowIndex].Cells["productId"].Value != null && dgvProduct.Rows[e.RowIndex].Cells["productId"].Value.ToString() != string.Empty)
                            {
                                if (dgvProduct.Rows[e.RowIndex].Cells["dgvcmbBatch"].Value != null && dgvProduct.Rows[e.RowIndex].Cells["dgvcmbBatch"].Value.ToString() != string.Empty)
                                {
                                    if (Convert.ToString(dgvProduct.Rows[e.RowIndex].Cells["dgvcmbBatch"].Value) != string.Empty &&
                                       Convert.ToString(dgvProduct.Rows[e.RowIndex].Cells["dgvcmbBatch"].Value) != "0")
                                    {
                                        decBatchId = Convert.ToDecimal(dgvProduct.Rows[e.RowIndex].Cells["dgvcmbBatch"].Value);
                                        strProductCode = dgvProduct.Rows[e.RowIndex].Cells["dgvtxtProductCode"].Value.ToString();
                                        strBarcode = BllBatch.ProductBatchBarcodeViewByBatchId(decBatchId);
                                        dgvProduct.Rows[e.RowIndex].Cells["dgvtxtBarcode"].Value = strBarcode;
                                        dgvProduct.Rows[e.RowIndex].Cells["dgvtxtProductCode"].Value = strProductCode;
                                    }
                                }
                            }
                        }
                        else if (dgvProduct.Columns[e.ColumnIndex].Name == "dgvcmbUnit")
                        {
                            if (dgvProduct.Rows[e.RowIndex].Cells["dgvcmbUnit"].Value != null && dgvProduct.Rows[e.RowIndex].Cells["dgvcmbUnit"].Value.ToString() != string.Empty)
                            {
                                UnitConvertionBll bllUnitByProduct = new UnitConvertionBll();
                                List<DataTable> listUnitByProduct = new List<DataTable>();
                                listUnitByProduct = bllUnitByProduct.UnitConversionIdAndConRateViewallByProductId(dgvProduct.Rows[e.RowIndex].Cells["productId"].Value.ToString());
                                foreach (DataRow drUnitByProduct in listUnitByProduct[0].Rows)
                                {
                                    if (dgvProduct.Rows[e.RowIndex].Cells["dgvcmbUnit"].Value.ToString() == drUnitByProduct.ItemArray[0].ToString())
                                    {
                                        dgvProduct.Rows[e.RowIndex].Cells["dgvtxtUnitConversionId"].Value = Convert.ToDecimal(drUnitByProduct.ItemArray[2].ToString());
                                        dgvProduct.Rows[e.RowIndex].Cells["dgvtxtConversionRate"].Value = Convert.ToDecimal(drUnitByProduct.ItemArray[3].ToString());
                                        if (isDoAfterGridFill)
                                        {
                                            decimal decNewConversionRate = Convert.ToDecimal(dgvProduct.Rows[e.RowIndex].Cells["dgvtxtConversionRate"].Value.ToString());
                                            decimal decNewRate = (decCurrentRate * decCurrentConversionRate) / decNewConversionRate;
                                            dgvProduct.Rows[e.RowIndex].Cells["dgvtxtRate"].Value = Math.Round(decNewRate, 2);
                                            NewAmountCalculation("dgvtxtQty", e.RowIndex);
                                            CalculateTotalAmount();
                                        }
                                    }
                                }
                                CheckInvalidEntries(e);
                            }
                        }
                        else if (dgvProduct.Columns[e.ColumnIndex].Name == "dgvcmbGodown")
                        {
                            if (dgvProduct.Rows[e.RowIndex].Cells["dgvcmbGodown"].Value != null && dgvProduct.Rows[e.RowIndex].Cells["dgvcmbGodown"].Value.ToString() != string.Empty)
                            {
                                decGodownId = Convert.ToDecimal(dgvProduct.CurrentRow.Cells["dgvcmbGodown"].Value);
                                RackComboFill(decGodownId, e.RowIndex, dgvProduct.Rows[e.RowIndex].Cells["dgvCmbRack"].ColumnIndex);
                                List<DataTable> listObj = new List<DataTable>();
                                RackBll BllRack = new RackBll();
                                listObj = BllRack.RackNamesCorrespondingToGodownId(decGodownId);
                                dgvProduct.Rows[e.RowIndex].Cells["dgvCmbRack"].Value = Convert.ToDecimal(listObj[0].Rows[0]["rackId"].ToString());
                            }
                            CheckInvalidEntries(e);
                        }
                        else if (dgvProduct.Columns[e.ColumnIndex].Name == "dgvCmbCurrency" && isAmountcalc)
                        {
                            ExchangeRateBll BllExchangeRate = new ExchangeRateBll();
                            if (dgvProduct.Rows[e.RowIndex].Cells["dgvCmbCurrency"].Value != null && Convert.ToString(dgvProduct.Rows[e.RowIndex].Cells["dgvCmbCurrency"].Value) != string.Empty)
                            {
                                dgvProduct.Rows[e.RowIndex].Cells["dgvtxtExchangeRate"].Value = BllExchangeRate.GetExchangeRateByExchangeRateId(Convert.ToDecimal(Convert.ToString(dgvProduct.Rows[e.RowIndex].Cells["dgvCmbCurrency"].Value)));
                            }
                            else
                            {
                                dgvProduct.Rows[e.RowIndex].Cells["dgvCmbCurrency"].Value = BllPurchaseOrder.ExchangeRateIdByCurrencyId(PublicVariables._decCurrencyId);
                                dgvProduct.Rows[e.RowIndex].Cells["dgvtxtExchangeRate"].Value = BllExchangeRate.GetExchangeRateByExchangeRateId(Convert.ToDecimal(Convert.ToString(dgvProduct.Rows[e.RowIndex].Cells["dgvCmbCurrency"].Value)));
                            }
                            CheckInvalidEntries(e);
                        }
                        //----------while changing Qty,corresponding change in amount--------
                        else if (dgvProduct.Columns[e.ColumnIndex].Name == "dgvtxtQty" && isAmountcalc)
                        {
                            if (dgvProduct.Rows[e.RowIndex].Cells["dgvtxtProductCode"].Value != null && dgvProduct.Rows[e.RowIndex].Cells["dgvtxtProductName"].Value != null)
                            {
                                if (dgvProduct.Rows[e.RowIndex].Cells["dgvtxtProductCode"].Value.ToString() != string.Empty && dgvProduct.Rows[e.RowIndex].Cells["dgvtxtProductName"].Value.ToString() != string.Empty)
                                {
                                    NewAmountCalculation("dgvtxtQty", e.RowIndex);
                                    CalculateTotalAmount();
                                }
                            }
                            CheckInvalidEntries(e);
                        }
                        //---------------while changing Qty,corresponding change in amount----
                        else if (dgvProduct.Columns[e.ColumnIndex].Name == "dgvtxtRate" && isAmountcalc)
                        {
                            NewAmountCalculation("dgvtxtRate", e.RowIndex);
                            CalculateTotalAmount();
                            CheckInvalidEntries(e);
                        }
                        //----while changing amount ,corresponding chnage in total amount-------
                        else if (dgvProduct.Columns[e.ColumnIndex].Name == "dgvtxtAmount" && isAmountcalc)
                        {
                            if (cmbcurrency.Text != string.Empty)
                            {
                                CalculateTotalAmount();
                            }
                        }
                        //}
                    }
                }
                CheckInvalidEntries(e);
            }
            catch (Exception ex)
            {
                MessageBox.Show("MR72:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
 public void RackComboFillCorrespondingGodown(decimal decGodownId, int inRow, int inColumn)
 {
     try
     {
         List<DataTable> listObj = new List<DataTable>();
         RackBll BllRack = new RackBll();
         listObj = BllRack.RackNamesCorrespondingToGodownId(decGodownId);
         DataRow drow = listObj[0].NewRow();
         DataGridViewComboBoxCell dgvcmbRackCellConsumption = (DataGridViewComboBoxCell)dgvPhysicalStock.Rows[inRow].Cells[inColumn];
         dgvcmbRackCellConsumption.DataSource = listObj[0];
         dgvcmbRackCellConsumption.ValueMember = "rackId";
         dgvcmbRackCellConsumption.DisplayMember = "rackName";
     }
     catch (Exception ex)
     {
         MessageBox.Show("SJ:26" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
Пример #4
0
        /// <summary>
        /// Function to fill all rack in datagridview
        /// </summary>
        public void GridFill()
        {
            try
            {
                RackBll BllRack = new RackBll();
                List<DataTable> listObjRack = new List<DataTable>();

                listObjRack = BllRack.RackSearch(txtRackNameSearch.Text.Trim(), cmbGodownSearch.Text.ToString());
                dgvRack.DataSource = listObjRack[0];
            }
            catch (Exception ex)
            {
                MessageBox.Show("R5:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Пример #5
0
 /// <summary>
 /// On doubleclicking on the grid, It displays the details to edit or delete a rack 
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void dgvRack_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
 {
     try
     {
         if (e.RowIndex != -1)
         {
             if (dgvRack.Rows[e.RowIndex].Cells["dgvtxtRackName"].Value.ToString() != "NA")
             {
                 RackBll BllRack = new RackBll();
                 RackInfo infoRack = new RackInfo();
                 decRackId = Convert.ToDecimal(dgvRack.Rows[e.RowIndex].Cells["dgvtxtRackId"].Value.ToString());
                 infoRack = BllRack.RackView(decRackId);
                 txtRackName.Text = infoRack.RackName;
                 cmbGodown.SelectedValue = infoRack.GodownId.ToString();
                 txtNarration.Text = infoRack.Narration;
                 btnSave.Text = "Update";
                 btnDelete.Enabled = true;
                 strRackName = infoRack.RackName;
                 txtRackName.Focus();
             }
             else
             {
                 Messages.InformationMessage("Default Rack cannot update or delete");
                 Clear();
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("R19:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
Пример #6
0
 /// <summary>
 /// Function to fill Rack combobox
 /// </summary>
 public void RackComboFillForLoad()
 {
     try
     {
         RackBll BllRack = new RackBll();
         List<DataTable> listObj = new List<DataTable>();
         if (cmbGodown.SelectedValue.ToString() != "System.Data.DataRowView")
         {
             listObj = BllRack.RackFillForStock(Convert.ToDecimal(cmbGodown.SelectedValue.ToString()));
             DataRow dr = listObj[0].NewRow();
             dr["rackName"] = "All";
             dr["rackId"] = 0;
             listObj[0].Rows.InsertAt(dr, 0);
             cmbRack.DataSource = listObj[0];
             cmbRack.DisplayMember = "rackName";
             cmbRack.ValueMember = "rackId";
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("ST:9" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
Пример #7
0
        /// <summary>
        /// Function to delete a Rack
        /// </summary>
        public void DeleteFunction()
        {
            try
            {

                RackBll BllRack = new RackBll();
                if (BllRack.RackDeleteReference(decRackId) <= 0)
                {
                    Messages.ReferenceExistsMessage();
                }
                else
                {
                    Clear();
                    btnSave.Text = "Save";
                    Messages.DeletedMessage();
                    GridFill();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("R39:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);

            }
        }
 //Form Rack
 //-------------------------------------------------------------ReturnFromRackForm---------------------------
 public void ReturnFromRackForm(decimal decId)
 {
     try
     {
         if (!isCallFromGrid)
         {
             RackComboFill();
             if (decId.ToString() != "0")
             {
                 cmbDefaultRack.SelectedValue = decId;
             }
             else if (strRackName != string.Empty)
             {
                 cmbDefaultRack.SelectedValue = strRackName;
             }
             else
             {
                 cmbDefaultRack.SelectedIndex = -1;
             }
             this.Enabled = true;
             cmbDefaultRack.Focus();
             this.WindowState = FormWindowState.Normal;
             this.Activate();
         }
         else
         {
             DataGridViewComboBoxCell dgvRackCell = (DataGridViewComboBoxCell)dgvProductCreation[dgvProductCreation.Columns["dgvcmbrack"].Index, dgvProductCreation.CurrentRow.Index];
             List<DataTable> listObj = new List<DataTable>();
             RackBll BllRack = new RackBll();
             listObj = BllRack.RackNamesCorrespondingToGodownId(decGodownIdForRack);
             if (decId.ToString() != "0")
             {
                 dgvRackCell.DataSource = listObj[0];
                 dgvRackCell.ValueMember = "rackId";
                 dgvRackCell.DisplayMember = "rackName";
                 dgvProductCreation.CurrentRow.Cells["dgvcmbrack"].Value = decId;
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("PC:42" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
 /// <summary>
 /// Work on dgvProductCreation CellEndEdit event
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void dgvProductCreation_CellEndEdit(object sender, DataGridViewCellEventArgs e)
 {
     try
     {
         if (dgvProductCreation.Columns[e.ColumnIndex].Name == "dgvtxtbatch")
         {
             string strBatch = dgvProductCreation.Rows[e.RowIndex].Cells[e.ColumnIndex].Value == null ? "" : dgvProductCreation.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString();
             if (strBatch != "")
             {
                 BatchBll BllBatch = new BatchBll();
                 List<DataTable> listBatch = new List<DataTable>();
                 listBatch = BllBatch.BatchViewByName(strBatch, decId);
                 if (listBatch[0].Rows.Count != 0)
                 {
                     dgvProductCreation.Rows[e.RowIndex].Cells["dgvtxtExpDate"].Value = listBatch[0].Rows[0]["expiryDate"];
                     dgvProductCreation.Rows[e.RowIndex].Cells["dgvtxManfDate"].Value = listBatch[0].Rows[0]["manufacturingDate"];
                 }
             }
             else
             {
                 dgvProductCreation.Rows[e.RowIndex].Cells["dgvtxtExpDate"].Value = string.Empty;
                 dgvProductCreation.Rows[e.RowIndex].Cells["dgvtxManfDate"].Value = string.Empty;
             }
         }
         if (dgvProductCreation.Columns[e.ColumnIndex].Name == "dgvcmbtgodown")
         {
             RackBll BllRack = new RackBll();
             RackInfo infoRack = new RackInfo();
             List<DataTable> listObjRack = new List<DataTable>();
             decimal decGodownId = Convert.ToDecimal(dgvProductCreation.Rows[e.RowIndex].Cells["dgvcmbtgodown"].Value);
             listObjRack = BllRack.RackNamesCorrespondingToGodownId(decGodownId);
             DataRow drow = listObjRack[0].NewRow();
             drow["rackName"] = string.Empty;
             drow["rackId"] = 0;
             listObjRack[0].Rows.InsertAt(drow, 0);
             DataGridViewComboBoxCell cell = (DataGridViewComboBoxCell)(dgvProductCreation.Rows[e.RowIndex].Cells["dgvcmbrack"]);
             cell.DataSource = listObjRack[0];
             cell.ValueMember = "rackId";
             cell.DisplayMember = "rackName";
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("PC:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
 /// <summary>
 /// Function to fill rack combobox in grid
 /// </summary>
 public void RackComboFill()
 {
     try
     {
         List<DataTable> listObj = new List<DataTable>();
         RackBll BllRack = new RackBll();
         decimal decGodownId = Convert.ToDecimal(cmbDefaultGodown.SelectedValue.ToString());
         listObj = BllRack.RackNamesCorrespondingToGodownId(decGodownId);
         cmbDefaultRack.DataSource = listObj[0];
         cmbDefaultRack.DisplayMember = "rackName";
         cmbDefaultRack.ValueMember = "rackId";
         if (listObj[0].Rows.Count > 0)
         {
             cmbDefaultRack.SelectedIndex = 0;
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("PC:54" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
 /// <summary>
 /// Function to view all rack combobox in grid
 /// </summary>
 public void RackGridComboFill()
 {
     try
     {
         List<DataTable> listObj = new List<DataTable>();
         RackBll BllRack = new RackBll();
         listObj = BllRack.RackViewAll();
         DataRow drow = listObj[0].NewRow();
         drow["rackName"] = string.Empty;
         drow["rackId"] = 0;
         listObj[0].Rows.InsertAt(drow, 0);
         dgvcmbrack.DataSource = listObj[0];
         dgvcmbrack.DisplayMember = "rackName";
         dgvcmbrack.ValueMember = "rackId";
     }
     catch (Exception ex)
     {
         MessageBox.Show("PC:55" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
 /// <summary>
 /// Function to use the Rack ComboFill based on the godown
 /// </summary>
 /// <param name="decGodownId"></param>
 /// <param name="dgvCurProduct"></param>
 /// <param name="inRowIndex"></param>
 public void DGVRackComboFill(decimal decGodownId, DataGridView dgvCurProduct, int inRowIndex)
 {
     try
     {
         List<DataTable> listObj = new List<DataTable>();
         RackBll BllRack = new RackBll();
         DataGridViewComboBoxCell dgvcmbCurRack = (DataGridViewComboBoxCell)dgvProduct[dgvProduct.Columns["dgvcmbRack"].Index, inRowIndex];
         listObj = BllRack.RackViewAllByGodownForCombo(decGodownId);
         dgvcmbCurRack.DataSource = listObj[0];
         dgvcmbCurRack.ValueMember = "rackId";
         dgvcmbCurRack.DisplayMember = "rackName";
     }
     catch (Exception ex)
     {
         MessageBox.Show("RI:17" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
 /// <summary>
 /// Rackcombofill
 /// </summary>
 /// <param name="decrackId"></param>
 public void rackcombofill1(decimal decrackId)
 {
     try
     {
         RackBll BllRack = new RackBll();
         List<DataTable> listObjc = new List<DataTable>(); ;
         listObjc = BllRack.RackNamesCorrespondingToGodownId(decrackId);
         dgvCmbRack.DataSource = listObjc;
         dgvCmbRack.ValueMember = "rackId";
         dgvCmbRack.DisplayMember = "rackName";
     }
     catch (Exception ex)
     {
         MessageBox.Show("SR73:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
 /// <summary>
 /// Function to fill the details against purchase order
 /// </summary>
 public void FillOrderDetails()
 {
     BatchBll BllBatch = new BatchBll();
     PurchaseOrderBll BllPurchaseOrder = new PurchaseOrderBll();
     //StockPostingSP spStockPosting = new StockPostingSP();
     StockPostingBll BllStockPosting = new StockPostingBll();
     ProductCreationBll BllProductCreation = new ProductCreationBll();
     try
     {
         if (!isEditFill)
         {
             isValueChange = false;
             if (dgvProduct.RowCount > 1)
             {
                 for (int i = 0; i < dgvProduct.RowCount - 1; i++)
                 {
                     if (dgvProduct.Rows[i].Cells["dgvtxtMaterialReceiptdetailsId"].Value != null && dgvProduct.Rows[i].Cells["dgvtxtMaterialReceiptdetailsId"].Value.ToString() != string.Empty)
                     {
                         lstArrOfRemove.Add(dgvProduct.Rows[i].Cells["dgvtxtMaterialReceiptdetailsId"].Value.ToString());
                     }
                 }
             }
             dgvProduct.Rows.Clear();
             isValueChange = true;
             isDoAfterGridFill = false;
             List<DataTable> ListObjDetails = new List<DataTable>();
             if (Convert.ToDecimal(cmbOrderNo.SelectedValue.ToString()) == decOrderNoWhileEditMode && btnSave.Text == "Update")
             {
                 ListObjDetails = BllPurchaseOrder.PurchaseOrderDetailsViewByOrderMasterIdWithRemainingForEdit(Convert.ToDecimal(cmbOrderNo.SelectedValue.ToString()), decMaterialReceiptId);
             }
             else
             {
                 ListObjDetails = BllPurchaseOrder.PurchaseOrderDetailsViewByOrderMasterIdWithRemaining(Convert.ToDecimal(cmbOrderNo.SelectedValue.ToString()), decMaterialReceiptId);
             }
             int inRowIndex = 0;
             foreach (DataRow drowDetails in ListObjDetails[0].Rows)
             {
                 dgvProduct.Rows.Add();
                 isValueChange = false;
                 isDoAfterGridFill = false;
                 dgvProduct.CurrentCell = dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvtxtProductName"];
                 dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvtxtPurchaseOrderDetailsId"].Value = Convert.ToString(drowDetails.ItemArray[0]);
                 strproductId = drowDetails.ItemArray[2].ToString();
                 ProductInfo infoproduct = new ProductInfo();
                 infoproduct = BllProductCreation.ProductView(Convert.ToDecimal(strproductId));
                 dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["productId"].Value = Convert.ToDecimal(strproductId);
                 dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvtxtProductCode"].Value = infoproduct.ProductCode;
                 dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvtxtProductName"].Value = infoproduct.ProductName;
                 dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvtxtvouchertypeId"].Value = Convert.ToString(drowDetails.ItemArray[11]);
                 dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvtxtvoucherNo"].Value = Convert.ToString(drowDetails.ItemArray[12]);
                 dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvtxtinvoiceNo"].Value = Convert.ToString(drowDetails.ItemArray[13]);
                 UnitComboFill(Convert.ToDecimal(strproductId), dgvProduct.Rows.Count - 2, dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvcmbUnit"].ColumnIndex);
                 isValueChange = true;
                 isDoAfterGridFill = true;
                 dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvcmbUnit"].Value = Convert.ToDecimal(drowDetails["unitId"].ToString());
                 UnitConvertionBll bllUnitConvertion = new UnitConvertionBll();
                List< DataTable >listUnitByProduct = new List<DataTable>();
                listUnitByProduct = bllUnitConvertion.UnitConversionIdAndConRateViewallByProductId(strproductId);
                foreach (DataRow drUnitByProduct in listUnitByProduct[0].Rows)
                 {
                     if (dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvcmbUnit"].Value.ToString() == drUnitByProduct.ItemArray[0].ToString())
                     {
                         dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvtxtUnitConversionId"].Value = Convert.ToDecimal(drUnitByProduct.ItemArray[2].ToString());
                         dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvtxtConversionRate"].Value = Convert.ToDecimal(drUnitByProduct.ItemArray[3].ToString());
                     }
                 }
                 isValueChange = false;
                 isDoAfterGridFill = false;
                 BatchComboFill(Convert.ToDecimal(strproductId), dgvProduct.Rows.Count - 2, Convert.ToInt32(dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvcmbBatch"].ColumnIndex));
                 decimal decBatch = BllStockPosting.BatchViewByProductId(Convert.ToDecimal(strproductId));
                 dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvcmbBatch"].Value = decBatch;
                 string strBarcode = BllBatch.ProductBatchBarcodeViewByBatchId(decBatch);
                 dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvtxtBarcode"].Value = strBarcode;
                 DGVGodownComboFill();
                 dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvcmbGodown"].Value = Convert.ToDecimal(1);
                 RackComboFill(1, dgvProduct.Rows.Count - 2, dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvCmbRack"].ColumnIndex);
                 List<DataTable> listObj = new List<DataTable>();
                 RackBll BllRack = new RackBll();
                 listObj = BllRack.RackNamesCorrespondingToGodownId(1);
                 dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvCmbRack"].Value = Convert.ToDecimal(listObj[0].Rows[0]["rackId"].ToString());
                 dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvtxtQty"].Value = Convert.ToString(drowDetails.ItemArray[3]);
                 dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvtxtRate"].Value = Convert.ToString(drowDetails.ItemArray[4]);
                 decCurrentRate = Convert.ToDecimal(drowDetails.ItemArray[4].ToString());
                 decCurrentConversionRate = Convert.ToDecimal(dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvtxtConversionRate"].Value.ToString());
                 dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvtxtAmount"].Value = Convert.ToString(drowDetails.ItemArray[6]);
                 dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvtxtProductCode"].ReadOnly = true;
                 dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvtxtProductName"].ReadOnly = true;
                 dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvtxtBarcode"].ReadOnly = true;
                 dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvtxtAmount"].ReadOnly = true;
                 dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["inRowIndex"].Value = Convert.ToString(drowDetails["extra1"]);
                 if (cmbVoucherType.Text != "NA")
                 {
                     dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvcmbUnit"].ReadOnly = true;
                 }
                 dgvProduct.Rows[dgvProduct.Rows.Count - 2].HeaderCell.Value = string.Empty;
                 int intIndex = 0;
                 int.TryParse(Convert.ToString(drowDetails["extra1"]), out intIndex);
                 if (inMaxCount < intIndex)
                     inMaxCount = intIndex;
                 inRowIndex++;
                 NewAmountCalculation(string.Empty, dgvProduct.Rows.Count - 2);
                 isValueChange = true;
                 isDoAfterGridFill = true;
                 dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvcmbUnit"].ReadOnly = true;
             }
             for (int i = inRowIndex; i < dgvProduct.Rows.Count; ++i)
                 dgvProduct["inRowIndex", i].Value = Convert.ToString(GetNextinRowIndex());
             SerialNo();
             CalculateTotalAmount();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("MR39:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
Пример #15
0
        /// <summary>
        /// Function to use the Rack Combo Fill
        /// </summary>
        public void RackComboFill()
        {
            try
            {

                List<DataTable> listObjRack = new List<DataTable>();
                RackBll BllRack = new RackBll();
                listObjRack = BllRack.RackViewAll();
                cmbRack.DataSource = listObjRack[0];
                cmbRack.ValueMember = "rackId";
                cmbRack.DisplayMember = "rackName";
            }
            catch (Exception ex)
            {
                MessageBox.Show("POS:14" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
 /// <summary>
 /// To fill rack combobox
 /// </summary>
 public void RackComboFill()
 {
     try
     {
         RackBll BllRack = new RackBll();
         List<DataTable> listObj = new List<DataTable>();
         listObj = BllRack.RackViewAll();
         DataRow dr = listObj[0].NewRow();
         dr["rackName"] = "All";
         dr["rackId"] = 0;
         listObj[0].Rows.InsertAt(dr, 0);
         cmbRack.DataSource = listObj[0];
         cmbRack.DisplayMember = "rackName";
         cmbRack.ValueMember = "rackId";
     }
     catch (Exception ex)
     {
         MessageBox.Show("SER:7" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
Пример #17
0
        /// <summary>
        /// Function to use the Rack Combo Fill by under the Godown
        /// </summary>
        /// <param name="dcGodownId"></param>
        public void RackComboFillByGodownId(decimal dcGodownId)
        {
            try
            {
                List<DataTable> listObjRack = new List<DataTable>();

                RackBll BllRack = new RackBll();
                listObjRack = BllRack.RackNamesCorrespondingToGodownId(dcGodownId);
                cmbRack.DataSource = listObjRack[0];
                cmbRack.ValueMember = "rackId";
                cmbRack.DisplayMember = "rackName";
            }
            catch (Exception ex)
            {
                MessageBox.Show("POS:15" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
 /// <summary>
 /// Function to fill rack combobox
 /// </summary>
 public void RackComboFill()
 {
     try
     {
         RackBll BllRack = new RackBll();
         List<DataTable> listObjRack = new List<DataTable>();
         listObjRack = BllRack.RejectionOutRackViewFromGodownId();
         dgvcmbConsumptionRack.DataSource = listObjRack[0];
         dgvcmbConsumptionRack.ValueMember = "rackId";
         dgvcmbConsumptionRack.DisplayMember = "rackName";
         dgvcmbProductionRack.DataSource = listObjRack[0];
         dgvcmbProductionRack.ValueMember = "rackId";
         dgvcmbProductionRack.DisplayMember = "rackName";
     }
     catch (Exception ex)
     {
         MessageBox.Show("SJ:22" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
Пример #19
0
 /// <summary>
 /// Function to check rack name alredy exist or not
 /// </summary>
 /// <returns></returns>
 public bool CheckExistenceOfRackName()
 {
     bool isExist = false;
     try
     {
         RackBll BllRack = new RackBll();
         isExist = BllRack.RackCheckExistence(txtRackName.Text.Trim(), 0, Convert.ToDecimal(cmbGodown.SelectedValue.ToString()));
         if (isExist)
         {
             string strRackNames = txtRackName.Text.Trim();
             if (strRackNames.ToLower() == strRackName.ToLower())
             {
                 isExist = false;
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("R6:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
     return isExist;
 }
Пример #20
0
 /// <summary>
 /// Function to Save Rack 
 /// </summary>
 public void RackAddCurrespondingtoGodown()
 {
     try
     {
         RackBll BllRack = new RackBll();
         RackInfo infoRack = new RackInfo();
         infoRack.RackName = "NA";
         infoRack.GodownId = decIdForOtherForms;
         infoRack.Narration = string.Empty;
         infoRack.Extra1 = string.Empty;
         infoRack.Extra2 = string.Empty;
         infoRack.ExtraDate = DateTime.Now;
         BllRack.RackAdd(infoRack);
     }
     catch (Exception ex)
     {
         MessageBox.Show("G3:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
Пример #21
0
        /// <summary>
        /// Function to edit the existing rack
        /// </summary>
        public void EditFunction()
        {
            try
            {
                RackBll BllRack = new RackBll();
                RackInfo rackInfo = new RackInfo();
                rackInfo.RackName = txtRackName.Text.Trim();
                rackInfo.GodownId = Convert.ToDecimal(cmbGodown.SelectedValue.ToString());
                rackInfo.Narration = txtNarration.Text.Trim();
                rackInfo.ExtraDate = DateTime.Now;
                rackInfo.Extra1 = string.Empty;
                rackInfo.Extra2 = string.Empty;
                rackInfo.RackId = decRackId;
                if (txtRackName.Text != strRackName)
                {
                    if (CheckExistenceOfRackName() == false)
                    {
                        if (BllRack.RackEdit(rackInfo))
                        {
                            Messages.UpdatedMessage();
                            Clear();
                        }
                    }
                    else
                    {
                        Messages.InformationMessage("Already exists");
                        txtRackName.Focus();
                    }
                }
                else if (rackInfo.RackId == 1)
                {
                    Messages.InformationMessage("Cannot update");
                    Clear();
                    txtRackName.Focus();
                }
                else
                {
                    if (BllRack.RackEdit(rackInfo))
                    {
                        Messages.UpdatedMessage();
                        Clear();

                    }
                }

            }
            catch (Exception ex)
            {
                MessageBox.Show("R8:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
        /// <summary>
        /// Function for Amount Calculations for Gross value, Net amount, Tax amount and Total amount
        /// </summary>
        /// <param name="columnName"></param>
        /// <param name="inIndexOfRow"></param>
        public void AmountCalculation(string columnName, int inIndexOfRow)
        {
            try
            {
                string strTaxRate = string.Empty;
                decimal decTaxAmt = 0;
                decimal decTotalAmnt = 0;
                decimal decdgvtxtgrossValue = 0, decDiscountCalc = 0, decNetAmount = 0;
                decimal decTaxPercent = 0;
                decimal decTaxId = 0;
                DataGridViewRow dgrow = dgvPurchaseReturn.Rows[inIndexOfRow];
                ProductInfo infoProduct = new ProductInfo();
                RackBll BllRack = new RackBll();
                TaxInfo infotax = new TaxInfo();
                TaxBll bllTax = new TaxBll();
                if (dgrow.Cells["dgvtxtqty"].Value != null && dgrow.Cells["dgvtxtqty"].Value.ToString() != string.Empty)
                {
                    decQty = Convert.ToDecimal(dgrow.Cells["dgvtxtqty"].Value.ToString());
                }

                if (dgrow.Cells["dgvtxtrate"].Value != null && dgrow.Cells["dgvtxtrate"].Value.ToString() != string.Empty)
                {
                    decRate = Convert.ToDecimal(dgrow.Cells["dgvtxtrate"].Value.ToString());
                    decdgvtxtgrossValue = decQty * decRate;
                    dgrow.Cells["dgvtxtgrossValue"].Value = Math.Round(decdgvtxtgrossValue, PublicVariables._inNoOfDecimalPlaces);
                }
                if (dgrow.Cells["dgvtxtgrossValue"].Value != null && dgrow.Cells["dgvtxtgrossValue"].Value.ToString() != string.Empty)
                {
                    dgrow.Cells["dgvtxtgrossValue"].Value = Math.Round(decdgvtxtgrossValue, PublicVariables._inNoOfDecimalPlaces);
                    if (dgrow.Cells["dgvtxtdiscount"].Value != null && dgrow.Cells["dgvtxtdiscount"].Value.ToString() != string.Empty)
                    {
                        decDiscountCalc = Convert.ToDecimal(dgrow.Cells["dgvtxtdiscount"].Value.ToString());
                        if (decdgvtxtgrossValue >= decDiscountCalc)
                        {
                            decNetAmount = Math.Round((decdgvtxtgrossValue - decDiscountCalc), PublicVariables._inNoOfDecimalPlaces);
                            dgrow.Cells["dgvtxtNetAmount"].Value = Math.Round(decNetAmount, PublicVariables._inNoOfDecimalPlaces);
                        }
                        else
                        {
                            dgrow.Cells["dgvtxtdiscount"].Value = 0;
                        }
                    }
                    else
                    {
                        dgrow.Cells["dgvtxtdiscount"].Value = 0;
                        dgrow.Cells["dgvtxtNetAmount"].Value = Math.Round(decNetAmount, PublicVariables._inNoOfDecimalPlaces);
                    }
                }
                if (dgrow.Cells["dgvtxtNetAmount"].Value != null && dgrow.Cells["dgvtxtNetAmount"].Value.ToString() != string.Empty)
                {
                    decNetAmount = Math.Round(decdgvtxtgrossValue - decDiscountCalc, PublicVariables._inNoOfDecimalPlaces);
                    decNetAmount = Convert.ToDecimal(dgrow.Cells["dgvtxtNetAmount"].Value.ToString());
                    dgrow.Cells["dgvtxtNetAmount"].Value = Math.Round(decNetAmount, PublicVariables._inNoOfDecimalPlaces);
                }
                if (dgvcmbTax.Visible)
                {
                    if (dgrow.Cells["dgvtxtproductId"].Value != null && dgrow.Cells["dgvtxtproductId"].Value.ToString() != string.Empty)
                    {
                        if (dgrow.Cells["dgvcmbTax"].Value != null && dgrow.Cells["dgvcmbTax"].Value.ToString() != string.Empty && dgrow.Cells["dgvcmbTax"].Value.ToString() != "NA")
                        {
                            decTaxId = Convert.ToDecimal(dgrow.Cells["dgvcmbTax"].Value.ToString());
                            infotax = bllTax.TaxView(decTaxId);
                            decTaxPercent = infotax.Rate;
                            if (decTaxPercent != 0)
                            {
                                if (strTaxComboFill != string.Empty)
                                {
                                    decTaxAmt = ((decNetAmount * decTaxPercent) / 100);
                                }
                                else
                                {
                                    dgrow.Cells["dgvtxttaxAmount"].Value = "0";
                                }
                                decTotalAmnt = Math.Round((decNetAmount + decTaxAmt), PublicVariables._inNoOfDecimalPlaces);
                                dgrow.Cells["dgvtxttaxAmount"].Value = Math.Round(decTaxAmt, PublicVariables._inNoOfDecimalPlaces);
                                decTaxAmt = Convert.ToDecimal(dgrow.Cells["dgvtxttaxAmount"].Value.ToString());
                                dgrow.Cells["dgvtxtAmount"].Value = Math.Round(decTotalAmnt, PublicVariables._inNoOfDecimalPlaces);
                            }
                            else
                            {
                                dgrow.Cells["dgvtxttaxAmount"].Value = "0";
                                dgrow.Cells["dgvtxtAmount"].Value = Math.Round(decNetAmount, PublicVariables._inNoOfDecimalPlaces);
                            }
                        }
                        else
                        {
                            decTaxPercent = 0;
                            dgrow.Cells["dgvtxttaxAmount"].Value = "0";
                            dgrow.Cells["dgvtxtAmount"].Value = Math.Round(decNetAmount, PublicVariables._inNoOfDecimalPlaces);
                        }
                    }
                    Calculate();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("PR:34 " + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Пример #23
0
 /// <summary>
 /// Function to save new rack
 /// </summary>
 public void SaveFunction()
 {
     try
     {
             RackBll BllRack = new RackBll();
             RackInfo InfoRack = new RackInfo();
             InfoRack.RackName = txtRackName.Text.Trim();
             InfoRack.GodownId = Convert.ToDecimal(cmbGodown.SelectedValue.ToString());
             InfoRack.Narration = txtNarration.Text.Trim();
             InfoRack.ExtraDate = DateTime.Now;
             InfoRack.Extra1 = string.Empty;
             InfoRack.Extra2 = string.Empty;
             decimal decGodounId=Convert.ToDecimal(cmbGodown.SelectedValue.ToString());
             if (BllRack.RackCheckExistence(txtRackName.Text.Trim(), 0, decGodounId) == false)
             {
                 decIdForOtherForms = BllRack.RackAdd(InfoRack);
                 if (decIdForOtherForms > 0)
                 {
                     Messages.SavedMessage();
                     Clear();
                 }
             }
             else
             {
                 Messages.InformationMessage(" Rack name already exist");
                 txtRackName.Focus();
             }
     }
     catch (Exception ex)
     {
         MessageBox.Show("R7:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
 /// <summary>
 /// Grid CellEndEdit for product details fill to curresponding row in grid
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void dgvPurchaseReturn_CellEndEdit(object sender, DataGridViewCellEventArgs e)
 {
     try
     {
         string strBarcode2 = string.Empty;
         decimal decBatchId2 = 0;
         BatchBll BllBatch = new BatchBll();
         RackBll BllRack = new RackBll();
         PurchaseInvoiceBll BllPurchaseInvoice = new PurchaseInvoiceBll();
         PurchaseReturnBll BllPurchaseReturn = new PurchaseReturnBll();
         ProductCreationBll BllProductCreation = new ProductCreationBll();
         if (dgvPurchaseReturn.Columns[e.ColumnIndex].Name == "dgvtxtproductName")
         {
             if (dgvPurchaseReturn.Rows[e.RowIndex].Cells["dgvtxtproductName"].Value != null && dgvPurchaseReturn.Rows[e.RowIndex].Cells["dgvtxtproductName"].Value.ToString().Trim() != string.Empty)
             {
                 ProductInfo infoProduct = BllProductCreation.ProductViewByName(dgvPurchaseReturn.Rows[e.RowIndex].Cells["dgvtxtproductName"].Value.ToString());
                 if (infoProduct.ProductCode != null && infoProduct.ProductCode != string.Empty)
                 {
                     FillProductDetails(infoProduct.ProductCode.ToString(), e.RowIndex);
                 }
                 else
                 {
                     StringEmptyDetailsInGrid();
                 }
             }
             else
             {
                 dgvPurchaseReturn.Rows[e.RowIndex].Cells["dgvtxtproductName"].Value = string.Empty;
             }
         }
         else if (dgvPurchaseReturn.Columns[e.ColumnIndex].Name == "dgvtxtproductCode")
         {
             if (dgvPurchaseReturn.Rows[e.RowIndex].Cells["dgvtxtproductCode"].Value != null && dgvPurchaseReturn.Rows[e.RowIndex].Cells["dgvtxtproductCode"].Value.ToString().Trim() != string.Empty)
             {
                 ProductInfo infoProduct = BllProductCreation.ProductViewByCode(dgvPurchaseReturn.Rows[e.RowIndex].Cells["dgvtxtproductCode"].Value.ToString());
                 if (infoProduct.ProductName != null && infoProduct.ProductCode != string.Empty)
                 {
                     FillProductDetails(infoProduct.ProductCode.ToString(), e.RowIndex);
                 }
                 else
                 {
                     StringEmptyDetailsInGrid();
                 }
             }
             else
             {
                 dgvPurchaseReturn.Rows[e.RowIndex].Cells["dgvtxtproductCode"].Value = string.Empty;
             }
         }
         else if (dgvPurchaseReturn.Columns[e.ColumnIndex].Name == "dgvtxtbarcode")
         {
             if (dgvPurchaseReturn.Rows[e.RowIndex].Cells["dgvtxtbarcode"].Value != null && dgvPurchaseReturn.Rows[e.RowIndex].Cells["dgvtxtbarcode"].Value.ToString().Trim() != string.Empty)
             {
                 string strBarcode = dgvPurchaseReturn.Rows[e.RowIndex].Cells["dgvtxtbarcode"].Value.ToString();
                 decBatchId = BllProductCreation.BatchIdByPartNoOrBarcode(strBarcode, strBarcode);
                 if (decBatchId > 0)
                 {
                     List<DataTable> listObjBatchName = new List<DataTable>();
                     listObjBatchName = BllProductCreation.ProductCodeAndBarcodeByBatchId(decBatchId);
                     dgvPurchaseReturn.Rows[e.RowIndex].Cells["dgvtxtproductCode"].Value = listObjBatchName[0].Rows[0]["productCode"].ToString();
                     if (listObjBatchName[0].Rows[0]["barcode"].ToString() != null && listObjBatchName[0].Rows[0]["barcode"].ToString() != string.Empty)
                     {
                         dgvPurchaseReturn.Rows[e.RowIndex].Cells["dgvtxtbarcode"].Value = listObjBatchName[0].Rows[0]["barcode"].ToString();
                     }
                     decimal batchId = BllBatch.BatchViewByBarcode(strBarcode);
                     dgvPurchaseReturn.Rows[e.RowIndex].Cells["dgvcmbBatch"].Value = batchId;
                     FillProductDetails(listObjBatchName[0].Rows[0]["productCode"].ToString(), e.RowIndex);
                 }
                 else
                 {
                     StringEmptyDetailsInGrid();
                 }
             }
             else
             {
                 dgvPurchaseReturn.Rows[e.RowIndex].Cells["dgvtxtbarcode"].Value = string.Empty;
             }
         }
         if (e.ColumnIndex == dgvPurchaseReturn.Columns["dgvcmbUnit"].Index)
         {
             if (dgvPurchaseReturn.Columns[e.ColumnIndex].Name == "dgvcmbUnit")
             {
                 if ((dgvPurchaseReturn.Rows[e.RowIndex].Cells["dgvcmbUnit"].Value != null) && (dgvPurchaseReturn.Rows[e.RowIndex].Cells["dgvcmbUnit"].Value.ToString() != string.Empty))
                 {
                     UnitConversionCalc(e.RowIndex);
                     AmountCalculation("dgvtxtqty", e.RowIndex);
                 }
             }
         }
         if (dgvPurchaseReturn.Columns[e.ColumnIndex].Name == "dgvtxtqty" && isAmountcalc)
         {
             if (dgvPurchaseReturn.Rows[e.RowIndex].Cells["dgvtxtqty"].Value != null && dgvPurchaseReturn.Rows[e.RowIndex].Cells["dgvtxtqty"].Value.ToString() != string.Empty && Convert.ToDecimal(dgvPurchaseReturn.Rows[e.RowIndex].Cells["dgvtxtqty"].Value.ToString()) != 0)
             {
                 if (cmbInvoiceNo.SelectedValue == null || cmbInvoiceNo.SelectedValue.ToString() == string.Empty)
                 {
                     AmountCalculation("dgvtxtqty", e.RowIndex);
                 }
                 else
                 {
                     List<DataTable> ListObj= BllPurchaseInvoice.PurchaseDetailsViewByPurchaseMasterIdWithRemaining(Convert.ToDecimal(cmbInvoiceNo.SelectedValue.ToString()), decPurchaseReturnMasterId, decPurchaseReturnVoucherTypeId);
                     if (dgvPurchaseReturn.Rows[e.RowIndex].Cells["dgvtxtPurchaseDetailsId"].Value != null)
                     {
                         if (Convert.ToDecimal(dgvPurchaseReturn.Rows[e.RowIndex].Cells["dgvtxtPurchaseDetailsId"].Value.ToString()) > 0)
                         {
                             if (dgvPurchaseReturn.Rows[e.RowIndex].Cells["dgvtxtqty"].Value != null)
                             {
                                 if (Convert.ToDecimal(dgvPurchaseReturn.Rows[e.RowIndex].Cells["dgvtxtqty"].Value.ToString()) > Convert.ToDecimal(ListObj[0].Rows[e.RowIndex]["qty"].ToString()))
                                 {
                                     dgvPurchaseReturn.Rows[e.RowIndex].Cells["dgvtxtqty"].Value = Math.Round(Convert.ToDecimal(ListObj[0].Rows[e.RowIndex]["qty"].ToString()), PublicVariables._inNoOfDecimalPlaces);
                                 }
                             }
                         }
                     }
                     AmountCalculation("dgvtxtqty", e.RowIndex);
                 }
             }
         }
         else if (dgvPurchaseReturn.Columns[e.ColumnIndex].Name == "dgvtxtrate" && isAmountcalc)
         {
             if (dgvPurchaseReturn.Rows[e.RowIndex].Cells["dgvtxtqty"].Value != null && dgvPurchaseReturn.Rows[e.RowIndex].Cells["dgvtxtqty"].Value.ToString() != string.Empty && Convert.ToDecimal(dgvPurchaseReturn.Rows[e.RowIndex].Cells["dgvtxtqty"].Value.ToString()) != 0)
             {
                 AmountCalculation("dgvtxtrate", e.RowIndex);
             }
         }
         else if (dgvPurchaseReturn.Columns[e.ColumnIndex].Name == "dgvtxtdiscount")
         {
             if (dgvPurchaseReturn.Rows[e.RowIndex].Cells["dgvtxtdiscount"].Value != null && dgvPurchaseReturn.Rows[e.RowIndex].Cells["dgvtxtdiscount"].Value.ToString().Trim() != string.Empty && dgvPurchaseReturn.Rows[e.RowIndex].Cells["dgvtxtDiscount"].Value.ToString().Trim() != "0")
             {
                 AmountCalculation("dgvtxtrate", e.RowIndex);
             }
         }
         else if (dgvPurchaseReturn.Columns[e.ColumnIndex].Name == "dgvcmbTax" && isAmountcalc)
         {
             if (dgvPurchaseReturn.Rows[e.RowIndex].Cells["dgvcmbTax"].Value != null && dgvPurchaseReturn.Rows[e.RowIndex].Cells["dgvcmbTax"].Value.ToString() != string.Empty)
             {
                 AmountCalculation("dgvtxtrate", e.RowIndex);
             }
         }
         else if (dgvPurchaseReturn.Columns[e.ColumnIndex].Name == "dgvcmbBatch")
         {
             if (dgvPurchaseReturn.Rows[e.RowIndex].Cells["dgvcmbBatch"].Value != null && dgvPurchaseReturn.Rows[e.RowIndex].Cells["dgvcmbBatch"].Value.ToString() != string.Empty)
             {
                 decBatchId2 = Convert.ToDecimal(dgvPurchaseReturn.CurrentRow.Cells["dgvcmbBatch"].Value);
                 strBarcode2 = BllBatch.ProductBatchBarcodeViewByBatchId(decBatchId2);
                 dgvPurchaseReturn.CurrentRow.Cells["dgvtxtbarcode"].Value = strBarcode2;
             }
         }
         CheckInvalidEntries(e);
     }
     catch (Exception ex)
     {
         MessageBox.Show("PR:80" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
 /// <summary>
 /// Rack Combofill
 /// </summary>
 /// <param name="decGodownId"></param>
 /// <param name="inRow"></param>
 /// <param name="inCol"></param>
 public void RackComboFill1(decimal decGodownId, int inRow, int inCol)
 {
     try
     {
         List<DataTable> listObj = new List<DataTable>();
         RackBll BllRack = new RackBll();
         listObj = BllRack.RackNamesCorrespondingToGodownId(decGodownId);
         DataGridViewComboBoxCell dgvcmbRackCell = (DataGridViewComboBoxCell)dgvProduct.Rows[inRow].Cells[inCol];
         dgvcmbRackCell.DataSource = listObj[0];
         dgvcmbRackCell.ValueMember = "rackId";
         dgvcmbRackCell.DisplayMember = "rackName";
     }
     catch (Exception ex)
     {
         MessageBox.Show("DN29 :" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
 /// <summary>
 /// Function to fill Rack combobox
 /// </summary>
 public void RackComboFill()
 {
     try
     {
         RackBll BllRack = new RackBll();
         List<DataTable> listObjRack = new List<DataTable>();
         listObjRack = BllRack.RackViewAll();
         cmbRack.DataSource = listObjRack[0];
         cmbRack.ValueMember = "rackId";
         cmbRack.DisplayMember = "rackName";
         SettingsBll BllSettings = new SettingsBll();
         if (BllSettings.SettingsStatusCheck("AllowRack") == "Yes")
         {
             cmbRack.Enabled = true;
         }
         else
         {
             cmbRack.Enabled = false;
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("MPC9:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }