/// <summary>
        /// Function to generate Product code automatically
        /// </summary>
        public void AutomaticCodeGenaration()
        {

            try
            {

                if (AutomaticProductCode())
                {

                    ProductSP spProduct = new ProductSP();
                    string strPcode = spProduct.ProductMax();
                    //int inCode = strPcode.Length;
                    //if (inCode == 3)
                    //{
                    //    strPcode = (strPcode.ToString()).PadLeft(4, '0');
                    //}
                    //else if (inCode == 2)
                    //{
                    //    strPcode = (strPcode.ToString()).PadLeft(4, '0');
                    //}
                    //else
                    //{
                    //    strPcode = (strPcode.ToString());
                    //}
                    txtProductCode.Text = strPcode;
                    txtProductCode.Enabled = false;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("PC:15" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }

        }
 /// <summary>
 /// To populate default values when user enters for new record 
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void dgvMultipleProductCreation_DefaultValuesNeeded(object sender, DataGridViewRowEventArgs e)
 {
     try
     {
         ProductSP spProduct = new ProductSP();
         string strProductCode = spProduct.ProductMax();
         foreach (DataGridViewRow row in dgvMultipleProductCreation.Rows)
         {
             row.Cells["dgvtxtSlNo"].Value = row.Index + 1;
             if (AutomaticProductCode())
             {
                 dgvMultipleProductCreation.Columns["dgvtxtProductCode"].ReadOnly = true;
                 strProductCode = (strProductCode.ToString());
                 row.Cells["dgvtxtProductCode"].Value = strProductCode;
                 strProductCode = (Convert.ToDecimal(strProductCode) + 1).ToString();
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("MPC18:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }