/// <summary>
        /// Function for save or update
        /// </summary>
        public void SaveOrEdit()
        {
            try
            {
                ProductSP spProduct = new ProductSP();
                if (txtName.Text.Trim() == string.Empty)
                {
                    Messages.InformationMessage("Enter product name");
                    txtName.Focus();
                }
                else if (txtProductCode.Text.Trim() == string.Empty)
                {
                    Messages.InformationMessage("Enter prouct code");
                    txtProductCode.Focus();
                }
                else if (cmbGroup.SelectedIndex == -1)
                {
                    Messages.InformationMessage("Select group");
                    cmbGroup.Focus();
                }
                else if (cmbUnit.SelectedIndex == -1)
                {
                    Messages.InformationMessage(" Select unit");
                    cmbUnit.Focus();
                }
                else if (cmbTaxApplicableOn.SelectedIndex == -1 && cmbTax.SelectedIndex != 0)
                {
                    Messages.InformationMessage("Select tax applicable on");
                    cmbTaxApplicableOn.Focus();
                }
                //else if (txtPartNo.Text.Trim() != string.Empty && spProduct.PartNoCheckExistence(txtPartNo.Text.Trim()) == true)
                //{
                //    Messages.InformationMessage("Part No Already Exist");
                //    txtPartNo.Focus();
                //}
                else
                {
                    if (btnSave.Text == "Save")
                    {

                        if (spProduct.ProductCodeCheckExistence(txtProductCode.Text.Trim(), 0) == false)
                        {
                            if (PublicVariables.isMessageAdd)
                            {
                                if (Messages.SaveMessage())
                                {
                                    SaveFunction();
                                }
                            }
                            else
                            {
                                SaveFunction();
                            }
                        }
                        else
                        {
                            Messages.InformationMessage("Product code already exist");
                            txtProductCode.Focus();
                        }
                    }
                    else
                    {

                        if (spProduct.ProductCodeCheckExistence(txtProductCode.Text.Trim(), decProductIdForEdit) == false)
                        {
                            EditFunction();
                        }
                        else
                        {
                            Messages.InformationMessage("Product code already exist");
                            txtProductCode.Focus();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("PC:62" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }

        }
 /// <summary>
 /// Function to check whether ProductCode exist
 /// </summary>
 /// <returns></returns>
 public bool CheckAlreadyExist()//To check ProductCode exist or not
 {
     bool isOk = true;
     try
     {
         //check if data present in database
         ProductSP spProduct = new ProductSP();
         int inCompleteRow = 0;
         int inCurrentindex = 0;
         string strMessage = "Row";
         foreach (DataGridViewRow dgvRow in dgvMultipleProductCreation.Rows)
         {
             if (dgvRow.Cells["dgvtxtProductCode"].Value != null)
             {
                 string ProductCode = dgvRow.Cells["dgvtxtProductCode"].Value.ToString();
                 if (spProduct.ProductCodeCheckExistence(ProductCode, 0))
                 {
                     isOk = false;
                     if (inCompleteRow == 0)
                     {
                         strMessage = strMessage + Convert.ToString(dgvRow.Index + 1);
                         inCurrentindex = dgvRow.Index;
                         inCompleteRow++;
                     }
                     else
                     {
                         strMessage = strMessage + ", " + Convert.ToString(dgvRow.Index + 1);
                     }
                 }
             }
         }
         if (!isOk)
         {
             strMessage = strMessage + " contains already exisitng productcode. Do you want to continue?";
             if (MessageBox.Show(strMessage, "OpenMiracle", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) == DialogResult.Yes)
             {
                 isOk = true;
                 for (int inK = 0; inK < dgvMultipleProductCreation.Rows.Count; inK++)
                 {
                     if (dgvMultipleProductCreation.Rows[inK].Cells["dgvtxtProductCode"].Value != null)
                     {
                         string strProductCode = dgvMultipleProductCreation.Rows[inK].Cells["dgvtxtProductCode"].Value.ToString().Trim();
                         if (spProduct.ProductCodeCheckExistence(strProductCode, 0) == true)
                         {
                             if (!dgvMultipleProductCreation.Rows[inK].IsNewRow)
                             {
                                 dgvMultipleProductCreation.Rows.RemoveAt(inK);
                                 inK--;
                             }
                         }
                     }
                 }
             }
             else
             {
                 dgvMultipleProductCreation.Rows[inCurrentindex].Cells["dgvtxtProductCode"].Selected = true;
                 dgvMultipleProductCreation.CurrentCell = dgvMultipleProductCreation.Rows[inCurrentindex].Cells["dgvtxtProductCode"];
                 dgvMultipleProductCreation.Focus();
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("MPC19:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
     return isOk;
 }