private void initialize() { #region ORDER-NO bool isAlreadyExist = true; try { while (isAlreadyExist) { string orderNo = GenerateOrderNo(); isAlreadyExist = CheckOrderExistance(orderNo); txtInvID.Text = orderNo; } } catch (Exception ex) { MessageBox.Show( @"Error while generating Order No. Pease check below details for reference. Details: " + ex.Message, @"Generate Order No", MessageBoxButtons.OK, MessageBoxIcon.Error); } #endregion //initialize the grid(empty) dgvCart.DataSource = SelectProductClass.InitializeDGV(); //load stock available //PopulateStockGrid(); //load default customer txtCustID.Text = Properties.Settings.Default["WalkingCustomerID"].ToString(); txtCustName.Text = @"WALK IN CUSTOMER"; //set default date txtInvDate.Text = DateTime.Now.Date.ToShortDateString(); //populate search by category combobox DataSet d = CategoryClass.Select(); cboSearchCat.DataSource = d.Tables[0].DefaultView; cboSearchCat.DisplayMember = "Name"; cboSearchCat.ValueMember = "CatID"; //POPULATE UNITS cboMeasurement.DataSource = ProductClass.PopulateMeasurementDropDown().Tables[0].DefaultView; cboMeasurement.DisplayMember = "Name"; cboMeasurement.ValueMember = "MeasurementID"; btnLoadAll.PerformClick(); }