// 保存 private void btnOK_Click(object sender, EventArgs e) { if (estimateNull() == false) { return; } if (m_srzmModel == null) { jt_sr_zm zmModel = new jt_sr_zm(); zmModel = setModelValue(zmModel); bool isSuccess = IncomeAccountsManager.Instance.Add(zmModel); if (isSuccess) { MessageBoxFunction.showSaveSuccessMessageBox(); this.DialogResult = DialogResult.OK; } } else { m_srzmModel = setModelValue(m_srzmModel); bool isSuccess = IncomeAccountsManager.Instance.Update(m_srzmModel); if (isSuccess) { MessageBoxFunction.showSaveSuccessMessageBox(); this.DialogResult = DialogResult.OK; } } base.Close(); }
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_sr_zm srzmModel = IncomeAccountsManager.Instance.GetModel(pk); EditIncomeAccountsForm form = new EditIncomeAccountsForm(); form.m_srzmModel = srzmModel; form.ShowDialog(); if (form.DialogResult == DialogResult.OK) { this.loadDataList(); } }
/// <summary> /// 给对象赋值 /// </summary> /// <param name="model"></param> /// <returns></returns> private jt_sr_zm setModelValue(jt_sr_zm model) { model.v_srzm_no = this.textBoxNo.Text.Trim(); model.f_sr_money = this.decimalTextBoxMoney.EditValue; model.v_srlx_no = this.comboBoxType.SelectedValue.ToString(); model.v_srlx_name = this.comboBoxType.Text.ToString(); model.t_xf_time = this.dateTimeDate.Value; model.v_srzm_name = this.textBoxDescription.Text.Trim(); model.v_who = this.textBoxWho.Text.Trim(); model.v_zffs_name = this.comboBoxPayType.Text.ToString(); model.v_zffs_no = this.comboBoxPayType.SelectedValue.ToString(); model.v_remark = this.richTextBoxRemark.Text.Trim(); if (m_srzmModel == 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); }