Ejemplo n.º 1
0
 private void tsbSave_Click(object sender, EventArgs e)
 {
     //如果点击的是“新建”按钮,则进行数据添加操作
     if (op == operation.insert)
     {
         DataClasses1DataContext db  = new DataClasses1DataContext(connStr);
         customerManage          cre = new customerManage();
         cre.cus_name   = txtName.Text;
         cre.cus_id     = txtId.Text;
         cre.cus_phone  = txtPhone.Text;
         cre.cus_type   = cbroomType.Text;
         cre.cus_roomid = Convert.ToInt32(cbRoomID.Text);
         cre.cus_time   = dtTime.Value;
         cre.cus_days   = Convert.ToInt32(txtDays.Text);
         cre.cus_pay    = Convert.ToSingle(txtPay.Text);
         cre.cus_extra  = Convert.ToInt32(txtExtra.Text);
         db.customerManage.InsertOnSubmit(cre);
         db.SubmitChanges();
         MessageBox.Show("信息添加成功", "添加记录", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
         BindInfo();
     }
     //如果点击的是“编辑”按钮,则进行数据更新操作
     else if (op == operation.update)
     {
         DataClasses1DataContext db = new DataClasses1DataContext(connStr);
         var result = from c in db.customerManage
                      where c.cus_id == txtId.Text
                      select c;
         foreach (customerManage c in result)
         {
             c.cus_name   = txtName.Text;
             c.cus_id     = txtId.Text;
             c.cus_phone  = txtPhone.Text;
             c.cus_type   = cbroomType.Text;
             c.cus_roomid = Convert.ToInt32(cbRoomID.Text);
             c.cus_time   = dtTime.Value;
             c.cus_days   = Convert.ToInt32(txtDays.Text);
             c.cus_pay    = Convert.ToSingle(txtPay.Text);
             c.cus_extra  = Convert.ToInt32(txtExtra.Text);
             db.SubmitChanges();
             MessageBox.Show("信息修改成功", "修改记录", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
             BindInfo();
         }
     }
 }
Ejemplo n.º 2
0
 partial void UpdatecustomerManage(customerManage instance);
Ejemplo n.º 3
0
 partial void DeletecustomerManage(customerManage instance);
Ejemplo n.º 4
0
 partial void InsertcustomerManage(customerManage instance);