| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526 |
- using BizCom;
- using SQLData;
- using System;
- using System.Collections.Generic;
- using System.Data;
- using System.Text;
- using Utils;
- namespace SiteCore.Handler
- {
- public partial class sync
- {
- #region 职位
- public void get_postsetting()
- {
- if (UrlParmsCheck("pId"))
- {
- int pId = GetInt("pId");
- DataTable dt = CeErpPost.SimpleQuery(0, "ID,DefaultPageModuleID as pmId,IndexPageReport as ipp", "", "ID=" + pId);
- returnSuccess(Utils.Serialization.JsonString.DataTable2AjaxJson(dt));
- }
- }
- public void save_postsetting()
- {
- if (UrlParmsCheck("pId,mId,index"))
- {
- int pId = GetInt("pId");
- int mId = GetInt("mId");
- int index = GetInt("index");
- string noshow = GetString("noshow");
- string[] sArr = noshow.Split(',');
- //using (new SessionScope())
- //{
- CeErpPost post = CeErpPost.Get(pId);
- if (post != null)
- {
- post.DefaultPageModuleID = mId;
- post.IndexPageReport = index;
- post.Update();
- }
- StringBuilder sql = new StringBuilder();
- sql.AppendFormat("delete from CE_ErpPostToIndexPage where postid={0} ;", pId);
- if (noshow != "" && sArr.Length > 0)
- {
- for (int i = 0; i < sArr.Length; i++)
- {
- sql.AppendFormat("insert into CE_ErpPostToIndexPage(postid,indexid) values({0},{1});", pId, sArr[i]);
- }
- }
- CeErpPost.ExecuteNonQuery(sql.ToString());
- //}
- returnSuccessMsg("保存配置成功!");
- }
- }
- public void get_post()
- {
- DataStruct dStruct = GetPostStruct();
- string path = GetPostString("path");
- int oId = GetPostInt("oId");
- if (path == "") dStruct.MainWhere = "OrgID=" + oId;
- else dStruct.MainWhere = "OrgID=" + oId + " or Path like '%|" + oId + "|%'";
- dStruct.Order = "path asc,sort asc";
- DataTable dt = WebCache.GetData("view_erppost", dStruct);
- writeGridDataTableJson(dStruct.TotalCount, dt);
- }
- public void save_post()
- {
- if (UrlParmsCheck("oId,name,sort,mId"))
- {
- int postId = GetInt("postId");
- int oId = GetInt("oId");
- string name = GetString("name");
- int sort = GetInt("sort");
- string code = GetString("code");
- int OrderAmountLimit = GetInt("OrderAmountLimit");
- int OrderDesignLimit = GetInt("OrderDesignLimit");
- int DayOrderLimit = GetInt("DayOrderLimit");
- int mId = GetInt("mId");
- CeErpPost post = null;
- if (postId > 0) post = CeErpPost.Get(postId);
- else post = new CeErpPost();
- post.Name = name;
- post.Code = code;
- post.OrderAmountLimit = OrderAmountLimit;
- post.OrderDesignLimit = OrderDesignLimit;
- post.DayOrderLimit = DayOrderLimit;
- post.Sort = sort;
- post.OrgID = oId;
- post.DefaultPageModuleID = mId;
- if (postId > 0) post.Update();
- else post.Create();
- returnSuccessMsg("保存成功!");
- }
- }
- public void del_post()
- {
- if (UrlParmsCheck("id,oId"))
- {
- int id = GetInt("id");
- int oId = GetInt("oId");
- string sql = "select count(0) from view_erpuser where postid=" + id;
- object res = CeErpOrganization.ExecuteScalar(sql);
- if (res != null && Convert.ToInt32(res) > 0)
- {
- returnErrorMsg("该职位已存在人员不允许删除!");
- return;
- }
- int result = CeErpPost.Del(id, oId);
- if (result > 0)
- {
- returnSuccessMsg("删除成功!");
- }
- else
- {
- returnSuccessMsg("删除失败!");
- }
- }
- }
- #endregion
- #region 员工
- public void get_employee()
- {
- DataStruct dStruct = GetPostStruct();
- string path = GetPostString("path");
- int oId = GetPostInt("oId");
- List<string> lw = new List<string>();
- if (oId > 0)
- {
- lw.Add("(OrgID=" + oId + " or Path like '%|" + oId + "|%')");
- //dStruct.MainWhere = "(OrgID=" + oId+" or Path like '%|"+oId+"|%')";
- //if (path == "") dStruct.MainWhere = "OrgID=" + oId;
- //else dStruct.MainWhere = "Path like '%|" + oId + "|%'";
- }
- string key = GetPostString("key");
- if (key != "")
- {
- lw.Add(string.Format(" (name like '%{0}%' or Account like '%{0}%' or (CHARINDEX( ','+convert(varchar,(select id from CE_ErpShop where Summary like '%{0}%'))+',' , ','+pemShop+',')>0 ))", key));
- //dStruct.SecondWhere = string.Format(" (PostName like '%{0}%' or name like '%{0}%' or Account like '%{0}%' )", key);
- }
- string orgIds = CurrentUser.User.ManageOrgIds;
- if (!string.IsNullOrEmpty(orgIds))
- {
- lw.Add(string.Format("OrgID in ({0})", orgIds));
- }
- else
- {
- lw.Add(string.Format("(OrgID =0)", orgIds));
- }
- if (lw.Count > 0)
- {
- dStruct.MainWhere = string.Join(" and ", lw.ToArray());
- }
- dStruct.Order = "isopen desc, createtime desc";
- DataTable dt = WebCache.GetData("view_erpuser", dStruct);
- foreach (DataRow dr in dt.Rows)
- {
- if (dr["password"].ToString() == "") continue;
- dr["password"] = SecurityHelper.DecryptSymmetric(dr["password"].ToString());
- }
- writeGridDataTableJson(dStruct.TotalCount, dt);
- }
- public void open_employee()
- {
- if (UrlParmsCheck("pid"))
- {
- int pId = GetInt("pId");
- CeErpUser.OpenAccount(pId, SecurityHelper.EncryptSymmetric("123456"));
- returnSuccessMsg("成功开通账户!");
- }
- }
- public void close_employee()
- {
- if (UrlParmsCheck("pid"))
- {
- int pId = GetInt("pId");
- int userId = GetInt("userId");
- CeErpUser ceErpUser = CeErpUser.Get(userId);
- if (ceErpUser == null || !ceErpUser.isOpen)
- {
- returnSuccessMsg("接收账号已关闭,无法转派!");
- return;
- }
- CeErpUser.FreezeAccount(pId);
- //设计师
- DbHelper.DbConn.ExecuteNonQuery(string.Format("update CE_ErpTradeCell set DesignUserId = {0} WHERE DesignUserId = {1} and OrderState > 0 and OrderState < 7", userId, pId));
- //客服
- DbHelper.DbConn.ExecuteNonQuery(string.Format("update CE_ErpTradeCell set CustomerUserId = {0} WHERE CustomerUserId = {1} and OrderState > 0 and OrderState < 7", userId, pId));
- //下单员
- DbHelper.DbConn.ExecuteNonQuery(string.Format("update CE_ErpTradeCell set PlaceUserId = {0} WHERE PlaceUserId = {1} and OrderState > 0 and OrderState < 7", userId, pId));
- //售后
- DbHelper.DbConn.ExecuteNonQuery(string.Format("update CE_ErpTradeCell set AfterSaleUserId = {0} WHERE AfterSaleUserId = {1} and AfterSaleState <> 4", userId, pId));
- returnSuccessMsg("成功关闭账户!");
- }
- }
- public void del_employee()
- {
- if (UrlParmsCheck("pid"))
- {
- string curPos = CurrentUser.UserPost.Post.Code;
- if (CurrentUser.User.State != 5) //超级管理员才能删除账号
- {
- returnSuccessMsg("您没有权限删除账号!");
- return;
- }
- int id = GetInt("pid");
- string code = GetString("code");
- int result = CeErpUser.RealDel(id);
- if (result > 0)
- {
- returnSuccessMsg("删除成功!");
- }
- else
- {
- returnSuccessMsg("删除失败!");
- }
- }
- }
- public void update_employee_pwd()
- {
- if (UrlParmsCheck("eid,pwd"))
- {
- int eid = GetInt("eid");
- string pwd = GetString("pwd");
- CeErpUser entity = CeErpUser.Get(eid);
- if (entity != null)
- {
- entity.PassWord = SecurityHelper.EncryptSymmetric(pwd);
- entity.Update();
- }
- returnSuccessMsg("修改成功!");
- }
- }
- public void update_employee_pwd2()
- {
- string tbxOldPwd = GetString("tbxOldPwd");
- string tbxNewPwd = GetString("tbxNewPwd");
- if (string.IsNullOrEmpty(tbxOldPwd) || string.IsNullOrEmpty(tbxNewPwd))
- {
- returnErrorMsg("参数有误");
- return;
- }
- int eid = CurrentUser.UserID;
- if (eid <= 0)
- {
- returnErrorMsg("未找到用户");
- return;
- }
- CeErpUser entity = CeErpUser.Get(eid);
- if (entity == null)
- {
- returnErrorMsg("未找到用户");
- return;
- }
- if (entity.PassWord != SecurityHelper.EncryptSymmetric(tbxOldPwd))
- {
- returnErrorMsg("原密码不正确");
- return;
- }
- entity.PassWord = SecurityHelper.EncryptSymmetric(tbxNewPwd);
- entity.Update();
- con.Session["isSimplePwd"] = null;
- returnSuccessMsg("修改成功!");
- }
- public void upd_user_onduty()
- {
- string uid = GetString("uid");
- if (uid.Length > 0)
- {
- //员工信息里面点上班
- int eUid = Convert.ToInt32(uid);
- string sql = "";
- sql = "update view_ErpUser set OnDuty=1 where id=" + eUid;
- DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
- CeErpUser entity = CeErpUser.Get(eUid);
- if (entity != null)
- {
- entity.OnDutyTime = DateTime.Now;
- entity.Update();
- }
- returnSuccessMsg("修改成功!");
- return;
- }
- else
- {
- //自己点上班
- string dutyStr = GetPostString("duty");
- CeErpUser entity = CeErpUser.Get(CurrentUser.UserID);
- if (entity != null)
- {
- int eUid = CurrentUser.UserID;
- string sql = "";
- if (dutyStr == "值班")
- {
- sql = "update view_ErpUser set OnDuty=1,BeOnDuty=1 where id=" + eUid;
- }
- else if (dutyStr == "晚班")
- {
- sql = "update view_ErpUser set OnDuty=1,BeOnDuty=2 where id=" + eUid;
- }
- else
- {
- sql = "update view_ErpUser set OnDuty=1 where id=" + eUid;
- }
- DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
- entity.OnDutyTime = DateTime.Now;
- entity.Update();
- returnSuccessMsg("修改成功!");
- return;
- }
- }
- returnErrorMsg("未找到用户");
- }
- public void upd_user_offduty()
- {
- string poscode = CurrentUser.UserPost.Post.Code;
- int orgID = CurrentUser.UserPost.OrgID;
- //string posname = CurrentUser.UserPost.Post.Name;
- //if (poscode != "SysAdmin")
- //{
- // returnErrorMsg("暂无下班权限");
- // return;
- //}
- string uid = GetString("uid");
- if (uid.Length > 0)
- {
- int eUid = Convert.ToInt32(uid);
- if (poscode != "SysAdmin" && poscode != "PlaceMr" && poscode != "Designerhd" && poscode != "DesignerMr" && poscode != "wxDesignerMr")
- {
- //31世纪天成 82商务板块
- if ((orgID == 31 || orgID == 82) && poscode == "Director")
- {
- //跳过
- }
- else
- {
- //p0设计师可以下班
- string ssql = "select * from view_ErpUser where PostName='设计师P0' and ID=" + eUid;
- DataTable dt = DbHelper.DbConn.ExecuteDataset(ssql.ToString()).Tables[0];
- if (dt.Rows.Count <= 0)
- {
- returnErrorMsg("暂无权限");
- return;
- }
- }
- }
- CeErpUser entity = CeErpUser.Get(eUid);
- string sql = "update view_ErpUser set OnDuty=0,BeOnDuty=0 where id=" + eUid;
- DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
- if (entity != null)
- {
- entity.OffDutyTime = DateTime.Now;
- entity.Update();
- }
- returnSuccessMsg("下班成功!");
- return;
- }
- else
- {
- CeErpUser entity = CeErpUser.Get(CurrentUser.UserID);
- if (entity != null)
- {
- int eUid = CurrentUser.UserID;
- string sql = "update view_ErpUser set OnDuty=0,BeOnDuty=0 where id=" + eUid;
- DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
- entity.OffDutyTime = DateTime.Now;
- entity.Update();
- returnSuccessMsg("下班成功!");
- return;
- }
- }
- returnErrorMsg("未找到用户");
- }
- public void upd_user_multilogin()
- {
- string uid = GetString("uid");
- CeErpUser entity = CeErpUser.Get(CurrentUser.UserID);
- if (entity != null)
- {
- int eUid = CurrentUser.UserID;
- if (uid.Length > 0)
- {
- eUid = Convert.ToInt32(uid);
- }
- string sql = "";
- sql = "update view_ErpUser set IsMultiLogin=1 where id=" + eUid;
- DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
- returnSuccessMsg("修改成功!");
- return;
- }
- returnErrorMsg("未找到用户");
- }
- public void upd_user_onelogin()
- {
- string uid = GetString("uid");
- CeErpUser entity = CeErpUser.Get(CurrentUser.UserID);
- if (entity != null)
- {
- int eUid = CurrentUser.UserID;
- if (uid.Length > 0)
- {
- eUid = Convert.ToInt32(uid);
- }
- string sql = "update view_ErpUser set IsMultiLogin=0 where id=" + eUid;
- DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
- returnSuccessMsg("操作成功!");
- return;
- }
- returnErrorMsg("未找到用户");
- }
- public void set_user_team()
- {
- string uids = GetPostString("ids");
- string names = GetPostString("names");
- StringBuilder sql = new StringBuilder();
- sql.AppendFormat("update ce_ErpUser set TeamIds='{0}',TeamNames='{1}' where id in ({0})", uids, names);
- DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
- returnSuccessMsg("设置成功!");
- return;
- }
- #endregion
- #region 账户
- public void get_account()
- {
- DataStruct dStruct = GetPostStruct();
- dStruct.MainWhere = "PersonID=0";
- DataTable dt = WebCache.GetData("ce_ErpUser", dStruct);
- writeGridDataTableJson(dStruct.TotalCount, dt);
- }
- public void save_account()
- {
- if (UrlParmsCheck("name,pwd"))
- {
- string name = GetString("name");
- if (CeErpUser.Exists(" Account=?", name))
- {
- returnErrorMsg("该账户名已经存在,请更换!");
- return;
- }
- string pwd = SecurityHelper.EncryptSymmetric(GetString("pwd"));
- CeErpUser user = new CeErpUser();
- user.Account = name;
- user.CreateTime = DateTime.Now;
- user.PassWord = pwd;
- user.Create();
- returnSuccessMsg("保存成功!");
- }
- }
- public void resetpwd_account()
- {
- int id = GetInt("id");
- int pId = GetInt("pid");
- if (id > 0) CeErpUser.ResetPwd(id, SecurityHelper.EncryptSymmetric("123456"));
- else if (pId > 0) CeErpUser.ResetPersonPwd(pId, SecurityHelper.EncryptSymmetric("123456"));
- returnSuccessMsg("密码重置成功!");
- }
- public void del_account()
- {
- if (UrlParmsCheck("id"))
- {
- int id = GetInt("id");
- CeErpUser.RealDel(id);
- returnSuccessMsg("删除成功!");
- }
- }
- public void open_account()
- {
- if (UrlParmsCheck("id,pid"))
- {
- int pId = GetInt("pid");
- int id = GetInt("id");
- CeErpUser.OpenAccount(id, SecurityHelper.EncryptSymmetric("123456"));
- returnSuccessMsg("成功开通账户!");
- }
- }
- public void close_account()
- {
- if (UrlParmsCheck("id,pid"))
- {
- int id = GetInt("id");
- CeErpUser.FreezeAccount(id);
- returnSuccessMsg("成功冻结账户!");
- }
- }
- #endregion
- }
- }
|