/// <summary> /// 增加一条数据 /// </summary> public bool Add(EmployeeProportion model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into employeeproportion("); strSql.Append("ID,EMPLOYEEID,PROPORTION,PARENTEMPLOYEEID,ISBRANCHLEADER)"); strSql.Append(" values ("); strSql.Append("@ID,@EMPLOYEEID,@PROPORTION,@PARENTEMPLOYEEID,@ISBRANCHLEADER)"); MySqlParameter[] parameters = { new MySqlParameter("@ID", MySqlDbType.VarChar, 36), new MySqlParameter("@EMPLOYEEID", MySqlDbType.VarChar, 36), new MySqlParameter("@PROPORTION", MySqlDbType.Decimal, 3), new MySqlParameter("@PARENTEMPLOYEEID", MySqlDbType.VarChar, 36), new MySqlParameter("@ISBRANCHLEADER", MySqlDbType.Bit) }; parameters[0].Value = model.ID; parameters[1].Value = model.EMPLOYEEID; parameters[2].Value = model.PROPORTION; parameters[3].Value = model.PARENTEMPLOYEEID; parameters[4].Value = model.ISBRANCHLEADER; int rows = DbHelperMySQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(EmployeeProportion model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update employeeproportion set "); strSql.Append("EMPLOYEEID=@EMPLOYEEID,"); strSql.Append("PROPORTION=@PROPORTION,"); strSql.Append("PARENTEMPLOYEEID=@PARENTEMPLOYEEID,"); strSql.Append("ISBRANCHLEADER=@ISBRANCHLEADER"); strSql.Append(" where ID=@ID "); MySqlParameter[] parameters = { new MySqlParameter("@EMPLOYEEID", MySqlDbType.VarChar, 36), new MySqlParameter("@PROPORTION", MySqlDbType.Decimal, 3), new MySqlParameter("@PARENTEMPLOYEEID", MySqlDbType.VarChar, 36), new MySqlParameter("@ISBRANCHLEADER", MySqlDbType.Bit), new MySqlParameter("@ID", MySqlDbType.VarChar, 36) }; parameters[0].Value = model.EMPLOYEEID; parameters[1].Value = model.PROPORTION; parameters[2].Value = model.PARENTEMPLOYEEID; parameters[3].Value = model.ISBRANCHLEADER; parameters[4].Value = model.ID; int rows = DbHelperMySQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
protected void gvEmployeeProportion_RowUpdating(object sender, GridViewUpdateEventArgs e) { string employeeID = gvEmployeeProportion.DataKeys[e.RowIndex].Value.ToString(); TextBox txtProportion = gvEmployeeProportion.Rows[e.RowIndex].FindControl("txtProportion") as TextBox; string strProportion = txtProportion.Text.Trim(); decimal dProportion = !string.IsNullOrEmpty(strProportion) ? Convert.ToDecimal(strProportion) : 0m; DropDownList ddlManager = gvEmployeeProportion.Rows[e.RowIndex].FindControl("ddlManager") as DropDownList; string parentEmployeeID = ddlManager.SelectedValue; DataTable dtEmpProportion = epBll.GetList(" AND employeeID = '" + employeeID + "'").Tables[0]; if (dtEmpProportion != null && dtEmpProportion.Rows.Count > 0) { EmployeeProportion empProportion = new EmployeeProportion(); empProportion.ID = dtEmpProportion.AsEnumerable().FirstOrDefault()["ID"].ToString(); empProportion.EMPLOYEEID = employeeID; empProportion.PROPORTION = dProportion; empProportion.PARENTEMPLOYEEID = parentEmployeeID == string.Empty ? null : parentEmployeeID; //empProportion.ISBRANCHLEADER = string.IsNullOrEmpty(parentEmployeeID); epBll.Update(empProportion); } else { EmployeeProportion empProportion = new EmployeeProportion(); empProportion.ID = Guid.NewGuid().ToString(); empProportion.EMPLOYEEID = employeeID; empProportion.PROPORTION = dProportion; empProportion.PARENTEMPLOYEEID = parentEmployeeID == string.Empty ? null : parentEmployeeID; //empProportion.ISBRANCHLEADER = string.IsNullOrEmpty(parentEmployeeID); epBll.Add(empProportion); } gvEmployeeProportion.EditIndex = -1; dtAllEmployeeProportion = epBll.GetList(string.Empty).Tables[0]; LoadDefaultProportion(); }
/// <summary> /// 得到一个对象实体 /// </summary> public EmployeeProportion DataRowToModel(DataRow row) { EmployeeProportion model = new EmployeeProportion(); if (row != null) { if (row["ID"] != null) { model.ID = row["ID"].ToString(); } if (row["EMPLOYEEID"] != null) { model.EMPLOYEEID = row["EMPLOYEEID"].ToString(); } if (row["PROPORTION"] != null && row["PROPORTION"].ToString() != "") { model.PROPORTION = decimal.Parse(row["PROPORTION"].ToString()); } if (row["PARENTEMPLOYEEID"] != null) { model.PARENTEMPLOYEEID = row["PARENTEMPLOYEEID"].ToString(); } if (row["ISBRANCHLEADER"] != null && row["ISBRANCHLEADER"].ToString() != "") { if ((row["ISBRANCHLEADER"].ToString() == "1") || (row["ISBRANCHLEADER"].ToString().ToLower() == "true")) { model.ISBRANCHLEADER = true; } else { model.ISBRANCHLEADER = false; } } } return(model); }
/// <summary> /// 得到一个对象实体 /// </summary> public EmployeeProportion GetModel(string ID) { StringBuilder strSql = new StringBuilder(); strSql.Append("select ID,EMPLOYEEID,PROPORTION,PARENTEMPLOYEEID,ISBRANCHLEADER from employeeproportion "); strSql.Append(" where ID=@ID "); MySqlParameter[] parameters = { new MySqlParameter("@ID", MySqlDbType.VarChar, 36) }; parameters[0].Value = ID; EmployeeProportion model = new EmployeeProportion(); DataSet ds = DbHelperMySQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { string prjID = Request.QueryString["prjID"].ToString(); decimal amount = Convert.ToDecimal(Request.QueryString["amount"]); string parentEmployeeID = Convert.ToString(Request.QueryString["parentEmployeeID"]); string where = " AND employeeId = '" + parentEmployeeID + "'"; decimal proportion = 0m; ProjectProportion projectProportion = new ProjectProportionBLL().GetModelList(" projectId = '" + prjID + "'").FirstOrDefault(); if (projectProportion != null) { proportion = projectProportion.PROPORTION ?? 0m; } else { EmployeeProportion empPro = epBll.GetModelList(where).FirstOrDefault(); proportion = empPro?.PROPORTION ?? 0m; } hidAmount.Value = lblAmount.Text = (amount * proportion).ToString(); LoadCanTransferEmp(); } }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(EmployeeProportion model) { return(dal.Update(model)); }
/// <summary> /// 增加一条数据 /// </summary> public bool Add(EmployeeProportion model) { return(dal.Add(model)); }
/// <summary> /// 添加员工 /// </summary> private void AddEmployee() { string employeeNO = txtEmployeeNo.Text.Trim(); //员工编号 try { //判断编号是否已经使用 bool isExist = eBll.IsExist(employeeNO); if (isExist) { ExecuteScript("AlertDialog('员工编号已存在!', null);"); return; } string name = txtName.Text.Trim(); //员工姓名 int gender = 0; //员工性别 if (rdbFemale.Checked) { gender = 1; } //出生日期 string birthdate = txtBirthDate.Text.Trim(); Employee emp = new Employee(); emp.ID = Guid.NewGuid().ToString(); emp.EMPLOYEENO = employeeNO; //密码加密 emp.PASSWORD = AES.Encrypt("666666", "0512000000000512"); //姓名 emp.NAME = name == null ? null : name; //性别 emp.SEX = gender == 0; if (!string.IsNullOrEmpty(birthdate)) { emp.BIRTHDATE = Convert.ToDateTime(birthdate); } //手机号码 emp.MOBILEPHONE = txtMobilePhone.Text.Trim(); //转正日期 emp.TOREGULARDATE = Convert.ToDateTime(txtToRegularDate.Text.Trim()); //员工类型,0:总经办,1:客服,2:造价员 decimal userType = 0; //总经办 if (rdbGMO.Checked) { userType = 0; } //客服 else if (rdbCustomerService.Checked) { userType = 1; } //造价员 else if (rdbEmployee.Checked) { userType = 2; } // 其他用户类型 else if (rdbOtherUserType.Checked) { if (!string.IsNullOrEmpty(txtUserType.Text.Trim())) { userType = Convert.ToDecimal(txtUserType.Text.Trim()); } } emp.TYPE = userType; emp.ISBRANCHLEADER = rblIsBranchLeader.SelectedValue == "1"; emp.ISEXTERNAL = rblIsExternal.SelectedValue == "1"; //启用状态 emp.AVAILABLE = 1; bool flag = eBll.Add(emp); //本系统添加成功 if (flag) { if (rblAddRole.SelectedValue == "1") { // 添加角色 EmployeeRole empRole = new EmployeeRole(); empRole.ID = Guid.NewGuid().ToString(); empRole.EMPLOYEEID = emp.ID; // 1 客服 if (emp.TYPE == 1) { empRole.ROLEID = "fea3a06f-6d97-45d3-93f7-b145c158eb27"; } // 2 工程师 else if (emp.TYPE == 2) { empRole.ROLEID = "2B43010866666af2b73d78c35288d565"; } if (!string.IsNullOrEmpty(empRole.ROLEID)) { new EmployeeRoleBLL().Add(empRole); } } // 创建员工编号同名目录 string rootPath = Convert.ToString(ConfigurationManager.AppSettings["employeePath"]); string employeeFolder = Path.Combine(rootPath, emp.EMPLOYEENO); if (!Directory.Exists(employeeFolder)) { Directory.CreateDirectory(employeeFolder); } // 2018-05-19 添加 // 添加员工的任务分成配置 EmployeeProportionBLL epBll = new EmployeeProportionBLL(); EmployeeProportion empProportion = new EmployeeProportion(); empProportion.ID = Guid.NewGuid().ToString(); empProportion.EMPLOYEEID = emp.ID; empProportion.PROPORTION = 0.3m; empProportion.PARENTEMPLOYEEID = null; empProportion.ISBRANCHLEADER = emp.ISBRANCHLEADER; epBll.Add(empProportion); // 任务分成配置结束 // 2018-05-20 添加 // 添加员工的默认账户 EmployeeAccount empAcct = new EmployeeAccount(); empAcct.ID = Guid.NewGuid().ToString(); empAcct.EMPLOYEEID = emp.ID; empAcct.AMOUNT = 0m; empAcct.PAIDAMOUNT = 0m; empAcct.SURPLUSAMOUNT = 0m; empAcct.OTHERSAMOUNT = 0m; empAcct.CREATEDATE = DateTime.Now; empAcct.LASTUPDATEDATE = DateTime.Now; EmployeeAccountBLL empAcctBll = new EmployeeAccountBLL(); empAcctBll.Add(empAcct); // 员工账户结束 #region 调用钉钉接口,添加员工到钉钉 //如果选择了钉钉同步创建 if (Request.Form["sync"] == "rdbSync") { string accessTokenResult = DingTalkHelper.GetAccessToken(); JObject jObj = JObject.Parse(accessTokenResult); string errcode = jObj["errcode"].ToString(); string accessToken = string.Empty; if (errcode == "0") { accessToken = jObj["access_token"].ToString(); string postUrl = string.Format("https://oapi.dingtalk.com/user/create?access_token={0}", accessToken); //岗位 string position = string.Empty; //钉钉系统中对应的部门ID string departmentid = string.Empty; ////总经办 //if (rdbGMO.Checked) //{ // position = rdbGMO.Text; // departmentid = "37037510"; //} ////客服 //else if (rdbCustomerService.Checked) //{ // position = rdbCustomerService.Text; // departmentid = "36958636"; //} ////造价员 //else if (rdbEmployee.Checked) //{ // position = rdbEmployee.Text; // departmentid = "36961466"; //} departmentid = "110817907"; //\"orderInDepts\":\"{1:10}\", \"remark\":\"\", \"tel\":\"010-12333\", \"workPlace\":\"\", \"isHide\":false, \"isSenior\":false string param = "{\"name\":\"" + emp.NAME + "\", \"department\":[" + departmentid + "], \"position\":\"" + position + "\", \"mobile\":\"" + emp.MOBILEPHONE + "\", \"email\":\"" + emp.EMAIL + "\", \"jobnumber\":\"" + emp.EMPLOYEENO + "\",}"; object userCreateResult = WebServiceHelper.Post(postUrl, param); JObject jCreateResult = JObject.Parse(userCreateResult.ToString()); //返回码 errcode = jCreateResult["errcode"].ToString(); //返回消息 string errmsg = jCreateResult["errmsg"].ToString(); //返回码为0,成功 if (errcode == "0") { string dingTalkUserId = jCreateResult["userid"].ToString(); emp.DINGTALKUSERID = dingTalkUserId; try { //关联钉钉UserId bool uptFlag = eBll.Update(emp); //关联成功 if (uptFlag) { //弹出提示并刷新当前页面 ExecuteScript("alert('添加成功!');window.location.href='/Pages/Admin/EmployeeAdd?UserId=" + emp.ID + "'"); } else { ExecuteScript("AlertDialog('关联钉钉UserId失败!', null);"); } } //本地OA更新钉钉UserId失败 catch (Exception ex) { LogHelper.WriteLine("自动关联钉钉UserId失败。" + ex.Message + ex.StackTrace); ExecuteScript("AlertDialog('操作失败!', null)"); } } else { LogHelper.WriteLine("用户在OA系统创建成功,但在钉钉系统创建失败,原因:" + errmsg); //ExecuteScript("AlertDialog('OA系统已成功创建用户,但该用户在钉钉系统中创建失败,请人工在钉钉系统中添加。<br />钉钉系统中添加成功后,需要将其系统中的UserId填写并关联到本系统中。', null)"); ExecuteScript("alert('OA系统已成功创建用户,但该用户在钉钉系统中创建失败,请人工在钉钉系统中添加。钉钉系统中添加成功后,需要将其系统中的UserId填写并关联到本系统中。');window.location.href='EmployeeAdd?UserId=" + emp.ID + "';"); } } else { ExecuteScript("AlertDialog('用户已在本系统中成功创建,但获取钉钉token失败,并未在钉钉系统中成功添加用户,请人工添加!', null)"); } } else { ExecuteScript("alert('本系统添加成功但尚未关联钉钉UserId,请尽快关联!');window.location.href='/Pages/Admin/EmployeeAdd?UserId=" + emp.ID + "';"); } #endregion } //添加失败 else { ExecuteScript("AlertDialog('添加失败!', null)"); } } catch (Exception ex) { string exMsg = ex.Message; LogHelper.WriteLine(string.Format("员工添加出错。" + exMsg + ex.StackTrace)); //写入文本日志 string script = string.Format("AlertDialog('服务器错误,请联系管理员!<p>{0}</p>'), null", exMsg); ExecuteScript(script); } }