コード例 #1
0
 private void ComboBoxLabourName_Leave(object sender, EventArgs e)
 {
     if (!ComboBoxLabourName.Items.Contains(ComboBoxLabourName.Text))
     {
         DialogResult result = MessageBox.Show("the Labour does not exist, would you like to add a new Labour?", "Confirmation", MessageBoxButtons.YesNo);
         if (result == DialogResult.Yes)
         {
             NewLabour NewLabourObj = new NewLabour(ComboBoxLabourName.Text.Trim());
             NewLabourObj.ShowDialog();
             getLaboursData();
             ComboBoxLabourName.Text = "";
             ComboBoxLabourName.Focus();
         }
         ComboBoxLabourName.Text = "";
     }
 }
コード例 #2
0
        private void ButtonAddLabour_Click(object sender, EventArgs e)
        {
            string labourId = laboursdata.Select("LabourName = '" + ComboBoxLabourName.Text.Trim() + "'")[0]["LabourId"].ToString().Trim();

            if (ComboBoxLabourName.Items.Contains(ComboBoxLabourName.Text.Trim()))
            {
                DataTable dataTable = (DataTable)DataGridLabour.DataSource;
                DataRow   drToAdd   = dataTable.NewRow();
                drToAdd["LabourName"] = ComboBoxLabourName.Text.ToString();
                drToAdd["price"]      = NumericLabourCharge.Value.ToString();
                drToAdd["Tax"]        = ComboBoxLabourTax.Text;
                drToAdd["LabourNo"]   = labourId;
                dataTable.Rows.Add(drToAdd);
                dataTable.AcceptChanges();
                loadTotalAndSubTotal();
                ComboBoxLabourName.Focus();
            }
            else
            {
                MessageBox.Show("Please add the new labour before adding this to the invoice");
                ComboBoxLabourName.Focus();
            }
        }