/// <summary> /// UpdateOperatorDeptDefault /// </summary> /// <param name="vo"></param> /// <returns></returns> public int UpdateOperatorDeptDefault(EntityDefDeptemployee vo) { using (BizDictionary biz = new BizDictionary()) { return(biz.UpdateOperatorDeptDefault(vo)); } }
/// <summary> /// DelOperatorDept /// </summary> /// <param name="vo"></param> /// <returns></returns> public int DelOperatorDept(EntityDefDeptemployee vo) { using (BizDictionary biz = new BizDictionary()) { return(biz.DelOperatorDept(vo)); } }
/// <summary> /// DelOperDept /// </summary> internal void DelOperDept() { if (Viewer.gvDept.FocusedRowHandle < 0) { return; } if (DialogBox.Msg("是否删除?", MessageBoxIcon.Question) == DialogResult.Yes) { EntityDefDeptemployee vo = DataSourceOperDept[Viewer.gvDept.FocusedRowHandle]; if (vo != null) { using (ProxyDictionary proxy = new ProxyDictionary()) { if (proxy.Service.DelOperatorDept(vo) > 0) { LoadOperDept(vo.operCode, string.Empty); DialogBox.Msg("删除成功!"); } else { DialogBox.Msg("删除失败。"); } } } } }
/// <summary> /// LoadOperDept /// </summary> /// <param name="operCode"></param> /// <param name="deptCode"></param> void LoadOperDept(string operCode, string deptCode) { using (ProxyDictionary proxy = new ProxyDictionary()) { DataSourceOperDept = proxy.Service.LoadOperatorDept(operCode); } if (DataSourceOperDept != null && DataSourceOperDept.Count > 0) { foreach (EntityDefDeptemployee item in DataSourceOperDept) { if (GlobalDic.DataSourceDepartment.Any(t => t.deptCode.Trim() == item.deptCode.Trim())) { item.deptName = GlobalDic.DataSourceDepartment.FirstOrDefault(t => t.deptCode.Trim() == item.deptCode.Trim()).deptName; } } } else { if (!string.IsNullOrEmpty(deptCode)) { DataSourceOperDept = new List <EntityDefDeptemployee>(); EntityDefDeptemployee vo1 = new EntityDefDeptemployee(); vo1.deptCode = deptCode; if (GlobalDic.DataSourceDepartment.Any(t => t.deptCode == deptCode)) { vo1.deptName = GlobalDic.DataSourceDepartment.FirstOrDefault(t => t.deptCode == deptCode).deptName; } DataSourceOperDept.Add(vo1); } } Viewer.gcDept.DataSource = DataSourceOperDept; }
/// <summary> /// 获取员工-科室对应表 /// </summary> /// <returns></returns> public List <EntityDefDeptemployee> GetDefDeptEmployee() { string Sql = string.Empty; List <EntityDefDeptemployee> data = new List <EntityDefDeptemployee>(); SqlHelper svc = null; try { Sql = @"select b.defaultflag as defaultflag, null as deptid, a.dept_code as deptcode, a.dept_name as deptname, a.py_code as pycode, a.wb_code as wbcode, c.OPER_CODE as operCode, c.OPER_NAME as operName from code_department a inner join defDeptemployee b on a.dept_code = b.deptcode inner join code_operator c on b.operCode = c.OPER_CODE"; svc = new SqlHelper(EnumBiz.onlineDB); DataTable dt = svc.GetDataTable(Sql); EntityDefDeptemployee vo = null; if (dt != null && dt.Rows.Count > 0) { foreach (DataRow dr in dt.Rows) { vo = new EntityDefDeptemployee(); vo.operCode = dr["operCode"].ToString(); vo.deptCode = dr["deptcode"].ToString(); vo.defaultFlag = Function.Int(dr["defaultflag"].ToString()); vo.deptName = dr["deptname"].ToString(); vo.operName = dr["operName"].ToString(); vo.pyCode = SpellCodeHelper.GetPyCode(dr["operName"].ToString()); vo.wbCode = SpellCodeHelper.GetWbCode(dr["operName"].ToString()); data.Add(vo); } } } catch (Exception ex) { ExceptionLog.OutPutException(Function.GetExceptionCaption(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.FullName, System.Reflection.MethodBase.GetCurrentMethod().Name, ex.Message)); } finally { svc = null; } return(data); }
/// <summary> /// 设默认科室 /// </summary> internal void SetDefaultDept() { EntityCodeOperator vo = GetOperOrig(); if (vo == null) { DialogBox.Msg("请先保存职工主信息。"); return; } if (Viewer.gvDept.RowCount <= 0 || Viewer.gvDept.FocusedRowHandle < 0) { return; } int rowHandle = Viewer.gvDept.FocusedRowHandle; EntityDefDeptemployee defVo = new EntityDefDeptemployee(); defVo.operCode = vo.operCode; defVo.deptCode = GetFieldValueStr(Viewer.gvDept, rowHandle, EntityDefDeptemployee.Columns.deptCode); defVo.defaultFlag = 1; using (ProxyDictionary proxy = new ProxyDictionary()) { if (proxy.Service.UpdateOperatorDeptDefault(defVo) < 0) { DialogBox.Msg("设置职工默认科室失败。"); return; } else { List <EntityDefDeptemployee> data = Viewer.gcDept.DataSource as List <EntityDefDeptemployee>; for (int i = 0; i < data.Count; i++) { if (i == rowHandle) { data[i].defaultFlag = 1; } else { data[i].defaultFlag = 0; } } Viewer.gvDept.RefreshData(); Viewer.gvDept.Invalidate(); DialogBox.Msg("设置职工默认科室成功!"); } } }
/// <summary> /// NewOperDept /// </summary> internal void NewOperDept() { EntityCodeOperator vo = GetOperOrig(); if (vo == null) { DialogBox.Msg("请先保存职工主信息。"); return; } frmNew frm = new frmNew(EntityTools.ConvertToDataTable <EntityCodeDepartment>(GlobalDic.DataSourceDepartment), "deptCode", "deptCode", "deptName"); if (frm.ShowDialog() == DialogResult.OK) { if (frm.lstNo.Count > 0) { bool isDefault = false; foreach (int index in frm.lstNo) { EntityDefDeptemployee vo1 = new EntityDefDeptemployee(); vo1.operCode = vo.operCode; vo1.deptCode = GlobalDic.DataSourceDepartment[index].deptCode; if (Viewer.gvDept.RowCount == 0 && isDefault == false) { vo1.defaultFlag = 1; isDefault = true; } else { vo1.defaultFlag = 0; } using (ProxyDictionary proxy = new ProxyDictionary()) { if (proxy.Service.SaveOperatorDept(vo1) < 0) { DialogBox.Msg("保存职工所属科室失败。"); return; } } } LoadOperDept(vo.operCode, string.Empty); } } }