Exemplo n.º 1
0
        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);
                }
            }
        }