private void 添加Button_Click(object sender, EventArgs e) { Dairy dairy = new Dairy(); dairy.Pos机会籍 = numericUpDown1.Value; dairy.Pos机私教 = numericUpDown2.Value; dairy.现金会籍 = numericUpDown3.Value; dairy.现金私教 = numericUpDown4.Value; dairy.微信会籍 = numericUpDown9.Value; dairy.微信私教 = numericUpDown8.Value; dairy.现金存水 = numericUpDown5.Value; dairy.微信存水 = numericUpDown10.Value; dairy.水吧余 = numericUpDown6.Value; dairy.总金额 = numericUpDown7.Value; dairy.经手人 = (selectStaffControl1.SelectedStaffs != null && selectStaffControl1.SelectedStaffs.Count > 0) ? selectStaffControl1.SelectedStaffs[0] : null; dairy.日期 = dateTimePicker3.Value; dairy.备注 = textBox2.Text; DairyLogic al = DairyLogic.GetInstance(); int id = al.AddDairy(dairy); if (id > 0) { dairy.ID = id; LoadDairys(); MessageBox.Show("添加成功!"); } }
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) { if (comboBox1.SelectedIndex > -1) { Dairy dairy = comboBox1.SelectedItem as Dairy; if (dairy != null) { numericUpDown1.Value = dairy.Pos机会籍; numericUpDown2.Value = dairy.Pos机私教; numericUpDown3.Value = dairy.现金会籍; numericUpDown4.Value = dairy.现金私教; numericUpDown9.Value = dairy.微信会籍; numericUpDown8.Value = dairy.微信私教; numericUpDown5.Value = dairy.现金存水; numericUpDown10.Value = dairy.微信存水; numericUpDown6.Value = dairy.水吧余; numericUpDown7.Value = dairy.总金额; selectStaffControl1.SelectedStaffs = new List <Staff>() { dairy.经手人 }; dateTimePicker3.Value = dairy.日期; textBox2.Text = dairy.备注; } } }
private void 修改Button_Click(object sender, EventArgs e) { if (comboBox1.SelectedIndex > -1) { Dairy dairy = (Dairy)comboBox1.SelectedItem; dairy.Pos机会籍 = numericUpDown1.Value; dairy.Pos机私教 = numericUpDown2.Value; dairy.现金会籍 = numericUpDown3.Value; dairy.现金私教 = numericUpDown4.Value; dairy.微信会籍 = numericUpDown9.Value; dairy.微信私教 = numericUpDown8.Value; dairy.现金存水 = numericUpDown5.Value; dairy.微信存水 = numericUpDown10.Value; dairy.水吧余 = numericUpDown6.Value; dairy.总金额 = numericUpDown7.Value; dairy.经手人 = (selectStaffControl1.SelectedStaffs != null && selectStaffControl1.SelectedStaffs.Count > 0) ? selectStaffControl1.SelectedStaffs[0] : null; dairy.日期 = dateTimePicker3.Value; dairy.备注 = textBox2.Text; DairyLogic al = DairyLogic.GetInstance(); if (al.UpdateDairy(dairy)) { LoadDairys(); MessageBox.Show("修改成功!"); } } else { MessageBox.Show("先选定要修改的业绩!"); } }
public List <Dairy> GetDairysByStaff(Staff staff) { List <Dairy> elements = new List <Dairy>(); string sql = "select * from TF_Dairy where 经手人=" + staff.ID; DataTable dt = sqlHelper.Query(sql); if (dt != null && dt.Rows.Count > 0) { for (int i = 0; i < dt.Rows.Count; i++) { Dairy element = new Dairy(); element.ID = Convert.ToInt32(dt.Rows[i]["ID"]); element.Pos机会籍 = Convert.ToDecimal(dt.Rows[i]["Pos机会籍"]); element.Pos机私教 = Convert.ToDecimal(dt.Rows[i]["Pos机私教"]); element.现金会籍 = Convert.ToDecimal(dt.Rows[i]["现金会籍"]); element.现金私教 = Convert.ToDecimal(dt.Rows[i]["现金私教"]); element.微信会籍 = Convert.ToDecimal(dt.Rows[i]["微信会籍"]); element.微信私教 = Convert.ToDecimal(dt.Rows[i]["微信私教"]); element.现金存水 = Convert.ToDecimal(dt.Rows[i]["现金存水"]); element.微信存水 = Convert.ToDecimal(dt.Rows[i]["微信存水"]); element.水吧余 = Convert.ToDecimal(dt.Rows[i]["水吧余"]); element.总金额 = Convert.ToDecimal(dt.Rows[i]["总金额"]); element.备注 = dt.Rows[i]["备注"].ToString(); element.经手人 = staff; element.日期 = Convert.ToDateTime(dt.Rows[i]["日期"]); elements.Add(element); } } return(elements); }
public Dairy GetDairy(int id) { string sql = "select * from TF_Dairy where ID=" + id; DataTable dt = sqlHelper.Query(sql); if (dt != null && dt.Rows.Count > 0) { Dairy element = new Dairy(); element.ID = id; element.Pos机会籍 = Convert.ToDecimal(dt.Rows[0]["Pos机会籍"]); element.Pos机私教 = Convert.ToDecimal(dt.Rows[0]["Pos机私教"]); element.现金会籍 = Convert.ToDecimal(dt.Rows[0]["现金会籍"]); element.现金私教 = Convert.ToDecimal(dt.Rows[0]["现金私教"]); element.微信会籍 = Convert.ToDecimal(dt.Rows[0]["微信会籍"]); element.微信私教 = Convert.ToDecimal(dt.Rows[0]["微信私教"]); element.现金存水 = Convert.ToDecimal(dt.Rows[0]["现金存水"]); element.微信存水 = Convert.ToDecimal(dt.Rows[0]["微信存水"]); element.水吧余 = Convert.ToDecimal(dt.Rows[0]["水吧余"]); element.总金额 = Convert.ToDecimal(dt.Rows[0]["总金额"]); element.备注 = dt.Rows[0]["备注"].ToString(); element.经手人 = StaffLogic.GetInstance().GetStaff(Convert.ToInt32(dt.Rows[0]["经手人"])); element.日期 = Convert.ToDateTime(dt.Rows[0]["日期"]); return(element); } return(null); }
public bool DeleteDairy(Dairy element) { string sql = "delete from TF_Dairy where ID=" + element.ID; int r = sqlHelper.ExecuteSql(sql); return(r > 0); }
public bool UpdateDairy(Dairy element) { string sql = "update TF_Dairy set Pos机会籍=" + element.Pos机会籍 + ", Pos机私教=" + element.Pos机私教 + ", 现金会籍=" + element.现金会籍 + ", 现金私教=" + element.现金私教 + ", 微信会籍=" + element.微信会籍 + ", 微信私教=" + element.微信私教 + ", 现金存水=" + element.现金存水 + ", 微信存水=" + element.微信存水 + ", 水吧余=" + element.水吧余 + ", 总金额=" + element.总金额 + ", 备注='" + element.备注 + "', 经手人=" + element.经手人.ID + ",日期='" + element.日期 + "' where ID=" + element.ID; int r = sqlHelper.ExecuteSql(sql); return(r > 0); }
public int AddDairy(Dairy element) { string sql = "insert into TF_Dairy (Pos机会籍, Pos机私教, 现金会籍, 现金私教, 微信会籍, 微信私教, 现金存水, 微信存水, 水吧余, 总金额, 备注, 经手人, 日期) values (" + element.Pos机会籍 + ", " + element.Pos机私教 + ", " + element.现金会籍 + ", " + element.现金私教 + ", " + element.微信会籍 + ", " + element.微信私教 + ", " + element.现金存水 + ", " + element.微信存水 + ", " + element.水吧余 + ", " + element.总金额 + ", '" + element.备注 + "', " + element.经手人.ID + ", '" + element.日期 + "'); select SCOPE_IDENTITY()"; object obj = sqlHelper.ExecuteSqlReturn(sql); int R; if (obj != null && obj != DBNull.Value && int.TryParse(obj.ToString(), out R)) { return(R); } else { return(0); } }
private void 除Button_Click(object sender, EventArgs e) { if (comboBox1.SelectedIndex > -1) { if (MessageBox.Show("确定要删除该业绩?", "删除提醒", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.OK) { Dairy alert = (Dairy)comboBox1.SelectedItem; if (DairyLogic.GetInstance().DeleteDairy(alert)) { LoadDairys(); } } } else { MessageBox.Show("先选定要删除的业绩!"); } }