/// <summary>
 /// Function to generate Product code automatically
 /// </summary>
 public void AutomaticCodeGenaration()
 {
     try
     {
         if (AutomaticProductCode())
         {
             ProductCreationBll BllProductcreation = new ProductCreationBll();
             string strPcode = BllProductcreation.ProductMax();
             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
     {
         ProductCreationBll BllProductCreation = new ProductCreationBll();
         string strProductCode = BllProductCreation.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);
     }
 }