public void ShowForm(GradeMaster_gdm_Info editInfo, Common.DefineConstantValue.EditStateEnum editStatc) { this._editInfo = editInfo; this.EditState = editStatc; this.ShowDialog(); }
public frmGradeMasterDetail() { InitializeComponent(); this._editInfo = null; this._gradeMasterBL = MasterBLLFactory.GetBLL<IGradeMasterBL>(MasterBLLFactory.GradeMaster); this._IClassMasterBL = MasterBLLFactory.GetBLL<IClassMasterBL>(MasterBLLFactory.ClassMaster); }
private void frmGradeMasterDetail_Load(object sender, EventArgs e) { if (_editInfo == null) { _editInfo = this.BaseParam as GradeMaster_gdm_Info; } if (this.EditState == Common.DefineConstantValue.EditStateEnum.OE_Insert) { this.Text = "新增 - " + this.Text; UserInputData insertInfo = new UserInputData(); proUserData.SelectedObject = insertInfo; } else if (this.EditState == Common.DefineConstantValue.EditStateEnum.OE_Update) { this.Text = "查看 - " + this.Text; UserInputData showData = new UserInputData(_editInfo); proUserData.SelectedObject = showData; } }
public ReturnValueInfo UpdateRecord(GradeMaster_gdm_Info infoObject) { ReturnValueInfo returnInfo = new ReturnValueInfo(false); if (infoObject != null) { try { using (SIOTSDB_HHZXDataContext db = new SIOTSDB_HHZXDataContext()) { db.Connection.Open(); db.Transaction = db.Connection.BeginTransaction(); try { GradeMaster_gdm updateData = db.GradeMaster_gdm.FirstOrDefault(t => t.gdm_cRecordID == infoObject.gdm_cRecordID); if (updateData != null) { updateData.gdm_cGradeName = infoObject.gdm_cGradeName; updateData.gdm_cPraepostorID = infoObject.gdm_cPraepostorID; updateData.gdm_cRemark = infoObject.gdm_cRemark; updateData.gdm_cAbbreviation = infoObject.gdm_cAbbreviation; updateData.gdm_cLast = infoObject.gdm_cLast; updateData.gdm_cLastDate = infoObject.gdm_cLastDate.Value; updateData.gdm_cLastDate = DateTime.Now; db.SubmitChanges(); List<CodeMaster_cmt> listCodeKey = db.CodeMaster_cmt.Where(x => x.cmt_cKey1 == Common.DefineConstantValue.CodeMasterDefine.KEY1_SIOT_CardUserClass).ToList(); List<ClassMaster_csm> listClassInfos = db.ClassMaster_csm.Where(x => x.csm_cGDMID == updateData.gdm_cRecordID).ToList(); foreach (ClassMaster_csm classItem in listClassInfos) { classItem.csm_cClassName = updateData.gdm_cGradeName; CodeMaster_cmt tagClass = listCodeKey.Find(x => x.cmt_cKey2 == classItem.csm_cClassNum); if (tagClass != null) { string strClassNum = tagClass.cmt_cValue; if (!string.IsNullOrEmpty(tagClass.cmt_cValue) && tagClass.cmt_cValue.Length > 1) { strClassNum = "(" + strClassNum.Substring(0, 2) + ")" + strClassNum.Substring(2, 1); } else { strClassNum = "(" + strClassNum + ")"; } classItem.csm_cClassName += strClassNum; } } if (listClassInfos != null && listClassInfos.Count > 0) { db.SubmitChanges(); } db.Transaction.Commit(); db.Connection.Close(); returnInfo.boolValue = true; } else { returnInfo.messageText = Common.DefineConstantValue.SystemMessageText.strMessageText_E_UpdateDataNull; } } catch (Exception exx) { db.Transaction.Rollback(); db.Connection.Close(); throw exx; } } } catch (Exception Ex) { returnInfo.messageText = Ex.Message; } } else { returnInfo.messageText = Common.DefineConstantValue.SystemMessageText.strMessageText_E_ObjectNull; } return returnInfo; }
public ReturnValueInfo InsertRecord(GradeMaster_gdm_Info infoObject) { ReturnValueInfo returnInfo = new ReturnValueInfo(false); if (infoObject != null) { try { using (SIOTSDB_HHZXDataContext db = new SIOTSDB_HHZXDataContext()) { GradeMaster_gdm insertData = Common.General.CopyObjectValue<GradeMaster_gdm_Info, GradeMaster_gdm>(infoObject); db.GradeMaster_gdm.InsertOnSubmit(insertData); db.SubmitChanges(); returnInfo.boolValue = true; returnInfo.ValueObject = infoObject; } } catch (Exception Ex) { returnInfo.messageText = Ex.Message; } } else { returnInfo.messageText = Common.DefineConstantValue.SystemMessageText.strMessageText_E_ObjectNull; } return returnInfo; }
public UserInputData(GradeMaster_gdm_Info showInfo) { this.gdm_cRecordID = showInfo.gdm_cRecordID; this.gdm_cGradeName = showInfo.gdm_cGradeName; this.gdm_cPraepostorID = showInfo.gdm_cPraepostorID.ToString(); this.gdm_cRemark = showInfo.gdm_cRemark; this.gdm_cAbbreviation = showInfo.gdm_cAbbreviation; }
private void sysToolBar_OnItemDelete_Click(object sender, EventArgs e) { if (lvGradeList.SelectedItems != null && lvGradeList.SelectedItems.Count > 0) { if (!ShowQuestionMessage("是否确认需要删除选中项?")) { return; } try { GradeMaster_gdm_Info delInfo = new GradeMaster_gdm_Info(); delInfo.gdm_cRecordID = new Guid(lvGradeList.SelectedItems[0].SubItems[0].Text); List<ClassMaster_csm_Info> listSubClass = this._IClassMasterBL.SearchRecords(new ClassMaster_csm_Info() { csm_cGDMID = delInfo.gdm_cRecordID }); if (listSubClass != null && listSubClass.Count > 0) { ShowWarningMessage("此年级仍与部分班级关联,请更新或删除相关班级信息后再试。"); return; } ReturnValueInfo returnInfo = this._IGradeMasterBL.Save(delInfo, Common.DefineConstantValue.EditStateEnum.OE_Delete); if (returnInfo.boolValue) { ShowInformationMessage("删除成功。"); loadAllGradeList(); } else { ShowErrorMessage(returnInfo.messageText); } } catch (Exception Ex) { ShowErrorMessage(Ex.Message); } } else { ShowWarningMessage("请先选择一条记录。"); } }
private void ShowDetailForm(Common.DefineConstantValue.EditStateEnum editStatc) { if (lvGradeList.SelectedItems.Count >= 0) { frmGradeMasterDetail frm = new frmGradeMasterDetail(); GradeMaster_gdm_Info showInfo = new GradeMaster_gdm_Info(); ReturnValueInfo returnInfo = new ReturnValueInfo(false); try { switch (editStatc) { case Common.DefineConstantValue.EditStateEnum.OE_Insert: showInfo.gdm_cRecordID = Guid.NewGuid(); frm.ShowForm(showInfo, editStatc); if (showInfo.lSave) { returnInfo = this._IGradeMasterBL.Save(showInfo, Common.DefineConstantValue.EditStateEnum.OE_Insert); } break; case Common.DefineConstantValue.EditStateEnum.OE_Update: if (lvGradeList.SelectedItems.Count > 0) { showInfo.gdm_cRecordID = new Guid(lvGradeList.SelectedItems[0].Text); showInfo = this._IGradeMasterBL.DisplayRecord(showInfo) as GradeMaster_gdm_Info; frm.ShowForm(showInfo, editStatc); if (showInfo.lSave) { returnInfo = this._IGradeMasterBL.Save(showInfo, Common.DefineConstantValue.EditStateEnum.OE_Update); } } break; default: break; } if (showInfo.lSave) { if (!returnInfo.boolValue) { ShowErrorMessage(returnInfo.messageText); } //else //{ // loadAllGradeList(); //} } } catch (Exception Ex) { ShowErrorMessage(Ex.Message); } loadAllGradeList(); } }