public frmDepartmentMasterDetail()
        {
            InitializeComponent();

            this._CurrentDptInfo = null;
            _IDepartmentMasterBL = MasterBLLFactory.GetBLL<IDepartmentMasterBL>(MasterBLLFactory.DepartmentMaster);
        }
        public void ShowForm(DepartmentMaster_dpm_Info editInfo, Common.DefineConstantValue.EditStateEnum editStatc)
        {
            this._CurrentDptInfo = editInfo;

            this.EditState = editStatc;

            this.ShowDialog();
        }
        private DepartmentMaster_dpm_Info GetDataInfo(UserInputData info)
        {
            DepartmentMaster_dpm_Info dpmInfo = new DepartmentMaster_dpm_Info();
            dpmInfo.dpm_cName = info.dpm_cName;
            dpmInfo.dpm_cRemark = info.dpm_cRemark;
            dpmInfo.dpm_lEnable = true;
            dpmInfo.dpm_cLast = UserInformation.usm_cUserLoginID;
            dpmInfo.dpm_dLastDate = System.DateTime.Now;
            if (this.EditState == Common.DefineConstantValue.EditStateEnum.OE_Insert)
            {
                dpmInfo.dpm_cAdd = this.UserInformation.usm_cUserLoginID;
                dpmInfo.dpm_dAddDate = System.DateTime.Now;

            }
            else if (this.EditState == Common.DefineConstantValue.EditStateEnum.OE_Update)
            {
                dpmInfo.dpm_RecordID = new Guid(info.dpm_RecordID);
                dpmInfo.dpm_cAdd = info.dpm_cAdd;
                dpmInfo.dpm_dAddDate = DateTime.Parse(info.dpm_dAddDate);
            }

            return dpmInfo;
        }
        private void sysToolBar_OnItemDelete_Click(object sender, EventArgs e)
        {
            try
            {
                if (lvDepartmentList.SelectedItems.Count > 0)
                {
                    if (base.ShowQuestionMessage("是否确认删除选中部门?"))
                    {
                        //int index = lvDepartmentList.SelectedItems[0].Index;
                        //DepartmentMaster_dpm_Info info = _ListDeptAllInfos[index];
                        string strID = lvDepartmentList.SelectedItems[0].SubItems[1].Text;
                        Guid gRecordId = new Guid(strID);
                        DepartmentMaster_dpm_Info info = new DepartmentMaster_dpm_Info();
                        info.dpm_RecordID = gRecordId;

                        List<CardUserMaster_cus_Info> listCardUserLeft = this._ICardUserMasterBL.SearchRecords(new CardUserMaster_cus_Info() { cus_cClassID = gRecordId });
                        if (listCardUserLeft != null && listCardUserLeft.Count > 0)
                        {
                            ShowWarningMessage("此部门仍存在相关联的教师信息,请更新或删除教师信息后重试。");
                            return;
                        }

                        ReturnValueInfo rvInfo = _IDepartmentMasterBL.Save(info, Common.DefineConstantValue.EditStateEnum.OE_Delete);

                        if (rvInfo.boolValue && !rvInfo.isError)
                        {
                            base.ShowInformationMessage("删除成功。");
                        }
                        else
                        {
                            base.ShowErrorMessage("删除失败。" + rvInfo.messageText);
                        }

                        loadAllDepartmentList();

                        sysToolBar.BtnModify_IsEnabled = false;
                        sysToolBar.BtnDelete_IsEnabled = false;
                        sysToolBar.BtnNew_IsEnabled = true;
                        sysToolBar.BtnRefresh_IsEnabled = true;
                    }
                }
                else
                {
                    base.ShowWarningMessage("请先选择一条记录。");
                }
            }
            catch (Exception ex)
            {
                ShowErrorMessage(ex);
            }
        }
        private void ShowDetailForm(Common.DefineConstantValue.EditStateEnum editStatc)
        {
            DepartmentMaster_dpm_Info info = null;

            if (editStatc == Common.DefineConstantValue.EditStateEnum.OE_Update)
            {
                if (lvDepartmentList.SelectedItems.Count > 0)
                {
                    int index = lvDepartmentList.SelectedItems[0].Index;
                    info = _ListDeptAllInfos[index];

                }
                else
                {
                    base.ShowWarningMessage("请先选择一条记录。");
                    return;
                }
            }
            else if ((editStatc == Common.DefineConstantValue.EditStateEnum.OE_Insert))
            {
                info = new DepartmentMaster_dpm_Info();
            }

            frmDepartmentMasterDetail frm = new frmDepartmentMasterDetail();
            frm.UserInformation = this.UserInformation;

            frm.ShowForm(info, editStatc);

            loadAllDepartmentList();
        }
        public ReturnValueInfo UpdateRecord(DepartmentMaster_dpm_Info infoObj)
        {
            ReturnValueInfo rvInfo = new ReturnValueInfo();
            if (infoObj == null)
            {
                rvInfo.messageText = Common.DefineConstantValue.SystemMessageText.strMessageText_E_ObjectNull;
                rvInfo.isError = true;
                return rvInfo;
            }
            try
            {
                using (SIOTSDB_HHZXDataContext db = new SIOTSDB_HHZXDataContext())
                {
                    DepartmentMaster_dpm query = db.DepartmentMaster_dpm.SingleOrDefault(t => t.dpm_RecordID == infoObj.dpm_RecordID);
                    if (query != null)
                    {
                        query.dpm_cName = infoObj.dpm_cName;
                        query.dpm_cLast = infoObj.dpm_cLast;
                        query.dpm_dLastDate = infoObj.dpm_dLastDate;
                        query.dpm_lEnable = infoObj.dpm_lEnable;
                        query.dpm_cRemark = infoObj.dpm_cRemark;

                        db.SubmitChanges();
                        rvInfo.boolValue = true;
                    }
                }
            }
            catch (Exception ex)
            {
                rvInfo.isError = true;
                rvInfo.messageText = ex.Message;
            }
            return rvInfo;
        }
        public ReturnValueInfo InsertRecord(DepartmentMaster_dpm_Info infoObj)
        {
            ReturnValueInfo rvInfo = new ReturnValueInfo();
            if (infoObj == null)
            {
                rvInfo.messageText = Common.DefineConstantValue.SystemMessageText.strMessageText_E_ObjectNull;
                rvInfo.isError = true;
                return rvInfo;
            }
            try
            {
                using (SIOTSDB_HHZXDataContext db = new SIOTSDB_HHZXDataContext())
                {
                    infoObj.dpm_RecordID = Guid.NewGuid();
                    infoObj.dpm_dAddDate = DateTime.Now;

                    DepartmentMaster_dpm newTab = Common.General.CopyObjectValue<DepartmentMaster_dpm_Info, DepartmentMaster_dpm>(infoObj);
                    db.DepartmentMaster_dpm.InsertOnSubmit(newTab);
                    db.SubmitChanges();
                    rvInfo.boolValue = true;
                }
            }
            catch (Exception ex)
            {
                rvInfo.isError = true;
                rvInfo.messageText = ex.Message;
            }
            return rvInfo;
        }
 public UserInputData(DepartmentMaster_dpm_Info showInfo)
 {
     this.dpm_RecordID = showInfo.dpm_RecordID.ToString();
     this.dpm_cName = showInfo.dpm_cName;
     this.dpm_cRemark = showInfo.dpm_cRemark;
     this.dpm_cAdd = showInfo.dpm_cAdd;
     this.dpm_dAddDate = showInfo.dpm_dAddDate.ToString("yyyy/MM/dd HH:mm:ss");
     this.dpm_cLast = showInfo.dpm_cLast;
     this.dpm_dLastDate = showInfo.dpm_dLastDate.ToString("yyyy/MM/dd HH:mm:ss");
 }