private void btnOK_Click(object sender, EventArgs e) { if (estimateNull() == false) { return; } if (m_jrzmModel == null) { jt_jr_zm zmModel = new jt_jr_zm(); zmModel = setModelValue(zmModel); bool isSuccess = BorrowAccountsManager.Instance.Add(zmModel); if (isSuccess) { MessageBoxFunction.showSaveSuccessMessageBox(); this.DialogResult = DialogResult.OK; } } else { m_jrzmModel = setModelValue(m_jrzmModel); bool isSuccess = BorrowAccountsManager.Instance.Update(m_jrzmModel); if (isSuccess) { MessageBoxFunction.showSaveSuccessMessageBox(); this.DialogResult = DialogResult.OK; } } base.Close(); }
/// <summary> /// 给对象赋值 /// </summary> /// <param name="model"></param> /// <returns></returns> private jt_jr_zm setModelValue(jt_jr_zm model) { if (model == null) { return(null); } model.v_jrzm_no = this.textBoxNo.Text.Trim(); model.v_jr_who = this.textBoxWho.Text.Trim(); model.f_jr_money = this.decimalTextBoxMoney.EditValue; model.t_jr_time = this.dateTimeDate.Value; model.v_jrzm_name = this.textBoxDescription.Text.Trim(); model.v_jr_name = this.textBoxWhoBorrow.Text.Trim(); model.t_gh_time = this.dateTimeInputReturn.Value; model.i_gh_flag = this.checkBoxReturn.Checked == true ? 1 : 0; model.f_accrual = this.tzxDecimalTextBoxAccrual.EditValue; model.f_gh_how_money = this.tzxDecimalTextBoxReturnMoney.EditValue; model.v_remark = this.richTextBoxRemark.Text; if (m_jrzmModel == null) { model.v_jz_user_name = LoginAccountManager.Instance.getLoginUserModel().v_yh_name; model.v_jz_user_pk = LoginAccountManager.Instance.getLoginUserModel().pk.ToString(); model.t_create_time = this.dateTimeTallyDate.Value; } return(model); }
private void buttonXModify_Click(object sender, EventArgs e) { if (this.gridViewDataList.SelectedRowsCount == 0) { MessageBox.Show("请选择一条数据!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } m_selectRow = this.gridViewDataList.FocusedRowHandle; // 取出pk int selectRow = this.gridViewDataList.GetSelectedRows()[0]; int pk = Convert.ToInt32(this.gridViewDataList.GetRowCellValue(selectRow, "pk").ToString()); jt_jr_zm zczmModel = BorrowAccountsManager.Instance.GetModel(pk); EditBorrowAccountsForm form = new EditBorrowAccountsForm(); form.m_jrzmModel = zczmModel; form.ShowDialog(); if (form.DialogResult == DialogResult.OK) { this.loadDataList(); } }