protected void gvList_RowDeleting(object sender, GridViewDeleteEventArgs e) { if (this.gvList.DataKeys[e.RowIndex].Value.ToString() != "1") { this.userSer.deleteUserByUserId(Convert.ToInt32(this.gvList.DataKeys[e.RowIndex].Value.ToString())); DBHelp.ExeCommand(string.Format("DELETE from A_Role_User where A_RoleId IN (28,32) AND User_Id ={0};", this.gvList.DataKeys[e.RowIndex].Value.ToString())); Show(); } else { base.ClientScript.RegisterStartupScript(base.GetType(), null, "<script>alert('管理员不能被删除!');</script>"); } }
private void LastUpdate(int id) { CAI_OrderInHousesService ordersSer = new CAI_OrderInHousesService(); List <CAI_OrderInHouses> orders = ordersSer.GetListArray(" 1=1 and CAI_OrderInHouses.id=1"); CAI_OrderChecksService ordersSer111 = new CAI_OrderChecksService(); List <CAI_OrderChecks> orders1111 = ordersSer111.GetListArray(" 1=1 and CAI_OrderChecks.CheckId=" + id); CAI_OrderCheckService mainSer = new CAI_OrderCheckService(); CAI_OrderCheck pp = mainSer.GetModel(id); DBHelp.ExeCommand(string.Format(@" update CAI_OrderInHouse SET ChcEkProNo='{0}',pono='{1}',poname='{2}' where id=1; update CAI_OrderOutHouse set pono='{1}',poname='{2}' where ChcEkProNo='20120000'; update CAI_OrderCheck set status='通过' where id={3} ;update tb_EForm set state='通过',e_LastTime=getdate() where allE_id={3} and proId=21;", pp.ProNo, orders1111[0].PONo, orders1111[0].POName, id)); using (SqlConnection conn = DBHelp.getConn()) { conn.Open(); SqlTransaction tan = conn.BeginTransaction(); SqlCommand objCommand = conn.CreateCommand(); objCommand.Transaction = tan; CAI_POCaiService CaiSer = new CAI_POCaiService(); try { objCommand.Parameters.Clear(); foreach (var caiIn in orders) { var check = orders1111.Single(t => t.CheckGoodId == caiIn.GooId); string sql = string.Format(" update CAI_OrderInHouses set OrderCheckIds={1} where ids={0}", caiIn.Ids, check.Ids); objCommand.CommandText = sql; objCommand.ExecuteNonQuery(); } tan.Commit(); } catch (Exception) { tan.Rollback(); } } }
protected void btnOK_Click(object sender, EventArgs e) { if (txtOrgPwd.Text.Trim() == "") { this.ClientScript.RegisterStartupScript(this.GetType(), null, "<script>alert('密码不能为空');</script>"); txtNewPwd.Focus(); return; } if (txtNewPwd.Text.Trim() == "") { this.ClientScript.RegisterStartupScript(this.GetType(), null, "<script>alert('新密码不能为空');</script>"); txtNewPwd.Focus(); return; } if (txtNewPwd.Text != txtReNewPwd.Text) { this.ClientScript.RegisterStartupScript(this.GetType(), null, "<script>alert('新密码和确认密码两个输入不一致');</script>"); txtNewPwd.Focus(); return; } User _User = new User(); _User.LoginPwd = this.txtOrgPwd.Text.Trim(); _User.LoginName = Convert.ToString(Session["LoginName"]); User u = new SysUserService().checkExist_1(_User); if (u == null) { base.ClientScript.RegisterStartupScript(base.GetType(), null, "<script>alert('密码不存在!');</script>"); return; } else if (u.LoginPwd != MD5Util.Encrypt(this.txtOrgPwd.Text)) { base.ClientScript.RegisterStartupScript(base.GetType(), null, "<script>alert('密码不存在!');</script>"); return; } else { } string sql = string.Format("update tb_User set loginPwd='{0}' where loginName='{1}'", MD5Util.Encrypt(txtNewPwd.Text), Session["LoginName"].ToString()); DBHelp.ExeCommand(sql); base.ClientScript.RegisterStartupScript(base.GetType(), null, "<script>alert('修改成功!');</script>"); }
protected void btnAdd_Click(object sender, EventArgs e) { if (this.FormCheck()) { try { User user = new User(); user.LoginUserNO = this.txtNo.Text; //user.LoginAddress = this.txtAddress.Text; //user.LoginRemark = this.txtCardNo.Text; user.LoginIPosition = this.ddlDeptment.Text; user.LoginPwd = MD5Util.Encrypt(this.txtPwd.Text); user.LoginPhone = this.txtTel.Text; user.LoginId = this.txtUserid.Text; user.LoginName = this.txtUserName.Text; //user.LoginStatus = this.ddlState.Text; //user.LoginTmpPwd = this.ddlState.Text; user.LoginStatus = this.ddlState.Text; user.LoginTmpPwd = this.ddlSex.Text; user.ReportTo = Convert.ToInt32(ddlReportTo.SelectedItem.Value); user.Zhiwu = txtZhiwu.Text; user.LoginMemo = txtEMail.Text; user.CompanyCode = ddlCompany.Text; user.SheBaoCode = ddlSheBao.Text; user.IsSpecialUser = cbIsSpecialUser.Checked; user.Mobile = txtMobile.Text; user.CardNO = txtCardNO.Text; user.CityNo = txtCityNo.Text; user.Education = ddlEducation.Text; user.School = txtSchool.Text; user.SchoolDate = txtSchoolDate.Text; user.Title = txtTitle.Text; user.Political = ddlPolitical.Text; user.HomeAdd = txtHomeAdd.Text; user.WorkDate = txtWorkDate.Text; int userId = this.UserSer.addUser(user); if (userId > 0) { List <RoleUser> roleUserList = new List <RoleUser>(); for (int i = 0; i < this.gvList.Rows.Count; i++) { CheckBox cbSelect = this.gvList.Rows[i].Cells[0].FindControl("IfSelected") as CheckBox; if (cbSelect.Checked) { RoleUser roleUser = new RoleUser(); roleUser.UserId = userId; roleUser.RoleId = Convert.ToInt32(this.gvList.DataKeys[i].Value); roleUserList.Add(roleUser); } } new RoleUserService().addRole_User(0, userId, roleUserList); //28 被派工人 //32 请假代理人 自动加载到审批流程中 string sql = string.Format(@"insert into A_Role_User values(28,{0},0,1);insert into A_Role_User values(32,{0},0,1);", userId); DBHelp.ExeCommand(sql); base.ClientScript.RegisterStartupScript(base.GetType(), null, "<script>alert('添加成功!');</script>"); this.clear(); IniData(); } else { base.ClientScript.RegisterStartupScript(base.GetType(), null, "<script>alert('添加失败!');</script>"); } } catch (Exception ex) { base.ClientScript.RegisterStartupScript(base.GetType(), null, "<script>alert('" + ex.Message + "!');</script>"); } } }
protected void btnDelete_Click(object sender, EventArgs e) { if (tvMain.SelectedNode == null || tvMain.SelectedNode.Depth <= 0) { ScriptManager.RegisterStartupScript(UpdatePanel1, this.GetType(), "a", string.Format("alert('请选择一个文件夹节点进行删除!');"), true); return; } if (tvMain.SelectedNode.Depth == 0) { ScriptManager.RegisterStartupScript(UpdatePanel1, this.GetType(), "a", string.Format("alert('该文件夹节点无法删除!');"), true); return; } string sql = "Folder_ID in ("; sql += string.Format("{0},", tvMain.SelectedNode.Target); for (int i = 0; i < tvMain.SelectedNode.ChildNodes.Count; i++) { sql += string.Format("{0},", tvMain.SelectedNode.ChildNodes[i].Target); } sql = sql.Substring(0, sql.Length - 1); sql += ")"; lblMess.Text = ""; //检测文件夹中是否有文件 string checkF = string.Format("select mainName,Folder_NAME from tb_Attachment left join tb_Folder on tb_Folder.Folder_ID=tb_Attachment.folder_Id where tb_Attachment." + sql); DataTable dt = DBHelp.getDataTable(checkF); if (dt.Rows.Count > 0) { string message = "<br/>提示:<br/>"; for (int i = 0; i < dt.Rows.Count; i++) { if (tvMain.SelectedNode.Text == dt.Rows[i]["Folder_NAME"].ToString()) { message += string.Format("文件夹:{1},存在文件:{0}<br/>", dt.Rows[i]["mainName"].ToString(), dt.Rows[i]["Folder_NAME"].ToString()); } else { message += string.Format("子文件夹:{1},存在文件:{0}<br/>", dt.Rows[i]["mainName"].ToString(), dt.Rows[i]["Folder_NAME"].ToString()); } } message += string.Format("上述原因导致改文件夹({0})不能被删除", tvMain.SelectedNode.Text); lblMess.Text = message; // ScriptManager.RegisterStartupScript(UpdatePanel1, this.GetType(), "a", string.Format("alert('{0}!');",message), true); return; } else { string delete = "delete from tb_Folder where " + sql; DBHelp.ExeCommand(delete); ScriptManager.RegisterStartupScript(UpdatePanel1, this.GetType(), "a", string.Format("alert('删除成功!');"), true); lblSonId.Visible = false; lblPareId.Visible = false; lblParent.Text = " "; txtFolder.Text = ""; btnSave.Enabled = false; btnCancel.Enabled = false; IniData(); } }