Esempio n. 1
0
        private void ShowEditDlg(DataGridViewRow dr)
        {
            int    id    = int.Parse(dr.Cells["ID"].Value.ToString());
            object model = BLLInvoke("GetModel", new object[] { id });

            if (model != null)
            {
                CfgForm cfgForm = new CfgForm(_FormName);
                cfgForm.SetValues <T_Model>(model);
                if (cfgForm.ShowDialog() == DialogResult.OK)
                {
                    object newModel = cfgForm.GetValues <T_Model>();
                    // newModel.ID = model.ID;
                    ModelSetProperty(newModel, "ID", id);

                    bool isSuccess = BLLInvoke("Update", new object[] { newModel }).Equals(true);
                    if (isSuccess)
                    {
                        MessageBox.Show("修改成功!");
                        RefreshData();
                    }
                    else
                    {
                        MessageBox.Show("修改失败!");
                    }
                }
            }
        }
Esempio n. 2
0
        private void button_add_Click(object sender, EventArgs e)
        {
            CfgForm cfgForm = new CfgForm(_FormName);

            if (cfgForm.ShowDialog() == DialogResult.OK)
            {
                object model     = cfgForm.GetValues <T_Model>();
                bool   isSuccess = BLLInvoke("Add", new object[] { model }).Equals(true);
                if (isSuccess)
                {
                    MessageBox.Show("增加成功!");
                    RefreshData();
                }
                else
                {
                    MessageBox.Show("增加失败!");
                }
            }
        }