public ActionResult Edit(int? id, string returnUrl) { Dept dept = new Dept(); if (id != null) dept = _deptRepository.GetById(id.Value); return View(dept); }
public ActionResult Edit(Dept model, string returnUrl) { if (model.ID == 0) { _deptRepository.Insert(model); } else _deptRepository.Update(model); return RedirectToAction("Index"); }
private void BindDDL(Dept current) { List<Dept> mys = ResolveDDL<Dept>(DeptHelper.Depts, current.ID); // 绑定到下拉列表(启用模拟树功能和不可选择项功能) ddlParent.EnableSimulateTree = true; ddlParent.DataTextField = "Name"; ddlParent.DataValueField = "ID"; ddlParent.DataSimulateTreeLevelField = "TreeLevel"; ddlParent.DataEnableSelectField = "Enabled"; ddlParent.DataSource = mys; ddlParent.DataBind(); if (current.Parent != null) { // 选中当前节点的父节点 ddlParent.SelectedValue = current.Parent.ID.ToString(); } }
private void SaveItem() { Dept item = new Dept(); item.Name = tbxName.Text.Trim(); item.SortIndex = Convert.ToInt32(tbxSortIndex.Text.Trim()); item.Remark = tbxRemark.Text.Trim(); int parentID = Convert.ToInt32(ddlParent.SelectedValue); if (parentID == -1) { item.Parent = null; } else { Dept dept = Attach<Dept>(parentID); item.Parent = dept; } DB.Depts.Add(item); DB.SaveChanges(); }
// // Dept // public Dept SaveDept(Dept dept) { return(DeptDao.Save(dept)); }
public bool CreateDept(Dept dept) { return(deptDao.Insert(dept)); }
public async Task <IActionResult> OnPostDeptUser_Grid2_DoPostBackAsync(string[] Grid2_fields, int Grid2_pageIndex, string Grid2_sortField, string Grid2_sortDirection, string ttbSearchMessage, int ddlGridPageSize, string actionType, int selectedDeptId, int[] deletedUserIDs) { var ttbSearchMessageUI = UIHelper.TwinTriggerBox("ttbSearchMessage"); if (actionType == "trigger1") { ttbSearchMessageUI.Text(String.Empty); ttbSearchMessageUI.ShowTrigger1(false); // 清空传入的搜索值 ttbSearchMessage = String.Empty; } else if (actionType == "trigger2") { ttbSearchMessageUI.ShowTrigger1(true); } else if (actionType == "delete") { // 在操作之前进行权限检查 if (!CheckPower("CoreDeptUserDelete")) { CheckPowerFailWithAlert(); return(UIHelper.Result()); } Dept role = await DB.Depts .Include(r => r.Users) .Where(r => r.ID == selectedDeptId) .FirstOrDefaultAsync(); foreach (int userID in deletedUserIDs) { User user = role.Users.Where(u => u.ID == userID).FirstOrDefault(); if (user != null) { role.Users.Remove(user); } } await DB.SaveChangesAsync(); } var grid2UI = UIHelper.Grid("Grid2"); var pagingInfo = new PagingInfoViewModel { SortField = Grid2_sortField, SortDirection = Grid2_sortDirection, PageIndex = Grid2_pageIndex, PageSize = ddlGridPageSize }; var deptUsers = await DeptUser_GetDataAsync(pagingInfo, selectedDeptId, ttbSearchMessage); // 1. 设置总项数 grid2UI.RecordCount(pagingInfo.RecordCount); // 2. 设置每页显示项数 if (actionType == "changeGridPageSize") { grid2UI.PageSize(ddlGridPageSize); } // 3.设置分页数据 grid2UI.DataSource(deptUsers, Grid2_fields); return(UIHelper.Result()); }
/// <summary> /// 添加部门类型 /// </summary> /// <param name="dept"></param> /// <returns></returns> public bool AddDept(Dept dept) { return(base.Change <Dept>().Insert(dept)); }
public void BindByStation() { DataTable dt = this.GetTable(); //获取人员列表。 SelectAccpers accps = new SelectAccpers(); accps.Retrieve(SelectAccperAttr.FK_Node, this.FK_Node, SelectAccperAttr.WorkID, this.WorkID); Dept dept = new Dept(); string fk_dept = ""; this.Pub1.AddTable("width=100%"); string info = ""; if (WebUser.FK_Dept.Length > 2) { if (this.FK_Dept == WebUser.FK_Dept) { info = "<b><a href='Accepter.aspx?ToNode=" + this.ToNode + "&WorkID=" + this.WorkID + "&FK_Node=" + this.FK_Node + "&type=1&FK_Dept=" + WebUser.FK_Dept.Substring(0, WebUser.FK_Dept.Length - 2) + "'>上一级部门人员</b></a>|<b><a href='Accepter.aspx?ToNode=" + this.ToNode + "&WorkID=" + this.WorkID + "&FK_Node=" + this.FK_Node + "&type=1&FK_Dept=" + this.FK_Dept + "&IsNextDept=1' >下一级部门人员</b></a>"; } else { info = "<b><a href='Accepter.aspx?ToNode=" + this.ToNode + "&WorkID=" + this.WorkID + "&FK_Node=" + this.FK_Node + "&type=1&FK_Dept=" + WebUser.FK_Dept + "'>本部门人员</a></b>"; } } else { info = "<b><a href='Accepter.aspx?ToNode=" + this.ToNode + "&WorkID=" + this.WorkID + "&FK_Node=" + this.FK_Node + "&type=1&FK_Dept=" + WebUser.FK_Dept + "'>本部门人员</a> | <a href='Accepter.aspx?ToNode=" + this.ToNode + "&WorkID=" + this.WorkID + "&FK_Node=" + this.FK_Node + "&type=1&FK_Dept=" + this.FK_Dept + "&IsNextDept=1' >下一级部门人员</b></a>"; } BP.WF.Node toNode = new BP.WF.Node(this.MyToNode); this.Pub1.AddCaptionLeft("<span style='color:red'>选择 [" + toNode.Name + "]</span> 可选择范围:" + dt.Rows.Count + " 位。" + info); if (dt.Rows.Count > 50) { /*多于一定的数,就显示导航。*/ this.Pub1.AddTRSum(); this.Pub1.Add("<TD class=BigDoc colspan=5>"); foreach (DataRow dr in dt.Rows) { if (fk_dept != dr["FK_Dept"].ToString()) { fk_dept = dr["FK_Dept"].ToString(); dept = new Dept(fk_dept); dr["DeptName"] = dept.Name; this.Pub1.Add("<a href='#d" + dept.No + "' >" + dept.Name + "</a> "); } } this.Pub1.AddTDEnd(); this.Pub1.AddTREnd(); } int idx = -1; bool is1 = false; foreach (DataRow dr in dt.Rows) { idx++; if (fk_dept != dr["FK_Dept"].ToString()) { switch (idx) { case 0: break; case 1: this.Pub1.AddTD(); this.Pub1.AddTD(); this.Pub1.AddTD(); this.Pub1.AddTD(); this.Pub1.AddTREnd(); break; case 2: this.Pub1.AddTD(); this.Pub1.AddTD(); this.Pub1.AddTD(); this.Pub1.AddTREnd(); break; case 3: this.Pub1.AddTD(); this.Pub1.AddTD(); this.Pub1.AddTREnd(); break; case 4: this.Pub1.AddTD(); this.Pub1.AddTREnd(); break; default: throw new Exception("error"); } this.Pub1.AddTRSum(); fk_dept = dr["FK_Dept"].ToString(); string deptName = dr["DeptName"].ToString(); this.Pub1.AddTD("colspan=5 aligen=left class=FDesc ", "<a name='d" + dept.No + "'>" + deptName + "</a>"); this.Pub1.AddTREnd(); is1 = false; idx = 0; } string no = dr["No"].ToString(); string name = dr["Name"].ToString(); CheckBox cb = new CheckBox(); if (BP.WF.Glo.IsShowUserNoOnly) { cb.Text = no; } else { cb.Text = no + " " + name; } cb.ID = "CB_" + no; if (accps.Contains("FK_Emp", no)) { cb.Checked = true; } switch (idx) { case 0: is1 = this.Pub1.AddTR(is1); this.Pub1.AddTD(cb); break; case 1: case 2: case 3: this.Pub1.AddTD(cb); break; case 4: this.Pub1.AddTD(cb); this.Pub1.AddTREnd(); idx = -1; break; default: throw new Exception("error"); } this.Pub1.AddTREnd(); } this.Pub1.AddTableEnd(); this.Pub1.AddHR(); Button btn = new Button(); btn.Text = "保存"; btn.ID = "Btn_Save"; btn.CssClass = "Btn"; //btn.Width = 80; btn.Click += new EventHandler(btn_Save_Click); this.Pub1.Add(btn); }
/// <summary> /// 修改一级科室 /// </summary> /// <param name="id"></param> /// <returns></returns> public ActionResult EditFristDept(int?id) { Dept dept = db.Dept.Find(id); return(View(dept)); }
/// <summary> /// 增加一条数据 /// </summary> public void Add(Dept model) { dal.Add(model); }
public void Save(Dept dept) { dept.Save(); }
/// <summary> /// 新增组织 /// </summary> /// <param name="dept">部门类</param> /// <returns>所影响的行数</returns> public int insertDept(Dept dept) { return(deptDao.insertDept(dept)); }
/// <summary> /// 同步钉钉通讯录到CCGPM /// </summary> /// <returns></returns> public bool AnsyOrgToCCGPM() { string access_token = getAccessToken(); string url = "https://oapi.dingtalk.com/department/list?access_token=" + access_token; try { string str = new HttpWebResponseUtility().HttpResponseGet(url); DepartMent_List departMentList = FormatToJson.ParseFromJson <DepartMent_List>(str); //部门集合 if (departMentList != null && departMentList.department != null && departMentList.department.Count > 0) { //删除旧数据 ClearOrg_Old(); //获取根部门 DepartMentDetailInfo rootDepartMent = new DepartMentDetailInfo(); foreach (DepartMentDetailInfo deptMenInfo in departMentList.department) { if (deptMenInfo.id == "1") { rootDepartMent = deptMenInfo; break; } } //增加跟部门 int deptIdx = 0; Dept rootDept = new Dept(); rootDept.No = rootDepartMent.id; rootDept.Name = rootDepartMent.name; rootDept.ParentNo = "0"; rootDept.DirectInsert(); //部门信息 foreach (DepartMentDetailInfo deptMentInfo in departMentList.department) { //增加部门,排除根目录 if (deptMentInfo.id != "1") { Dept dept = new Dept(); dept.No = deptMentInfo.id; dept.Name = deptMentInfo.name; dept.ParentNo = deptMentInfo.parentid; dept.DirectInsert(); } //部门人员 DepartMentUser_List userList = GenerDeptUser_List(access_token, deptMentInfo.id); if (userList != null) { foreach (DepartMentUserInfo userInfo in userList.userlist) { Emp emp = new Emp(); DeptEmp deptEmp = new DeptEmp(); //如果账户存在则人员信息不添加,添加关联表 if (emp.IsExit(EmpAttr.No, userInfo.userid) == true) { deptEmp.MyPK = deptMentInfo.id + "_" + emp.No; deptEmp.FK_Dept = deptMentInfo.id; deptEmp.FK_Emp = emp.No; deptEmp.DirectInsert(); continue; } //增加人员 emp.No = userInfo.userid; emp.Name = userInfo.name; emp.FK_Dept = deptMentInfo.id; emp.Tel = userInfo.mobile; emp.Email = userInfo.email; //emp.Idx = DataType.IsNullOrEmpty(userInfo.order) == true ? 0 : Int32.Parse(userInfo.order); emp.DirectInsert(); //增加人员与部门对应表 deptEmp.MyPK = deptMentInfo.id + "_" + emp.No; deptEmp.FK_Dept = deptMentInfo.id; deptEmp.FK_Emp = emp.No; deptEmp.DirectInsert(); } } } #region 处理部门名称全程 //OrgInit_NameOfPath nameOfPath = new OrgInit_NameOfPath(); //if (nameOfPath.IsCanDo) // nameOfPath.Do(); #endregion return(true); } } catch (Exception ex) { BP.DA.Log.DefaultLogWriteLineError(ex.Message); } return(false); }
/// <summary> /// 增量同步组织结构 /// </summary> /// <returns></returns> public string AnsyIncrementOrgToGPM() { string access_token = getAccessToken(); string url = "https://oapi.dingtalk.com/department/list?access_token=" + access_token; try { StringBuilder append = new StringBuilder(); string str = new HttpWebResponseUtility().HttpResponseGet(url); DepartMent_List departMentList = FormatToJson.ParseFromJson <DepartMent_List>(str); if (departMentList == null || departMentList.department == null || departMentList.department.Count == 0) { return("钉钉获取部门出错。"); } #region 获取钉钉组织结构,进行更新与新增 //增加跟部门 int deptIdx = 0; bool doSomeThing = false; //部门信息 foreach (DepartMentDetailInfo deptMentInfo in departMentList.department) { deptIdx++; doSomeThing = false; //增加部门,排除根目录 if (deptMentInfo.id != "1") { Dept dept = new Dept(); if (dept.IsExit(DeptAttr.No, deptMentInfo.id) == true) { if (dept.No == deptMentInfo.id && !dept.Name.Equals(deptMentInfo.name)) { doSomeThing = true; append.Append("\r\n部门名称发生变化:" + dept.Name + " --> " + deptMentInfo.name); } if (!dept.ParentNo.Equals(deptMentInfo.parentid)) { doSomeThing = true; append.Append("\r\n部门父级发生变化:" + dept.ParentNo + " --> " + deptMentInfo.parentid); } //有变化,更新 if (doSomeThing == true) { dept.No = deptMentInfo.id; dept.Name = deptMentInfo.name; dept.ParentNo = deptMentInfo.parentid; dept.DirectUpdate(); } } else { //不存在则新增 dept.No = deptMentInfo.id; dept.Name = deptMentInfo.name; dept.ParentNo = deptMentInfo.parentid; dept.DirectInsert(); append.Append("\r\n新增部门:" + deptMentInfo.id + " - " + deptMentInfo.name); } } //部门人员 DepartMentUser_List userList = GenerDeptUser_List(access_token, deptMentInfo.id); if (userList != null) { foreach (DepartMentUserInfo userInfo in userList.userlist) { Emp emp = new Emp(); emp.No = userInfo.userid; DeptEmp deptEmp = new DeptEmp(); //如果账户存在则人员信息不添加,添加关联表 if (emp.RetrieveFromDBSources() > 0) { if (!emp.Name.Equals(userInfo.name)) { emp.Name = userInfo.name; emp.DirectUpdate(); append.Append("\r\n人员名称发生变化:" + emp.Name + " --> " + userInfo.name); } deptEmp.MyPK = deptMentInfo.id + "_" + emp.No; if (deptEmp.RetrieveFromDBSources() > 0) { continue; } //增加人员归属部门 deptEmp.FK_Dept = deptMentInfo.id; deptEmp.FK_Emp = emp.No; deptEmp.DirectInsert(); append.Append("\r\n增加人员归属部门:" + emp.Name + " - " + deptMentInfo.name); continue; } //增加人员 emp.No = userInfo.userid; emp.Name = userInfo.name; emp.FK_Dept = deptMentInfo.id; emp.Tel = userInfo.mobile; emp.Email = userInfo.email; //emp.Idx = DataType.IsNullOrEmpty(userInfo.order) == true ? 0 : Int32.Parse(userInfo.order); emp.DirectInsert(); append.Append("\r\n增加人员:" + emp.Name + " 所属部门:" + deptMentInfo.name); //增加人员与部门对应表 deptEmp.MyPK = deptMentInfo.id + "_" + emp.No; deptEmp.FK_Dept = deptMentInfo.id; deptEmp.FK_Emp = emp.No; deptEmp.DirectInsert(); } } } #endregion #region GPM组织结构,在钉钉不存在进行删除部门与人员关系表,人员表不进行删除,删除业务人员表WF_Emp Depts gpm_Depts = new Depts(); gpm_Depts.RetrieveAllFromDBSource(); foreach (Dept gpm_Dept in gpm_Depts) { bool isHave = false; foreach (DepartMentDetailInfo ding_Dept in departMentList.department) { if (gpm_Dept.No.Equals(ding_Dept.id)) { isHave = true; break; } } //部门在钉钉不存在则进行删除:部门表、部门人员、部门人员岗位、部门职位、部门岗位 if (isHave == false) { //部门岗位 DeptStation deptStation = new DeptStation(); int iDeptStation = deptStation.Delete(DeptStationAttr.FK_Dept, gpm_Dept.No); //部门人员岗位 DeptEmpStation deptEmpStation = new DeptEmpStation(); int iDeptEmpStation = deptEmpStation.Delete(DeptEmpStationAttr.FK_Dept, gpm_Dept.No); //部门人员 DeptEmp deptEmp = new DeptEmp(); int iDeptEmp = deptEmp.Delete(DeptEmpAttr.FK_Dept, gpm_Dept.No); //部门表 Dept dt = new Dept(gpm_Dept.No); dt.Delete(); append.Append("\r\n删除部门:" + gpm_Dept.Name + " 部门全路径:" + gpm_Dept.NameOfPath); append.Append("\r\n 部门岗位 " + iDeptStation + " 条记录"); append.Append("\r\n 部门人员岗位 " + iDeptEmpStation + " 条记录"); append.Append("\r\n 部门人员 " + iDeptEmp + " 条记录"); } else { //组织结构人员 DeptEmps deptEmps = new DeptEmps(); QueryObject obj = new QueryObject(deptEmps); obj.AddWhere(DeptEmpAttr.FK_Dept, gpm_Dept.No); obj.addAnd(); obj.AddWhereNotIn(DeptEmpAttr.FK_Emp, "'admin'"); obj.DoQuery(); //部门下没有人员不需要处理 if (deptEmps == null || deptEmps.Count == 0) { continue; } //钉钉部门人员 DepartMentUser_List userList = GenerDeptUser_List(access_token, gpm_Dept.No); //部门下没有人员,清除部门下的所有人员 if (userList == null || userList.userlist.Count == 0) { append.Append("\r\n删除部门下的人员,部门:" + gpm_Dept.Name + " 部门全路径:" + gpm_Dept.NameOfPath); foreach (DeptEmp dt in deptEmps) { dt.Delete(); Emp ep = new Emp(); ep.No = dt.FK_Emp; ep.RetrieveFromDBSources(); append.Append("\r\n 人员编号:" + dt.FK_Emp + " 姓名:" + ep.Name); } continue; } //判断部门下的人员是否存在 foreach (DeptEmp deptEmp in deptEmps) { isHave = false; foreach (DepartMentUserInfo userInfo in userList.userlist) { if (deptEmp.FK_Emp.Equals(userInfo.userid)) { isHave = true; break; } } //不存在,删除 if (isHave == false) { deptEmp.Delete(); Emp ep = new Emp(); ep.No = deptEmp.FK_Emp; ep.RetrieveFromDBSources(); append.Append("\r\n删除部门下的人员,部门:" + gpm_Dept.Name + " 部门全路径:" + gpm_Dept.NameOfPath); append.Append("\r\n 人员编号:" + deptEmp.FK_Emp + " 姓名:" + ep.Name); } } } } //删除没包含在部门的人员 #endregion #region 处理部门名称全程 //OrgInit_NameOfPath nameOfPath = new OrgInit_NameOfPath(); //if (nameOfPath.IsCanDo) // nameOfPath.Do(); #endregion return(append.ToString()); } catch (Exception ex) { BP.DA.Log.DefaultLogWriteLineError(ex.Message); } return(null); }
public static void UpdateBOM(BillOfMaterials bom, BusiLog bl) { using (SqlConnection conn = ConnectionPool.BorrowConnection()) { //conn.Open(); SqlTransaction trans = conn.BeginTransaction(IsolationLevel.ReadCommitted); try { string strSysTime = SqlHelper.ExecuteScalar(trans, CommandType.Text, "select getdate()").ToString(); DateTime dtSysTime = DateTime.Parse(strSysTime); Dept dept = new Dept(); dept.cnvcDeptID = bom.cnvcDeptID; dept = EntityMapping.Get(dept, trans) as Dept; OilStorage os = new OilStorage(); os.cnvcGoodsName = bom.cnvcGoodsName; os.cnvcGoodsType = bom.cnvcGoodsType; os.cnvcDeptID = bom.cnvcDeptID; os = EntityMapping.Get(os, trans) as OilStorage; if (null == os) { throw new BusinessException(bexType.noobject, "库存获取错误"); } Guid gd = Guid.NewGuid(); //判断修改操作类型 改多为出库 改少为入库 //专供油出库 BillOfMaterials oldbom = new BillOfMaterials(); oldbom.cnvcBillNo = bom.cnvcBillNo; oldbom.cnvcDeptID = bom.cnvcDeptID; oldbom = EntityMapping.Get(oldbom, trans) as BillOfMaterials; string strOperType = ""; if (oldbom.cnnCount > bom.cnnCount) { strOperType = InType.BOMModIn; } else { strOperType = InType.BOMModOut; } //验收单 //bom.cnvcInType = strOperType; if (bom.cnnCount != oldbom.cnnCount) { //库存日志 OilStorageLog ol = new OilStorageLog(bom.ToTable()); ol.cndOperDate = dtSysTime; ol.cnvcDeptName = dept.cnvcDeptName; ol.cnvcOperType = strOperType; ol.cnnSerial = gd; ol.cnnLastCount = oldbom.cnnCount; //os.cnnStorageCount; ol.cnnInOutCount = oldbom.cnnCount - bom.cnnCount; //bom.cnnCount-oldbom.cnnCount; ol.cnnCurCount = bom.cnnCount; //os.cnnStorageCount + oldbom.cnnCount - bom.cnnCount; EntityMapping.Create(ol, trans); OilStorageLogHis olhis = new OilStorageLogHis(ol.ToTable()); EntityMapping.Create(olhis, trans); oldbom.SynchronizeModifyValue(bom); oldbom.cnnCount = bom.cnnCount; oldbom.cnnReceiveCount = bom.cnnReceiveCount; oldbom.cnnSpecialFee = bom.cnnSpecialFee; EntityMapping.Update(oldbom, trans); //库存 os.cnnStorageCount = os.cnnStorageCount + ol.cnnInOutCount; //ol.cnnCurCount; EntityMapping.Update(os, trans); } //日志 bl.cnnSerial = gd; bl.cnvcComments = "领料单修改,出入库量:" + (oldbom.cnnCount - bom.cnnCount); bl.cnvcOperType = OperType.OP203; bl.cndOperDate = dtSysTime; bl.cnvcSource = InSource.bs; EntityMapping.Create(bl, trans); trans.Commit(); } catch (BusinessException bex) { trans.Rollback(); LogAdapter.WriteBusinessException(bex); throw bex; } catch (SqlException sex) { trans.Rollback(); LogAdapter.WriteDatabaseException(sex); throw sex; } catch (Exception ex) { trans.Rollback(); LogAdapter.WriteFeaturesException(ex); throw ex; } finally { ConnectionPool.ReturnConnection(conn); } } }
public void AddToDepts(Dept dept) { base.AddObject("Depts", dept); }
public DataTable getDept(Dept dept) { return(SqlHelper.ExecuteDataTable(CommandType.Text, "select cnnDeptID as 部门ID,cnvcDeptName as 部门名称,cnnParentDeptID as 上级部门ID,cnvcManager as 部门管理员,cnnDiscount as 部门折扣上限,cnvcComments as 描述 from tbDept where cnvcDeptName like '%" + dept.cnvcDeptName + "%' or cnnParentDeptID like '%" + dept.cnnParentDeptID.ToString() + "%'")); }
/// <summary> /// 操作员登录 /// </summary> /// <param name="OperName"></param> /// <param name="PWD"></param> public void OperLogin(string OperName, string PWD) { alOperFunc = new ArrayList(); oper = new Oper(); try { conn = ConnectionPool.BorrowConnection(); //trans = conn.BeginTransaction(); //安全比对 DataTable dtOper = SqlHelper.ExecuteDataTable(conn, CommandType.Text, "select * from tbOper where cnvcOperName = '" + OperName + "' and cnvcPwd = '" + PWD + "'"); if (null == dtOper) { throw new BusinessException("操作员登录", "操作员名称或密码错误!"); } if (dtOper.Rows.Count == 0) { throw new BusinessException("操作员登录", "操作员名称或密码错误!"); } oper = new Oper(dtOper); //操作员功能列表 if (oper.cnnDeptID != 0) //=0为系统管理员 { //系统管理员具有所有权限 //否则比对权限列表 DataTable dtOperFunc = SqlHelper.ExecuteDataTable(conn, CommandType.Text, "select * from tbOperFunc where cnnOperID = " + oper.cnnOperID); foreach (DataRow dr in dtOperFunc.Rows) { FuncList funcList = new FuncList(dr); alOperFunc.Add(funcList.cnvcFuncCode); } if (alOperFunc.Count == 0) { throw new BusinessException("操作员登录", "操作员无任何权限!"); } } if (oper.cnnDeptID == 0) { iDiscount = 0; } else { Dept dept = new Dept(); dept.cnnDeptID = oper.cnnDeptID; Dept oldDept = EntityMapping.Get(dept, conn) as Dept; iDiscount = oldDept.cnnDiscount; } //折扣上限 //trans.Commit(); } catch (BusinessException bex) //业务异常 { //LogAdapter.WriteBusinessException(bex); throw new BusinessException(bex.Type, bex.Message); } catch (SqlException sex) //数据库异常 { //事务回滚 //trans.Rollback(); //LogAdapter.WriteDatabaseException(sex); throw new BusinessException("数据库异常", sex.Message); } catch (Exception ex) //其他异常 { //事务回滚 //trans.Rollback(); //LogAdapter.WriteFeaturesException(ex); throw new BusinessException("其它异常", ex.Message); } finally { ConnectionPool.ReturnConnection(conn); } }
/// <summary> /// 修改组织 /// </summary> /// <param name="dept">部门实体类</param> /// <returns>所影响的行数</returns> public int updateDept(Dept dept) { return(deptDao.updateDept(dept)); }
public void Update(Dept dept) { _dbcontext.Entry(dept).State = EntityState.Modified; }
/// <summary> /// 通用的登陆 /// </summary> /// <param name="em">人员</param> /// <param name="lang">语言</param> /// <param name="auth">授权人</param> /// <param name="isRememberMe">是否记录cookies</param> /// <param name="IsRecSID">是否记录SID</param> public static void SignInOfGener(Emp em, string lang = "CH", bool isRememberMe = false, bool IsRecSID = false, string authNo = null, string authName = null) { if (System.Web.HttpContext.Current == null) { SystemConfig.IsBSsystem = false; } else { SystemConfig.IsBSsystem = true; } if (SystemConfig.IsBSsystem) { BP.Sys.Glo.WriteUserLog("SignIn", em.No, "登录"); } WebUser.No = em.No; WebUser.Name = em.Name; if (DataType.IsNullOrEmpty(authNo) == false) { WebUser.Auth = authNo; //被授权人,实际工作的执行者. WebUser.AuthName = authName; } else { WebUser.Auth = null; WebUser.AuthName = null; } #region 解决部门的问题. if (BP.Sys.SystemConfig.OSDBSrc == OSDBSrc.Database) { if (DataType.IsNullOrEmpty(em.FK_Dept) == true) { string sql = ""; sql = "SELECT FK_Dept FROM Port_DeptEmp WHERE FK_Emp='" + em.No + "'"; string deptNo = BP.DA.DBAccess.RunSQLReturnString(sql); if (DataType.IsNullOrEmpty(deptNo) == true) { sql = "SELECT FK_Dept FROM Port_Emp WHERE No='" + em.No + "'"; deptNo = BP.DA.DBAccess.RunSQLReturnString(sql); if (DataType.IsNullOrEmpty(deptNo) == true) { throw new Exception("@登录人员(" + em.No + "," + em.Name + ")没有维护部门..."); } } else { //调用接口更改所在的部门. WebUser.ChangeMainDept(em.No, deptNo); } } BP.Port.Dept dept = new Dept(); dept.No = em.FK_Dept; if (dept.RetrieveFromDBSources() == 0) { throw new Exception("@登录人员(" + em.No + "," + em.Name + ")没有维护部门,或者部门编号{" + em.FK_Dept + "}不存在."); } } if (BP.Sys.SystemConfig.OSDBSrc == OSDBSrc.WebServices) { var ws = DataType.GetPortalInterfaceSoapClientInstance(); DataTable dt = ws.GetEmpHisDepts(em.No); string strs = BP.DA.DBAccess.GenerWhereInPKsString(dt); Paras ps = new Paras(); ps.SQL = "UPDATE WF_Emp SET Depts=" + SystemConfig.AppCenterDBVarStr + "Depts WHERE No=" + SystemConfig.AppCenterDBVarStr + "No"; ps.Add("Depts", strs); ps.Add("No", em.No); BP.DA.DBAccess.RunSQL(ps); dt = ws.GetEmpHisStations(em.No); strs = BP.DA.DBAccess.GenerWhereInPKsString(dt); ps = new Paras(); ps.SQL = "UPDATE WF_Emp SET Stas=" + SystemConfig.AppCenterDBVarStr + "Stas WHERE No=" + SystemConfig.AppCenterDBVarStr + "No"; ps.Add("Stas", strs); ps.Add("No", em.No); BP.DA.DBAccess.RunSQL(ps); } #endregion 解决部门的问题. WebUser.FK_Dept = em.FK_Dept; WebUser.FK_DeptName = em.FK_DeptText; if (IsRecSID) { //判断是否视图,如果为视图则不进行修改 if (BP.DA.DBAccess.IsView("Port_Emp", SystemConfig.AppCenterDBType) == false) { /*如果记录sid*/ string sid1 = DateTime.Now.ToString("MMddHHmmss"); DBAccess.RunSQL("UPDATE Port_Emp SET SID='" + sid1 + "' WHERE No='" + WebUser.No + "'"); WebUser.SID = sid1; } } WebUser.SysLang = lang; if (BP.Sys.SystemConfig.IsBSsystem) { HttpCookie hc = BP.Sys.Glo.Request.Cookies["CCS"]; if (hc != null) { BP.Sys.Glo.Request.Cookies.Remove("CCS"); } HttpCookie cookie = new HttpCookie("CCS"); //设置Cookies有效期 DateTime time = DateTime.Now; cookie.Values.Add("No", em.No); cookie.Values.Add("Name", HttpUtility.UrlEncode(em.Name)); if (isRememberMe) { cookie.Values.Add("IsRememberMe", "1"); } else { cookie.Values.Add("IsRememberMe", "0"); } cookie.Values.Add("FK_Dept", em.FK_Dept); cookie.Values.Add("FK_DeptName", HttpUtility.UrlEncode(em.FK_DeptText)); if (System.Web.HttpContext.Current.Session != null) { cookie.Values.Add("Token", System.Web.HttpContext.Current.Session.SessionID); cookie.Values.Add("SID", System.Web.HttpContext.Current.Session.SessionID); } cookie.Values.Add("Lang", lang); if (authNo == null) { authNo = ""; } cookie.Values.Add("Auth", authNo); //授权人. if (authName == null) { authName = ""; } cookie.Values.Add("AuthName", authName); //授权人名称.. System.Web.HttpContext.Current.Response.AppendCookie(cookie); } }
public ActionResult EditTwoDept(Dept dept) { db.Entry(dept).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); return(RedirectToAction("TwoDept", "Adimin")); }
public DebtHistoryViewModel() { CurrentDept = new Dept(); }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(Dept model) { return(dal.Update(model)); }
private static void CreateTable() { using (var session = NHibernateHelper.OpenSession()) { using (var transaction = session.BeginTransaction()) { var dept = new Dept { DeptId = 1, Name = "IT", Location = "Mumbai" }; var dept1 = new Dept { DeptId = 2, Name = "HR", Location = "Pune" }; var dept2 = new Dept { DeptId = 3, Name = "Sales", Location = "Delhi" }; var emp = new Emp { EmpId = 1, Name = "Rohan", Salary = 12000 }; var emp1 = new Emp { EmpId = 2, Name = "Ashar", Salary = 15000 }; var emp2 = new Emp { EmpId = 3, Name = "Saurabh", Salary = 25000 }; var emp3 = new Emp { EmpId = 4, Name = "Arshdeep", Salary = 14000 }; emp.Dept = dept; emp1.Dept = dept; emp2.Dept = dept1; emp3.Dept = dept2; session.Save(dept); session.Save(dept1); session.Save(dept2); session.Save(emp); session.Save(emp1); session.Save(emp2); session.Save(emp3); transaction.Commit(); } //Console.ReadKey(); } Console.WriteLine("Table created!"); }
private StaffAllResponseModel GenerateStaffAllResponseModel(Staff staffModel, Dept deptModel, int rowId) { var a = staffModel; return(new StaffAllResponseModel { RowId = rowId, StaffId = a.Id, Code = a.Code, DeptId = a.DeptId, DeptName = deptModel.Name, StaffName = a.Name, Sex = a.Sex == 1 ? "男" : "女", Birthday = a.Birth.ToString("yyyy-MM-dd"), InTime = a.InTime.ToString("yyyy-MM-dd"), Telephone = a.Tel, Address = a.Add, State = a.State, StateName = a.State ? "启用" : "未启用", Remark = a.Remark }); }
// moved to device view model async Task GetBackgroundFiles() { if (IsOnline) { HttpClient client = new HttpClient(); var db = DependencyService.Get <IDatabaseConnection>().DbConnection(); // var db = new SQLiteConnection(dbPath); // Download Actions and Save to Local DB IsBusy = true; // db.DeleteAll<Scan>(); db.CreateTable <ActionItem>(); var getactionresponse = await client.GetStringAsync("https://assettrackingwebapi.azurewebsites.net/scan/getactions"); var actions = JsonConvert.DeserializeObject <List <ActionItem> >(getactionresponse); db.DeleteAll <ActionItem>(); foreach (var act in actions) { var newAction = new ActionItem(); newAction.Id = act.Id; newAction.Code = act.Code; newAction.SortCode = act.SortCode; newAction.Description = act.Description; newAction.DeptId = act.DeptId; newAction.ItemRequired = act.ItemRequired; db.Insert(newAction); } ActionItemsList = db.Table <ActionItem>().ToList(); // stationList.Add(new Station() { Id = 1, DeptId = 1, LastScanId = 0, Description = "Dept A", Code = "A" }); // stationList.Add(new Station() { Id = 2, DeptId = 1, LastScanId = 0, Description = "Dept B", Code = "B" }); // stationList.Add(new Station() { Id = 3, DeptId = 2, LastScanId = 0, Description = "Dept C", Code = "C" }); // stationList.Add(new Station() { Id = 4, DeptId = 2, LastScanId = 0, Description = "Dept D", Code = "D" }); db.CreateTable <Station>(); // Download Stations and Save to Local DB var getstationresponse = await client.GetStringAsync("https://assettrackingwebapi.azurewebsites.net/scan/getstations"); var stations = JsonConvert.DeserializeObject <List <Station> >(getstationresponse); db.DeleteAll <Station>(); foreach (var sta in stations) { var newStation = new Station(); newStation.Id = sta.Id; newStation.Code = sta.Code; newStation.DeptId = sta.DeptId; newStation.Description = sta.Description; newStation.LastScanId = sta.LastScanId; db.Insert(newStation); } StationList = db.Table <Station>().ToList(); // Download Operators and Save to Local DB db.CreateTable <Operator>(); var getoperatorresponse = await client.GetStringAsync("https://assettrackingwebapi.azurewebsites.net/scan/getoperators"); var operators = JsonConvert.DeserializeObject <List <Operator> >(getoperatorresponse); db.DeleteAll <Operator>(); foreach (var oper in operators) { var newOperator = new Operator(); newOperator.Id = oper.Id; newOperator.Initials = oper.Initials; newOperator.FirstName = oper.FirstName; newOperator.LastName = oper.LastName; newOperator.PIN = oper.PIN; db.Insert(newOperator); } OperatorList = db.Table <Operator>().ToList(); //// Download Depts and Save to Local DB /// db.CreateTable <Dept>(); var getdeptresponse = await client.GetStringAsync("https://assettrackingwebapi.azurewebsites.net/scan/getdepts"); var depts = JsonConvert.DeserializeObject <List <Dept> >(getdeptresponse); db.DeleteAll <Dept>(); foreach (var dept in depts) { var newDept = new Dept(); newDept.Id = dept.Id; newDept.Code = dept.Code; newDept.PlantId = dept.PlantId; newDept.Description = dept.Description; db.Insert(newDept); } // Download Plants and Save to Local DB db.CreateTable <Plant>(); var getplantresponse = await client.GetStringAsync("https://assettrackingwebapi.azurewebsites.net/scan/getplants"); var plants = JsonConvert.DeserializeObject <List <Plant> >(getplantresponse); db.DeleteAll <Plant>(); foreach (var plant in plants) { var newPlant = new Plant(); newPlant.Id = plant.Id; newPlant.Code = plant.Code; newPlant.CompanyName = plant.CompanyName; newPlant.Address = plant.Address; newPlant.City = plant.City; newPlant.State = plant.State; newPlant.ZipCode = plant.ZipCode; newPlant.Telephone = plant.Telephone; db.Insert(newPlant); } db.Close(); // PlantList = db.Table<Plant>().ToList(); IsBusy = false; } { DisplayMessage = "Working Offline"; } }
public void Add(Dept dept) { deptrepo.Add(dept); }
public ActionResult DirektoratEdit(int id) { Dept dept = db.Depts.Single(p => p.DeptId == id); return(View(dept)); }
private void IsGetChildsDept2(ApplicationContext db, Dept dept, List <Dept> deptsList) { List <Dept> childsDept = db.Depts.Where(x => x.ParentId == dept.Id).ToList(); deptsList.AddRange(childsDept); }
partial void DeleteDept(Dept instance);
private void LoadData() { var empsCol = new List <Emp>(); var deptsCol = new List <Dept>(); #region Load depts var d1 = new Dept { Deptno = 1, Dname = "Research", Loc = "Warsaw" }; var d2 = new Dept { Deptno = 2, Dname = "Human Resources", Loc = "New York" }; var d3 = new Dept { Deptno = 3, Dname = "IT", Loc = "Los Angeles" }; deptsCol.Add(d1); deptsCol.Add(d2); deptsCol.Add(d3); Depts = deptsCol; #endregion #region Load emps var e1 = new Emp { Deptno = 1, Empno = 1, Ename = "Jan Kowalski", HireDate = DateTime.Now.AddMonths(-5), Job = "Backend programmer", Mgr = null, Salary = 2000 }; var e2 = new Emp { Deptno = 1, Empno = 20, Ename = "Anna Malewska", HireDate = DateTime.Now.AddMonths(-7), Job = "Frontend programmer", Mgr = e1, Salary = 4000 }; var e3 = new Emp { Deptno = 1, Empno = 2, Ename = "Marcin Korewski", HireDate = DateTime.Now.AddMonths(-3), Job = "Frontend programmer", Mgr = null, Salary = 5000 }; var e4 = new Emp { Deptno = 2, Empno = 3, Ename = "Paweł Latowski", HireDate = DateTime.Now.AddMonths(-2), Job = "Frontend programmer", Mgr = e2, Salary = 5500 }; var e5 = new Emp { Deptno = 2, Empno = 4, Ename = "Michał Kowalski", HireDate = DateTime.Now.AddMonths(-2), Job = "Backend programmer", Mgr = e2, Salary = 5500 }; var e6 = new Emp { Deptno = 2, Empno = 5, Ename = "Katarzyna Malewska", HireDate = DateTime.Now.AddMonths(-3), Job = "Manager", Mgr = null, Salary = 8000 }; var e7 = new Emp { Deptno = null, Empno = 6, Ename = "Andrzej Kwiatkowski", HireDate = DateTime.Now.AddMonths(-3), Job = "System administrator", Mgr = null, Salary = 7500 }; var e8 = new Emp { Deptno = 2, Empno = 7, Ename = "Marcin Polewski", HireDate = DateTime.Now.AddMonths(-3), Job = "Mobile developer", Mgr = null, Salary = 4000 }; var e9 = new Emp { Deptno = 2, Empno = 8, Ename = "Władysław Torzewski", HireDate = DateTime.Now.AddMonths(-9), Job = "CTO", Mgr = null, Salary = 12000 }; var e10 = new Emp { Deptno = 2, Empno = 9, Ename = "Andrzej Dalewski", HireDate = DateTime.Now.AddMonths(-4), Job = "Database administrator", Mgr = null, Salary = 9000 }; empsCol.Add(e1); empsCol.Add(e2); empsCol.Add(e3); empsCol.Add(e4); empsCol.Add(e5); empsCol.Add(e6); empsCol.Add(e7); empsCol.Add(e8); empsCol.Add(e9); empsCol.Add(e10); Emps = empsCol; ResultsDataGridView.DataSource = Emps; #endregion }
partial void UpdateDept(Dept instance);
public ServiceResponseData UserLogin() { string usercode = requestData.GetData <string>(0); string password = requestData.GetData <string>(1); User user = NewObject <User>(); bool islogin = user.UserLogin(usercode, password); if (islogin) { BaseUser ebaseUser = user.GetUser(usercode); SysLoginRight right = new SysLoginRight(); right.UserId = ebaseUser.UserId; right.EmpId = ebaseUser.EmpId; right.WorkId = ebaseUser.WorkId; right.IsAdmin = ebaseUser.IsAdmin; Dept dept = NewObject <Dept>(); BaseDept ebaseDept = dept.GetDefaultDept(ebaseUser.EmpId); if (ebaseDept != null) { right.DeptId = ebaseDept.DeptId; right.DeptName = ebaseDept.Name; } BaseEmployee ebaseEmp = (BaseEmployee)NewObject <BaseEmployee>().getmodel(ebaseUser.EmpId); right.EmpName = ebaseEmp.Name; BaseWorkers ebaseWork = (BaseWorkers)NewObject <BaseWorkers>().getmodel(ebaseUser.WorkId); right.WorkName = ebaseWork.WorkName; if (ebaseWork.DelFlag == 0) { string regkey = ebaseWork.RegKey; DESEncryptor des = new DESEncryptor(); des.InputString = regkey; des.DesDecrypt(); string[] ret = (des.OutString == null ? "" : des.OutString).Split(new char[] { '|' }); if (ret.Length == 2 && ret[0] == ebaseWork.WorkName && Convert.ToDateTime(ret[1]) > DateTime.Now) { //ClientInfo.LoginRight = right;//缓存登录用户信息 //单点登录注册 Guid token = Guid.Empty; SsoHelper.SignIn(usercode, new UserInfo() { UserId = usercode, EmpId = right.EmpId, UserName = right.EmpName, DeptId = right.DeptId, DeptName = right.DeptName, WorkId = right.WorkId, WorkName = right.WorkName, IsAdmin = right.IsAdmin }, out token); right.token = token; responseData.AddData(right.EmpName); responseData.AddData(right.DeptName); responseData.AddData(right.WorkName); responseData.AddData(NewObject <Module>().GetModuleList(right.UserId).OrderBy(x => x.SortId).ToList()); responseData.AddData(NewObject <Menu>().GetMenuList(right.UserId)); responseData.AddData(NewObject <Dept>().GetHaveDept(right.EmpId)); responseData.AddData(right); return(responseData); } else { throw new Exception("登录用户的当前机构注册码不正确!"); } } else { throw new Exception("登录用户的当前机构还未启用!"); } } else { throw new Exception("输入的用户名密码不正确!"); } }
public JsonResult Edit(Dept model) { var result = bll.Edit(model); return(Json(result)); }
public ActionResult DeptDelete(int id) { Dept dept = db.Depts.Single(p => p.DeptId == id); return(View(dept)); }
public static Dept CreateDept(int ID) { Dept dept = new Dept(); dept.Id = ID; return dept; }
public JsonResult Add([FromBody] Dept model) { var result = bll.Add(model); return(Json(result)); }
partial void InsertDept(Dept instance);