private void btn_del_Click(object sender, EventArgs e)
 {
     if (customerInfoBindingSource.Current != null)
     {
         if (MessageBox.Show("确定要删除吗?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
         {
             db.CustomerInfoes.Remove(customerInfoBindingSource.Current as CustomerInfo);
             customerInfoBindingSource.RemoveCurrent();
             db.SaveChanges();
         }
     }
 }
 private void Form_addctm_FormClosing(object sender, FormClosingEventArgs e)
 {
     if (DialogResult == DialogResult.OK)
     {
         if (string.IsNullOrEmpty(textBox_name.Text) || string.IsNullOrEmpty(textBox_address.Text) || string.IsNullOrEmpty(textBox_mn.Text))
         {
             MessageBox.Show("输入客户信息", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
             textBox_name.Focus();
             e.Cancel = true;
             return;
         }
         db.SaveChanges();
         e.Cancel = false;
     }
     e.Cancel = false;
 }
示例#3
0
 private void Form_editOrder_FormClosing(object sender, FormClosingEventArgs e)
 {
     if (DialogResult == DialogResult.OK)
     {
         if (string.IsNullOrEmpty(textBox_name.Text) || string.IsNullOrEmpty(textBox_address.Text) || string.IsNullOrEmpty(textBox_mn.Text) || string.IsNullOrEmpty(textBox_lastprice.Text) || string.IsNullOrEmpty(textBox1.Text) || string.IsNullOrEmpty(textBox_quantity.Text) || string.IsNullOrEmpty(dateTimePicker1.Text))
         {
             MessageBox.Show("输入完整订单信息", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
             textBox_name.Focus();
             e.Cancel = true;
             return;
         }
         db.SaveChanges();
         e.Cancel = false;
     }
     e.Cancel = false;
 }