private void SkinDataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e) { if (skinDataGridView1.Columns[e.ColumnIndex].Name == "colBtn_drop") { Staff model = new Staff(); model.Id = Convert.ToInt32(skinDataGridView1.Rows[e.RowIndex].Cells["staff_id"].Value); if (StaffDAL.Drop(model, new List <string>() { "id" })) { ShowDataGird(); MessageBoxEx.Show("删除成功", "", MessageBoxButtons.OK, MessageBoxIcon.Information); } } if (skinDataGridView1.Columns[e.ColumnIndex].Name == "colBtn_alter") { Staff model = new Staff(); model.Id = Convert.ToInt32(skinDataGridView1.Rows[e.RowIndex].Cells["staff_id"].Value); model.StaffName = skinDataGridView1.Rows[e.RowIndex].Cells["staff_name"].Value.ToString(); model.Store_Id = Convert.ToInt32(skinDataGridView1.Rows[e.RowIndex].Cells["Store_Id"].Value); model.Gender = skinDataGridView1.Rows[e.RowIndex].Cells["staff_Gender"].Value.ToString(); if (StoreDAL.FindModel(new Store(model.Store_Id), new List <string>() { "id" }) == null) { MessageBoxEx.Show("修改失败,不存在此门店", "", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (StaffDAL.AlterByPK(model, "id")) { ShowDataGird(); MessageBoxEx.Show("修改成功", "", MessageBoxButtons.OK, MessageBoxIcon.Information); } } }
/// <summary> /// 点击录入员工 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void BtnAbout_Click(object sender, EventArgs e) { if (textBox1.Text == "") { MessageBoxEx.Show("请填写员工姓名", "", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } Staff model = new Staff(); model.StaffName = textBox1.Text; model.Gender = comboBox1.Text; model.Store_Id = StoreDAL.FindModel(new Store(comboBox2.Text.ToString(), null, null), new List <string>() { "StoreName" }).Id; if (StaffDAL.Add(model)) { ShowDataGird(); MessageBoxEx.Show("新增员工成功", "", MessageBoxButtons.OK, MessageBoxIcon.Information); } }