//protected void Button1_Click(object sender, EventArgs e) //{ // str111 = "select * from e_info order by infoDATE DESC"; //} //protected void GridView1_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e) //{ // GridView1.EditIndex = -1; //} //删除信息 protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e) { if (Session["benfactorFrom"].ToString() != GridView1.Rows[e.RowIndex].Cells[2].Text.ToString() && Session["UserName"].ToString() != "admin") {//当前用户既不是发件人也不是管理员 HttpContext.Current.Response.Write("<script>alert('只有发件人和管理员可以删除信息');</script>"); return; } NLogTest nlog = new NLogTest(); string sss = "删除了信息:" + ((HyperLink)GridView1.Rows[e.RowIndex].Cells[0].Controls[0]).Text.ToString(); nlog.WriteLog(Session["UserName"].ToString(), sss); ////删除服务器里的附件 ////读取附件列表并删除附件 //string str113 = string.Format("select infoFile from e_info where infoID='{0}'", GridView1.DataKeys[e.RowIndex].Value.ToString()); //mysqlconn msq11 = new mysqlconn(); //MySqlDataReader mysqlread = msq11.getmysqlread(str113); //string Files = ""; //string[] arrFiles; //while (mysqlread.Read()) //{ // Files = mysqlread.GetString(0); //} //arrFiles = Files.Split('|'); //foreach(string s in arrFiles) //{ // DeleteFile(s); //} //删除记录 string str112 = "delete from e_info where infoID='" + GridView1.DataKeys[e.RowIndex].Value.ToString() + "'"; msq.getmysqlcom(str112); databind(); }
//提交、写入数据库 protected void submit() { if (infoContent.Text.Length <= 0) { HttpContext.Current.Response.Write("<script>alert('信息内容不能为空');</script>"); } else if (infoTitle.Text.Length <= 0) { HttpContext.Current.Response.Write("<script>alert('信息标题不能为空');</script>"); } else { string str11 = string.Format("update e_info set infoTitle='{0}',infoContent='{1}',infoFile='{2}' where infoID='{3}'", infoTitle.Text, infoContent.Text, ViewState["myFilename"].ToString(), ViewState["IDNow"].ToString()); int res = msq.getmysqlcom(str11); if (res > 0) { NLogTest nlog = new NLogTest(); string sss = "修改了信息:" + ViewState["infoTitle"].ToString(); nlog.WriteLog(Session["UserName"].ToString(), sss); HttpContext.Current.Response.Write("<script>alert('信息修改成功');</script>"); //infoTitle.Text = infoContent.Text = ""; //重置? //ViewState["myFilename"] = ""; } else { HttpContext.Current.Response.Write("<script>alert('信息修改失败');</script>"); } } }
protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e) { //if (Session["userRole"].ToString() == "3")//会长不能删除受助人 //{ // Response.Write("<script>alert('会长不能删除受助人');</script>"); // return; //} //不能删除在项目中(即使是未通过的项目)的受助人 int countNum = 0; string str113 = "select count(*) as cnum from e_pr where recipientID=" + GridView1.DataKeys[e.RowIndex].Value.ToString(); MySqlDataReader mysqlread = msq.getmysqlread(str113); while (mysqlread.Read()) { countNum = mysqlread.GetInt32("cnum"); } if (countNum > 0)//该受助人在项目里 { HttpContext.Current.Response.Write("<script>alert('不能删除在项目中的受助人');</script>"); return; } NLogTest nlog = new NLogTest(); string sss = "删除了受助人:" + ((HyperLink)GridView1.Rows[e.RowIndex].Cells[1].Controls[0]).Text.ToString(); nlog.WriteLog(Session["UserName"].ToString(), sss); //删除记录 string str112 = "delete from e_recipients where recipientsID='" + GridView1.DataKeys[e.RowIndex].Value.ToString() + "'"; msq.getmysqlcom(str112); databind(ViewState["now"].ToString()); }
//protected void GridView1_SelectedIndexChanged(object sender, EventArgs e) //{//查看捐赠人信息 // //GridView与DetailsView的联动 // //DetailsView1.PageIndex = GridView1.SelectedIndex; // databind(ViewState["now"].ToString()); // //DetailsView1.Visible = true; //} protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e) {//判断当前登录用户是否和该捐赠人属于同一机构 if (Session["benfactorFrom"].ToString() != GridView1.Rows[e.RowIndex].Cells[2].Text.Trim()) { HttpContext.Current.Response.Write("<script>alert('不能删除其他机构的捐赠人');</script>"); return; } //判断捐赠人是否有资金 int countNum = 0; MySqlDataReader mysqlread = msq.getmysqlread("select count(*) as num from e_capital where capitalID='" + GridView1.DataKeys[e.RowIndex].Value.ToString() + "'"); while (mysqlread.Read()) { countNum = mysqlread.GetInt32("num"); } if (countNum == 0) {//没有资金 string str112 = "delete from e_benfactor where benfactorID='" + GridView1.DataKeys[e.RowIndex].Value.ToString() + "'"; NLogTest nlog = new NLogTest(); string sss = "删除了捐赠人:" + ((HyperLink)(GridView1.Rows[e.RowIndex].Cells[1].Controls[0])).Text; nlog.WriteLog(Session["UserName"].ToString(), sss); msq.getmysqlcom(str112); databind(ViewState["now"].ToString()); //DetailsView1.Visible = false; } else {//有资金,不能删除 HttpContext.Current.Response.Write("<script>alert('不能删除有资金(申请)的捐赠人');</script>"); } }
protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e) { NLogTest nlog = new NLogTest(); string s = "管理员删除了用户:" + GridView1.Rows[e.RowIndex].Cells[0].Text.ToString(); nlog.WriteLog(Session["UserName"].ToString(), s); string str113 = "delete from e_user where user='******'"; msq.getmysqlcom(str113); databind(ViewState["now"].ToString()); }
protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e) { NLogTest nlog = new NLogTest(); string s = "删除了经办单位:" + GridView1.Rows[e.RowIndex].Cells[1].Text.ToString(); nlog.WriteLog(Session["UserName"].ToString(), s); string str112 = "delete from e_handlingunit where handlingunitID='" + GridView1.DataKeys[e.RowIndex].Value.ToString() + "'"; msq.getmysqlcom(str112); databind(ViewState["queryString"].ToString()); }
protected void dgData_DeleteCommand(object source, DataGridCommandEventArgs e) { NLogTest nlog = new NLogTest(); string sss = "删除了项目:" + ((Label)e.Item.FindControl("labName")).Text.Trim(); nlog.WriteLog(Session["UserName"].ToString(), sss); string str112 = "delete from e_project where projectID='" + ((HyperLink)(e.Item.Cells[0].Controls[0])).Text.Trim() + "'"; msq.getmysqlcom(str112); dgData.CurrentPageIndex = 0; databind(); }
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "resetPWD") { int index = int.Parse(e.CommandArgument.ToString()); string str115 = "update e_user set password='******' where user='******'"; msq.getmysqlcom(str115); HttpContext.Current.Response.Write("<script>alert('密码已重置为cs12345');</script>"); NLogTest nlog = new NLogTest(); string s = "管理员重置了用户:" + GridView1.DataKeys[index].Value.ToString() + "的密码"; nlog.WriteLog(Session["UserName"].ToString(), s); } }
protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e) { string updateString = string.Format("update e_capital set capitalEarn=capitalEarn-{1} where capitalID='{0}'", GridView1.Rows[e.RowIndex].Cells[1].Text, GridView1.Rows[e.RowIndex].Cells[6].Text); string update2String = string.Format("update e_capital_detail set operator='{1}',opType='撤回录入',opTime='{2}',opBranchName='{3}' where ID='{0}'", GridView1.DataKeys[e.RowIndex].Value.ToString(), Session["UserName"].ToString(), DateTime.Now.ToString(), Session["benfactorFrom"].ToString()); HttpContext.Current.Response.Write("<script>alert('金额撤回成功');</script>"); NLogTest nlog = new NLogTest(); string sss = "捐助科撤回了" + GridView1.Rows[e.RowIndex].Cells[0].Text + "的" + GridView1.Rows[e.RowIndex].Cells[2].Text + "的捐赠金额" + GridView1.Rows[e.RowIndex].Cells[6].Text + "元。资金ID:" + GridView1.Rows[e.RowIndex].Cells[1].Text; nlog.WriteLog(Session["UserName"].ToString(), sss); msq.getmysqlcom(updateString); msq.getmysqlcom(update2String); databind(); }
//private void dgData_DeleteCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e) //{ //} private void dgData_EditCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e) { DateTime dt = DateTime.Now; string prodatatimefinsh = dt.ToShortDateString().ToString(); string tempID = ((HyperLink)(e.Item.Cells[0].Controls[0])).Text.Trim(); string str = string.Format("update e_project set proschedule='归档',prodatatimefinsh='{0}' where projectID='" + tempID + "'", prodatatimefinsh); msq.getmysqlcom(str); databind(); NLogTest nlog = new NLogTest(); string sss = "项目归档:" + tempID; nlog.WriteLog(Session["UserName"].ToString(), sss); }
private void dgData_UpdateCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e) { //DataSet dds = MySqlHelper.ExecuteDataset(msq.getmysqlcon(), str111); //DataView ddv = new DataView(dds.Tables[0]); //dgData.DataSource = dds; // dgData.DataBind(); // databind(); string strupdata = string.Format("update e_recipients set projectID='{0}' where recipientsPIdcard='{1}'", Session["ProjectID"].ToString(), ((TextBox)e.Item.FindControl("txtEditName")).Text.Trim()); msq.getmysqlcom(strupdata); NLogTest nlog = new NLogTest(); string sss = "分配资金:" + ((TextBox)e.Item.FindControl("txtteladd")).Text.Trim(); nlog.WriteLog(Session["UserName"].ToString(), sss); }
protected void dgData_ItemCommand(object source, DataGridCommandEventArgs e) { if (e.CommandName == "SelectR") {//选择受助人到项目中 if (Session["ProjectID"] == null) { labError.Text = "请先获取项目ID"; return; } if (tbMoney.Text.Trim() == "") { Response.Write("<script>alert('请填写受助人的救助金额');</script>"); return; } else { try { Convert.ToDouble(tbMoney.Text.Trim()); } catch { Response.Write("<script>alert('救助金额为正数');</script>"); return; } if (Convert.ToDouble(tbMoney.Text.Trim()) < 0) { Response.Write("<script>alert('救助金额不能为负数');</script>"); return; } } if (tbRequest.Text.Trim() == "") { Response.Write("<script>alert('请填写受助人的救助申请');</script>"); return; } NLogTest nlog = new NLogTest(); string sss = "分配受助人:" + ((Label)e.Item.FindControl("lblID")).Text.Trim() + "到项目:" + Session["ProjectID"].ToString();//LbproID.Text nlog.WriteLog(Session["UserName"].ToString(), sss); string strupdata = string.Format("insert ignore into e_pr (projectID,recipientID,request,money) values ({0},{1},'{2}',{3})", Session["ProjectID"].ToString(), ((Label)e.Item.FindControl("lblID")).Text.Trim(), tbRequest.Text.Trim(), tbMoney.Text.Trim()); msq.getmysqlcom(strupdata); //databind(ViewState["now"].ToString()); databind2(); dgData1.Visible = true; } }
protected void dgData_ItemCommand(object source, DataGridCommandEventArgs e) { if (e.CommandName == "Edit1") { DateTime dt = DateTime.Now; string prodatatimefinsh = dt.ToShortDateString().ToString(); string tempID = ((HyperLink)(e.Item.Cells[0].Controls[0])).Text.Trim(); string str = string.Format("update e_project set proschedule='结项',prodatatimeguid='{0}' where projectID='" + tempID + "'", prodatatimefinsh); msq.getmysqlcom(str); databind(); NLogTest nlog = new NLogTest(); string sss = "项目结项:" + tempID; nlog.WriteLog(Session["UserName"].ToString(), sss); } }
protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e) { //sqlcon = new SqlConnection(strCon); NLogTest nlog = new NLogTest(); string s = "修改了经办单位信息:" + GridView1.Rows[e.RowIndex].Cells[1].Text.ToString().Trim(); nlog.WriteLog(Session["UserName"].ToString(), s); string str113 = "update e_handlingunit set address='" //+ ((TextBox)(GridView1.Rows[e.RowIndex].Cells[0].Controls[0])).Text.ToString().Trim() + "',address='" + ((TextBox)(GridView1.Rows[e.RowIndex].Cells[2].Controls[0])).Text.ToString().Trim() + "',contactPerson='" + ((TextBox)(GridView1.Rows[e.RowIndex].Cells[3].Controls[0])).Text.ToString().Trim() + "',TEL='" + ((TextBox)(GridView1.Rows[e.RowIndex].Cells[4].Controls[0])).Text.ToString().Trim() + "' where handlingunitID='" + GridView1.DataKeys[e.RowIndex].Value.ToString() + "'"; msq.getmysqlcom(str113); GridView1.EditIndex = -1; databind(ViewState["queryString"].ToString()); }
private void dgData1_UpdateCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e) { ((TextBox)e.Item.FindControl("tbProjectID")).Text = LbproID.Text;//项目ID if (((TextBox)e.Item.FindControl("tbProjectID")).Text == "") { lberror.Text = "项目ID不能为空"; } else {//物品追踪 string strupdate = string.Format("update e_item set projectID='{1}',projectName='{2}',timeOut='{3}',state='已使用' where itemID='{0}'", ((TextBox)e.Item.FindControl("tbItemID")).Text.Trim(), LbproID.Text.Trim(), lbbenfnadd.Text.Trim(), DateTime.Now.ToString()); msq.getmysqlcom(strupdate); dgData1.EditItemIndex = -1; databind1(ViewState["now"].ToString()); NLogTest nlog = new NLogTest(); string sss = "分配物品:" + ((TextBox)e.Item.FindControl("tbItemName")).Text.Trim(); nlog.WriteLog(Session["UserName"].ToString(), sss); } }
private void dgData_UpdateCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e) { string strupdata = string.Format("update e_project set projectID='{0}',projectName='{1}',benfactorFrom='{2}',proschedule='{3}',telphoneName='{4}',projectDir='{5}' where projectID='{0}'", ((TextBox)e.Item.FindControl("txtEditID")).Text.Trim(), ((TextBox)e.Item.FindControl("txtEditName")).Text.Trim(), ((TextBox)e.Item.FindControl("txtEditOrder")).Text.Trim(), ((TextBox)e.Item.FindControl("txttimer")).Text.Trim(), ((TextBox)e.Item.FindControl("txtteladdname")).Text.Trim(), ((TextBox)e.Item.FindControl("txtdes")).Text.Trim()); msq.getmysqlcom(strupdata); dgData.EditItemIndex = -1; databind(); NLogTest nlog = new NLogTest(); string sss = "修改项目信息情况:" + ((TextBox)e.Item.FindControl("txtEditName")).Text.Trim(); nlog.WriteLog(Session["UserName"].ToString(), sss); }
protected void btnReceipt_Click(object sender, EventArgs e) { string zerostr = "未读"; string str11 = string.Format("insert into e_info (infoTitle,infoContent,infoDATE,infoFile,infoFrom,infoTo,infoRead) VALUES ('{0}','{1}','{2}','{3}','{4}','{5}','{6}')", Session["benfactorFrom"].ToString() + "的回执:" + infoTitle.Text, "原始信息:" + infoContent.Text, DateTime.Now.ToString(), "", Session["benfactorFrom"].ToString(), ViewState["sender"].ToString(), zerostr); int res = msq.getmysqlcom(str11); //写入数据库 if (res > 0) { NLogTest nlog = new NLogTest(); string s = "发布了信息:“" + infoTitle.Text.ToString() + "”的回执"; nlog.WriteLog(Session["UserName"].ToString(), s); lblErr.Text = "发送成功!"; } else { lblErr.Text = "发送失败!"; } }
private void dgData_UpdateCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e) { //DataSet dds = MySqlHelper.ExecuteDataset(msq.getmysqlcon(), str111); //DataView ddv = new DataView(dds.Tables[0]); //dgData.DataSource = dds; // dgData.DataBind(); // databind(); if (((TextBox)e.Item.FindControl("txtproid")).Text == "") { lberror.Text = "项目ID不能为空"; } else { int i = int.Parse(lbcaptID.Text); int re = int.Parse(((TextBox)e.Item.FindControl("txtemail")).Text); if (i > re) { lbcaptID.Text = (i - re).ToString(); ((TextBox)e.Item.FindControl("txtemail")).Text = "0"; } else { ((TextBox)e.Item.FindControl("txtemail")).Text = (re - i).ToString(); lbcaptID.Text = "0"; } string strupdata = string.Format("update e_capital set capitalID='{0}',capitalEarn='{1}',capitalIntime='{2}',projectID='{3}',projectName='{4}' where capitalID='{0}'", ((TextBox)e.Item.FindControl("txtteladd")).Text.Trim(), ((TextBox)e.Item.FindControl("txtemail")).Text.Trim(), ((TextBox)e.Item.FindControl("txtdir")).Text.Trim(), ((TextBox)e.Item.FindControl("txtproid")).Text.Trim(), ((TextBox)e.Item.FindControl("txtproname")).Text.Trim()); msq.getmysqlcom(strupdata); dgData.EditItemIndex = -1; databind(); NLogTest nlog = new NLogTest(); string sss = "申请资金分配审批:" + ((TextBox)e.Item.FindControl("txtteladd")).Text.Trim(); nlog.WriteLog(Session["UserName"].ToString(), sss); } }
protected void btnCancel_Click(object sender, EventArgs e) { //撤回语句 string updateString = string.Format("update e_capital set capitalIn=0,state=1 where capitalID='{0}'", lbcaptID.Text); string insertString = string.Format("insert into e_capital_detail (detailID,benefactorName,branchName,operator,opType,income,remain,opTime,opBranchName) values('{0}','{1}','{2}','{3}','{4}',{5},{6},'{7}','{8}')", lbcaptID.Text, LbproID.Text, lblBranch.Text, Session["UserName"].ToString(), "撤回申请", double.Parse(txtPLAN.Text), Convert.ToDouble(lbcaptIDown.Text), DateTime.Now.ToString(), Session["benfactorFrom"].ToString()); int result = msq.getmysqlcom(updateString); if (result > 0) { msq.getmysqlcom(insertString); lblErr.Text = "金额撤回成功"; NLogTest nlog = new NLogTest(); string sss = "撤回了" + lblBranch.Text + "的" + LbproID.Text + "申请捐赠金额" + txtPLAN.Text + "元。资金ID:" + lbcaptID.Text; nlog.WriteLog(Session["UserName"].ToString(), sss); txtPLAN.Enabled = true; btyes.Enabled = true; confirm.Visible = false; btnCancel.Visible = false; } reload(); }
protected void confirm_Click(object sender, EventArgs e)//确认添加 { //string updateString = string.Format("update e_capital set capitalEarn={1},capitalIntime='{2}',state=1 where capitalID='{0}'", lbcaptID.Text, Convert.ToInt32(lbcaptIDown.Text) + Convert.ToInt32(txtPLAN.Text), lbtime.Text); string updateString = string.Format("update e_capital set capitalEarn={1},capitalIn=0,state=1 where capitalID='{0}'", lbcaptID.Text, Convert.ToDouble(lbcaptIDown.Text) + Convert.ToDouble(txtPLAN.Text)); string insertString = string.Format("insert into e_capital_detail (detailID,benefactorName,branchName,operator,opType,income,remain,opTime,opBranchName) values('{0}','{1}','{2}','{3}','{4}',{5},{6},'{7}','{8}')", lbcaptID.Text, LbproID.Text, lblBranch.Text, Session["UserName"].ToString(), "确认录入", double.Parse(txtPLAN.Text), Convert.ToDouble(lbcaptIDown.Text), DateTime.Now.ToString(), Session["benfactorFrom"].ToString()); int result = msq.getmysqlcom(updateString); if (result > 0) { msq.getmysqlcom(insertString); // HttpContext.Current.Response.Write("<script>alert('金额确认成功');</script>"); lblErr.Text = "金额确认成功"; NLogTest nlog = new NLogTest(); string sss = "捐助科确认:为" + lblBranch.Text + "的" + LbproID.Text + "录入了捐赠金额" + txtPLAN.Text + "元。资金ID:" + lbcaptID.Text; nlog.WriteLog(Session["UserName"].ToString(), sss); txtPLAN.Enabled = true; btyes.Enabled = true; confirm.Visible = false; btnCancel.Visible = false; } reload(); }
protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e) { string strNewRole = ((TextBox)(GridView1.Rows[e.RowIndex].Cells[1].Controls[0])).Text.ToString().Trim(); if (strNewRole == "1" || strNewRole == "2" || strNewRole == "3" || strNewRole == "4") { string str114 = "update e_user set userRole='" + ((TextBox)(GridView1.Rows[e.RowIndex].Cells[1].Controls[0])).Text.ToString().Trim() + "' where user='******'"; msq.getmysqlcom(str114); NLogTest nlog = new NLogTest(); string s = "管理员修改了用户:" + GridView1.Rows[e.RowIndex].Cells[0].Text.ToString().Trim() + "的信息"; nlog.WriteLog(Session["UserName"].ToString(), s); GridView1.EditIndex = -1; databind(ViewState["now"].ToString()); } else { GridView1.EditIndex = -1; databind(ViewState["now"].ToString()); } }
protected void btyes_Click(object sender, EventArgs e)//提交添加资金 { ////判断状态 //string queryState = "select state from e_capital where capitalID='" + lbcaptID.Text.ToString() + "'"; //MySqlDataReader readState = msql.getmysqlread(queryState); //int state = -1; //while (readState.Read()) //{ // if(readState.GetInt32(0)==0) // { // HttpContext.Current.Response.Write("<script>alert('请科室确认资金');</script>"); // return; // } //} //判断是否为空 //if ((txtPLAN.Text == "")||(txtPLAN.Text=="0")) //{ // lblErr.InnerText = "请输入金额"; // // HttpContext.Current.Response.Write("<script>alert('请输入金额');</script>"); // return; //} //else if(Convert.ToDouble(txtPLAN.Text)<=0) //{ // lblErr.InnerText = "请输入正数"; // return; //} if (txtPLAN.Text.Trim() == "") { lblErr.Text = "请输入金额!"; txtPLAN.BackColor = Color.FromArgb((int)0xFFE1FF); txtPLAN.Focus(); // HttpContext.Current.Response.Write("<script>alert('请输入金额');</script>"); return; } else { try { Convert.ToDouble(txtPLAN.Text.Trim()); } catch { lblErr.Text = "请输入正数"; txtPLAN.BackColor = Color.FromArgb((int)0xFFE1FF); txtPLAN.Focus(); return; } if (Convert.ToDouble(txtPLAN.Text.Trim()) <= 0) { lblErr.Text = "请输入正数"; txtPLAN.BackColor = Color.FromArgb((int)0xFFE1FF); txtPLAN.Focus(); return; } txtPLAN.BackColor = Color.White; } ////判断权限 //string queryRole = "select userRole from e_user where user='******'"; //MySqlDataReader mysqlread32 = msql.getmysqlread(queryRole); //int roleOfUser=0; //while (mysqlread32.Read()) //{ // roleOfUser = mysqlread32.GetInt32(0); //} int result; //捐助科不用确认有误操作风险,2016-8-28注释 //if(Session["benfactorFrom"].ToString() == "北京市朝阳区慈善协会捐助科")//捐助科 //{ // string strins = string.Format("insert into e_capital (capitalID,benfactorID,capitalIn,capitalEarn,capitalIntime,handlingunitID,benfactorName,state,benfactorFrom) values('{0}','{1}','{2}',{3},'{4}','{5}','{6}',1,'{7}')", lbcaptID.Text, (string)ViewState["myKey"], 0, Convert.ToDouble(txtPLAN.Text) + Convert.ToDouble(lbcaptIDown.Text), lbtime.Text, (string)ViewState["myID"], LbproID.Text,lblBranch.Text); // string strupd = string.Format("update e_capital set benfactorID='{1}',capitalIn='{2}',capitalEarn={3},capitalIntime='{4}',handlingunitID='{5}',benfactorName='{6}',state=1,benfactorFrom='{7}' where capitalID='{0}'", lbcaptID.Text, (string)ViewState["myKey"], 0, Convert.ToDouble(txtPLAN.Text) + Convert.ToDouble(lbcaptIDown.Text), lbtime.Text, (string)ViewState["myID"], LbproID.Text, lblBranch.Text); // try{ // result = msq.getmysqlcom(strins); // } // catch{ // result = msq.getmysqlcom(strupd); // } // if (result>0) // { // lblErr.InnerText = "添加资金成功"; // NLogTest nlog = new NLogTest(); // string sss = "捐助科为" + lblBranch.Text+"的"+LbproID.Text+ "录入了捐赠金额"+txtPLAN.Text+"元。资金ID:" + lbcaptID.Text; // nlog.WriteLog(Session["UserName"].ToString(), sss); // // HttpContext.Current.Response.Write("<script>alert('添加资金成功');</script>"); // } // reload();//刷新页面 //} //else //{//非捐助科权限 string strins2 = string.Format("insert into e_capital (capitalID,benfactorID,capitalIn,capitalEarn,capitalIntime,handlingunitID,benfactorName,state,benfactorFrom) values('{0}','{1}','{2}',{3},'{4}','{5}','{6}',0,'{7}')", lbcaptID.Text, (string)ViewState["myKey"], double.Parse(txtPLAN.Text.Trim()), Convert.ToDouble(lbcaptIDown.Text), lbtime.Text, (string)ViewState["myID"], LbproID.Text, lblBranch.Text); string strupd2 = string.Format("update e_capital set benfactorID='{1}',capitalIn='{2}',capitalEarn={3},capitalIntime='{4}',handlingunitID='{5}',benfactorName='{6}',state=0,benfactorFrom='{7}' where capitalID='{0}'", lbcaptID.Text, (string)ViewState["myKey"], double.Parse(txtPLAN.Text.Trim()), Convert.ToDouble(lbcaptIDown.Text), lbtime.Text, (string)ViewState["myID"], LbproID.Text, lblBranch.Text); string insertString = string.Format("insert into e_capital_detail (detailID,benefactorName,branchName,operator,opType,income,remain,opTime,opBranchName) values('{0}','{1}','{2}','{3}','{4}',{5},{6},'{7}','{8}')", lbcaptID.Text, LbproID.Text, lblBranch.Text, Session["UserName"].ToString(), "申请录入", double.Parse(txtPLAN.Text), Convert.ToDouble(lbcaptIDown.Text), DateTime.Now.ToString(), Session["benfactorFrom"].ToString()); try { result = msq.getmysqlcom(strins2); } catch { result = msq.getmysqlcom(strupd2); } if (result > 0) { msq.getmysqlcom(insertString); lblErr.Text = "提交成功,请等待捐助科审批确认"; NLogTest nlog = new NLogTest(); string sss = "为" + lblBranch.Text + "的" + LbproID.Text + "录入了捐赠金额" + txtPLAN.Text + "元。资金ID:" + lbcaptID.Text; nlog.WriteLog(Session["UserName"].ToString(), sss); // HttpContext.Current.Response.Write("<script>alert('提交成功,请等待科室审批确认');</script>"); } reload(); //刷新页面 //} }
//发布信息 protected void Button1_Click(object sender, EventArgs e) { if (infoTitle.Text.Length <= 0) { //Response.Write("<script>alert('请输入标题!')</script>"); lblError.Text = "标题不能为空!"; infoTitle.BackColor = Color.FromArgb((int)0xFFE1FF); infoTitle.Focus(); return; } else { infoTitle.BackColor = Color.White; } if (infoContent.Text.Length <= 0) { lblError.Text = "内容不能为空!"; infoContent.BackColor = Color.FromArgb((int)0xFFE1FF); infoContent.Focus(); //Response.Write("<script>alert('请输入内容!')</script>"); return; } else { infoContent.BackColor = Color.White; } if ((DropDownList1.SelectedValue.ToString().Trim() == "选择机构") && (DropDownCheckBoxList1.SelectedText.ToString().Trim() == "")) { lblError.Text = "请选择收件人!"; //Response.Write("<script>alert('请选择收件人!')</script>"); return; } else //if(infoTitle.Text.Length>0 && infoContent.Text.Length>0) { string zerostr = "未读"; if (DropDownList1.SelectedValue == "所有机构") { string str11 = string.Format("insert into e_info (infoTitle,infoContent,infoDATE,infoFile,infoFrom,infoTo,infoRead,projectID) VALUES ('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}')", infoTitle.Text, infoContent.Text, DateTime.Now.ToString(), ViewState["myFilename"].ToString(), Session["benfactorFrom"].ToString(), DropDownList1.Text.Trim(), zerostr, tbID.Text.Trim()); int res = msq.getmysqlcom(str11); //写入数据库 if (res > 0) { NLogTest nlog = new NLogTest(); string s = "发布了信息:" + infoTitle.Text.ToString(); nlog.WriteLog(Session["UserName"].ToString(), s); //HttpContext.Current.Response.Write("<script>alert('信息发布成功');</script>"); lblError.Text = "信息发布成功!"; //重置 infoTitle.Text = infoContent.Text = ""; ViewState["myFilename"] = ""; pageload(); } else { //HttpContext.Current.Response.Write("<script>alert('信息发布失败');</script>"); lblError.Text = "信息发布失败!"; } } else//多收件人n>0 {//事务 List <string> SQLStringList = new List <string>(); string insertString = ""; string[] recs = DropDownCheckBoxList1.SelectedText.ToString().Split(','); foreach (string s in recs) { insertString = string.Format("insert into e_info (infoTitle,infoContent,infoDATE,infoFile,infoFrom,infoTo,infoRead,projectID) VALUES ('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}')", infoTitle.Text, infoContent.Text, DateTime.Now.ToString(), ViewState["myFilename"].ToString(), Session["benfactorFrom"].ToString(), s, zerostr, tbID.Text.Trim()); SQLStringList.Add(insertString); } ExecuteSqlTran(SQLStringList); NLogTest nlog2 = new NLogTest(); string s2 = "发布了信息:" + infoTitle.Text.ToString(); nlog2.WriteLog(Session["UserName"].ToString(), s2); lblError.Text = "信息发布成功!"; //重置 infoTitle.Text = infoContent.Text = ""; ViewState["myFilename"] = ""; pageload(); } } }
protected void btyes_Click(object sender, EventArgs e) { labError.Text = ""; string strID = txtID.Text.Trim(); if (strID == "") { labError.ForeColor = System.Drawing.Color.Red; labError.Text = "请输入用户名"; txtID.BackColor = Color.FromArgb((int)0xFFE1FF); txtID.Focus(); return; } else { txtID.BackColor = Color.White; } string errMsg = ""; if (!luyunfei.lyf_validate.isAZaz09_(strID, 5, 8, out errMsg)) { labError.Text = "用户名由5~8位的数字、英文字母或下划线组成!"; txtID.BackColor = Color.FromArgb((int)0xFFE1FF); txtID.Focus(); return; } else { txtID.BackColor = Color.White; } //bool isMatch = lyf_validate.isIDorPwd(strID); //if (!isMatch) //{ // labError.ForeColor = System.Drawing.Color.Red; // labError.Text = "输入的用户名格式不正确!用户ID只能包含字母、数字、下划线,且不能以数字开头,5~16位。"; // benfactorFrom.BackColor = Color.FromArgb((int)0xFFE1FF); // benfactorFrom.Focus(); // return; //} string strName = txtName.Text.Trim(); if (strName == "") { labError.ForeColor = System.Drawing.Color.Red; labError.Text = "请输入姓名"; txtName.BackColor = Color.FromArgb((int)0xFFE1FF); txtName.Focus(); return; } else { txtName.BackColor = Color.White; } string strUserRole = ddlRole.SelectedValue.ToString(); if (ddlRole.SelectedValue == "请选择") { labError.ForeColor = System.Drawing.Color.Red; labError.Text = "请选择权限"; return; } string strTEL = TEL.Text.Trim(); if (strTEL == "") { labError.ForeColor = System.Drawing.Color.Red; labError.Text = "请输入联系方式"; TEL.BackColor = Color.FromArgb((int)0xFFE1FF); TEL.Focus(); return; } else { TEL.BackColor = Color.White; } string strPwd = txtPWD.Text.Trim(); if (strPwd == "") { labError.ForeColor = System.Drawing.Color.Red; labError.Text = "请输入密码"; txtPWD.BackColor = Color.FromArgb((int)0xFFE1FF); txtPWD2.BackColor = Color.White; txtPWD.Focus(); return; } else { txtPWD.BackColor = Color.White; } if (!luyunfei.lyf_validate.isAZaz09_(strPwd, 5, 20, out errMsg)) { labError.Text = "密码由5~20位的数字、英文字母或下划线组成!"; txtPWD.BackColor = Color.FromArgb((int)0xFFE1FF); txtPWD.Focus(); return; } else { txtPWD.BackColor = Color.White; } string strPwd2 = txtPWD2.Text.Trim(); if (strPwd2 == "") { labError.ForeColor = System.Drawing.Color.Red; labError.Text = "请再次输入密码"; txtPWD.BackColor = Color.FromArgb((int)0xFFE1FF); txtPWD2.BackColor = Color.FromArgb((int)0xFFE1FF); txtPWD.Focus(); return; } else { txtPWD.BackColor = Color.White; txtPWD2.BackColor = Color.White; } if (strPwd != strPwd2) { labError.ForeColor = System.Drawing.Color.Red; labError.Text = "两次输入的密码不一致!"; txtPWD.BackColor = Color.FromArgb((int)0xFFE1FF); txtPWD2.BackColor = Color.FromArgb((int)0xFFE1FF); txtPWD.Focus(); return; } else { txtPWD.BackColor = Color.White; txtPWD2.BackColor = Color.White; } string strFrom = benfactorFrom.Text.Trim(); HybridDictionary hd = new HybridDictionary(); hd.Add(sPMS_CTG_ID, strID); // dtUsers = entityUsers.ExecuteDataTable2(CommandType.Text, "SelectById", hd); string sqldate = string.Format("select * from e_user where user='******'", strID); mysqlconn mys = new mysqlconn(); MySqlDataAdapter sda = new MySqlDataAdapter(sqldate, mys.getmysqlcon()); DataSet ds = MySqlHelper.ExecuteDataset(mys.getmysqlcon(), sqldate); DataView dv = new DataView(ds.Tables[0]); if (dv.Count > 0) { labError.ForeColor = System.Drawing.Color.Red; labError.Text = "该用户已存在!"; return; } try { //DataTable schemaMeter = entityUsers.GetSchema(); //DataRow dr = schemaMeter.NewRow(); //dr[sPMS_CTG_ID] = strID; //dr[sPMS_CTG_NAME] = strName; //dr[sUSE_IDT] = 0;//用户标记为未启用 //dr[sPwd] = strPwd; //dr[sDES] = ""; //dr[sCRT_DATE] = DateTime.Now; string sqldate1 = string.Format("insert into e_user(user,password,benfactorFrom,name,TEL,userRole) values('{0}','{1}','{2}','{3}','{4}',{5})", strID, strPwd, strFrom, strName, strTEL, strUserRole); // bool result = Convert.ToBoolean(entityUsers.Insert(dr)); int result1 = mys.getmysqlcom(sqldate1); if (result1 > 0) { labError.ForeColor = System.Drawing.Color.Red; labError.Text = "注册成功!"; // wl.WriteLogData(PAGE_NAME, "创建", strName, System.Diagnostics.EventLogEntryType.Information); NLogTest nlog = new NLogTest(); string sss = "管理员创建了新用户:" + strID + "(" + strName + ")"; nlog.WriteLog(Session["UserName"].ToString(), sss); } else { labError.ForeColor = System.Drawing.Color.Red; labError.Text = "注册失败!"; // wl.WriteLogData(PAGE_NAME, "创建", strName, System.Diagnostics.EventLogEntryType.Warning); } } catch (Exception ex) { labError.ForeColor = System.Drawing.Color.Red; labError.Text = "添加记录失败" + ui.ExceptionMsg(ex); // wl.WriteLogData(PAGE_NAME, "创建", strName + ":" + ex.Message + ex.StackTrace, System.Diagnostics.EventLogEntryType.Error); } }
protected void btnReapply_Click(object sender, EventArgs e) { //if (LbproID.Text.Trim() == "") //{ // labError.Text = "请获取项目ID"; // return; //} if (recipientsType.SelectedValue == "请选择") { labError.Text = "请选择受助人类别"; return; } if (projectID.Text.Trim() == "") { labError.Text = "请输入项目名称"; return; } if (projectDir.Text.Trim() == "") { labError.Text = "请输入项目方案"; return; } if (txtPLAN.Text.Trim() == "") { labError.Text = "请输入项目预算"; return; } else { try { Convert.ToDouble(txtPLAN.Text.Trim()); } catch { labError.Text = "项目预算为正数"; return; } if (Convert.ToDouble(txtPLAN.Text.Trim()) < 0) { labError.Text = "项目预算不能为负数"; return; } if (Convert.ToDouble(txtPLAN.Text.Trim()) > Convert.ToDouble(ViewState["sum"].ToString())) { labError.Text = "金额不足"; return; } } if (txtDIR.Text.Trim() == "") { if (ddlNaming.SelectedValue.ToString() == "1") {//冠名项目 labError.Text = "请输入受助人情况"; return; } } DateTime dt = DateTime.Now; string prodatatime = dt.ToShortDateString().ToString(); string str11 = string.Format("update e_project set projectName='{1}',projectDir='{2}',palnMoney='{3}',recipientsNow='{4}',telphoneName='{5}',telphoneADD='{6}',prodatatime='{7}',proschedule='申请中',projectLei='{8}',needMoney={3},projectType='{9}',isnaming={10},isdirect={11} where projectID='{0}'", LbproID.Text, projectID.Text, projectDir.Text, txtPLAN.Text, txtDIR.Text, txttel.Text, txtteladd.Text, prodatatime, recipientsType.SelectedValue.ToString(), ddlType.SelectedValue.ToString(), ddlNaming.SelectedValue.ToString(), ddlDirect.SelectedValue.ToString()); int res = msq.getmysqlcom(str11); if (res > 0) { labError.Text = "重新申请项目成功,请选择受助人"; btnReapply.Visible = false; btnFinish.Visible = true; table1.Visible = true; dgData1.Visible = true; ddlDirect.Enabled = ddlNaming.Enabled = ddlType.Enabled = recipientsType.Enabled = false; } else { labError.Text = "重新申请项目失败"; } NLogTest nlog = new NLogTest(); string sss = "重新申请项目:" + projectID.Text; nlog.WriteLog(Session["UserName"].ToString(), sss); projectID.ReadOnly = true; projectDir.ReadOnly = true; txtPLAN.ReadOnly = true; txtDIR.ReadOnly = true; txttel.ReadOnly = true; txtteladd.ReadOnly = true; buttonVisible.Visible = false; applyTable.Visible = false; familylist.Text = "+"; }
//protected void BindData()//绑定数据 //{ //} protected void Button1_Click(object sender, EventArgs e) { if (tbItem.Text.Trim() == "") { lblError.ForeColor = System.Drawing.Color.Red; lblError.Text = "请填入捐赠物品!"; tbItem.BackColor = Color.FromArgb((int)0xFFE1FF); tbItem.Focus(); return; } else { tbItem.BackColor = Color.White; } if (tbValue.Text.Trim() == "") { lblError.ForeColor = System.Drawing.Color.Red; lblError.Text = "请输入公允值(元)!"; tbValue.BackColor = Color.FromArgb((int)0xFFE1FF); tbValue.Focus(); return; } else { try { Convert.ToDouble(tbValue.Text.Trim()); } catch { lblError.ForeColor = System.Drawing.Color.Red; lblError.Text = "公允值为正数"; tbValue.BackColor = Color.FromArgb((int)0xFFE1FF); tbValue.Focus(); return; } if (Convert.ToDouble(tbValue.Text.Trim()) <= 0) { lblError.ForeColor = System.Drawing.Color.Red; lblError.Text = "公允值为正数"; tbValue.BackColor = Color.FromArgb((int)0xFFE1FF); tbValue.Focus(); return; } tbValue.BackColor = Color.White; } string insertString = string.Format("insert into e_item (handlingunitID,benfactorFrom,benfactorID,benfactorName,item,fairValue,state,timeIn) values({0},'{1}',{2},'{3}','{4}',{5},'{6}','{7}')", ViewState["IDNow"].ToString().Substring(0, 3), ViewState["branchName"].ToString(), ViewState["IDNow"].ToString(), ViewState["name"].ToString(), tbItem.Text.Trim(), tbValue.Text.Trim(), "未使用", DateTime.Now.ToString()); //try //{ msq.getmysqlcom(insertString); lblError.Text = "提交成功"; NLogTest nlog = new NLogTest(); string sss = "为" + lblBranch.Text + "的" + lblName.Text + "录入了物品:" + tbItem.Text + ",公允值:" + tbValue.Text + "元。"; nlog.WriteLog(Session["UserName"].ToString(), sss); //} //catch //{ // lblError.Text = "提交失败"; //} }
protected void Btinput_Click(object sender, EventArgs e) { string strbranchID = ""; //经办单位ID string strBenfactorType; //捐助人类型 string strTEL; //手机号 string strBenfactorID; //捐助人ID //string selectBranchID = "select handlingunitID from e_handlingunit where benfactorFrom='" + ddlBranch.Text.ToString() + "'"; //MySqlDataReader mysqlread1 = msq.getmysqlread(selectBranchID); //while (mysqlread1.Read()) switch (int.Parse(benfactorType.SelectedValue)) { case 1: if (benfactorName.Text.Trim() == "") { labError.Text = "公益组织名称不能为空!"; benfactorName.BackColor = Color.FromArgb((int)0xFFE1FF); benfactorName.Focus(); return; } else { benfactorName.BackColor = Color.White; } if (Contacts.Text.Trim() == "") { labError.Text = "联系人姓名不能为空!"; Contacts.BackColor = Color.FromArgb((int)0xFFE1FF); Contacts.Focus(); return; } else { Contacts.BackColor = Color.White; } if (Contacts.Text.Trim() == "") { labError.Text = "联系人姓名不能为空!"; Contacts.BackColor = Color.FromArgb((int)0xFFE1FF); Contacts.Focus(); return; } else { Contacts.BackColor = Color.White; } break; case 2: if (benfactorName.Text.Trim() == "") { labError.Text = "单位名称不能为空!"; benfactorName.BackColor = Color.FromArgb((int)0xFFE1FF); benfactorName.Focus(); return; } else { benfactorName.BackColor = Color.White; } break; case 3: if (benfactorName.Text.Trim() == "") { labError.Text = "姓名不能为空!"; benfactorName.BackColor = Color.FromArgb((int)0xFFE1FF); benfactorName.Focus(); return; } else { benfactorName.BackColor = Color.White; } break; case 4: if (benfactorName.Text.Trim() == "") { labError.Text = "募捐箱名称不能为空!"; benfactorName.BackColor = Color.FromArgb((int)0xFFE1FF); benfactorName.Focus(); return; } else { benfactorName.BackColor = Color.White; } break; case 5: if (benfactorName.Text.Trim() == "") { labError.Text = "冠名慈善捐助金名称不能为空!"; benfactorName.BackColor = Color.FromArgb((int)0xFFE1FF); benfactorName.Focus(); return; } else { benfactorName.BackColor = Color.White; } break; } //使用正则表达式验证11位手机号是由11位数字组成 Regex mobileReg = new Regex("^[0-9]{11,11}$"); if (TEL.Text.Trim() == "") { labError.Text = "请输入手机号"; TEL.BackColor = Color.FromArgb((int)0xFFE1FF); TEL.Focus(); return; } else if (TEL.Text.Trim().Length != 11) { labError.Text = "11位手机号位数不对"; TEL.BackColor = Color.FromArgb((int)0xFFE1FF); TEL.Focus(); return; } else if (mobileReg.IsMatch(TEL.Text.Trim())) { //验证通过 TEL.BackColor = Color.White; } else { labError.Text = "手机号由11位数字组成"; TEL.BackColor = Color.FromArgb((int)0xFFE1FF); TEL.Focus(); return; } strbranchID = ddlBranch.SelectedValue.ToString(); if (strbranchID == "") { labError.Text = "未找到该经办单位的ID!"; return; } strBenfactorType = benfactorType.SelectedValue; strTEL = TEL.Text.ToString(); strBenfactorID = strbranchID + strBenfactorType + strTEL; try { string strName = Regex.Replace(benfactorName.Text.ToString(), @"\s", ""); if (benfactorType.SelectedValue == "1") //公益组织 { string strgongyi = string.Format("insert into e_benfactor (benfactorID,benfactorName,handlingunitID,benfactorFrom,benfactorType,Contacts,TEL,email,remainMoney) values('{0}','{1}',{2},'{3}',{4},'{5}','{6}','{7}',{8})", strBenfactorID, strName, strbranchID, ddlBranch.SelectedItem.Text.ToString(), strBenfactorType, Contacts.Text.ToString(), strTEL, email.Text.ToString(), "0"); msq.getmysqlcom(strgongyi); if (rdbNaming.Checked) { string strUpdNaming = "update e_benfactor set naming=1,namingSelected='" + ddlNaming.SelectedItem.Text.ToString() + "' where benfactorID='" + strBenfactorID + "'"; msq.getmysqlcom(strUpdNaming); } if (rdbDirect.Checked) { string strUpdDirect = "update e_benfactor set direction=1,recipientsType='" + recipientsType.SelectedItem.Text.ToString() + "',recipientsDescription='" + description.Text.ToString() + "' where benfactorID='" + strBenfactorID + "'"; msq.getmysqlcom(strUpdDirect); } } if (benfactorType.SelectedValue == "2") //单位 { string strfaren = string.Format("insert into e_benfactor (benfactorID,benfactorName,handlingunitID,benfactorFrom,benfactorType,Contacts,TEL,email,remainMoney) values('{0}','{1}',{2},'{3}',{4},'{5}','{6}','{7}',{8})", strBenfactorID, strName, strbranchID, ddlBranch.SelectedItem.Text.ToString(), strBenfactorType, Contacts.Text.ToString(), strTEL, email.Text.ToString(), "0"); msq.getmysqlcom(strfaren); if (rdbNaming.Checked) { string strUpdNaming = "update e_benfactor set naming=1,namingSelected='" + ddlNaming.SelectedItem.Text.ToString() + "',recipientsDescription='" + description.Text.ToString() + "' where benfactorID='" + strBenfactorID + "'"; msq.getmysqlcom(strUpdNaming); } if (rdbDirect.Checked) { string strUpdDirect = "update e_benfactor set direction=1,recipientsType='" + recipientsType.SelectedItem.Text.ToString() + "' where benfactorID='" + strBenfactorID + "'"; msq.getmysqlcom(strUpdDirect); } } if (benfactorType.SelectedValue == "3") //个人 { string strziran = string.Format("insert into e_benfactor (benfactorID,benfactorName,handlingunitID,benfactorFrom,benfactorType,sex,TEL,email,remainMoney) values('{0}','{1}',{2},'{3}',{4},'{5}','{6}','{7}',{8})", strBenfactorID, strName, strbranchID, ddlBranch.SelectedItem.Text.ToString(), strBenfactorType, ddlSex.SelectedItem.Text.ToString(), strTEL, email.Text.ToString(), "0"); msq.getmysqlcom(strziran); if (rdbNaming.Checked) { string strUpdNaming = "update e_benfactor set naming=1,namingSelected='" + ddlNaming.SelectedItem.Text.ToString() + "' where benfactorID='" + strBenfactorID + "'"; msq.getmysqlcom(strUpdNaming); } if (rdbDirect.Checked) { string strUpdDirect = "update e_benfactor set direction=1,recipientsType='" + recipientsType.SelectedItem.Text.ToString() + "',recipientsDescription='" + description.Text.ToString() + "' where benfactorID='" + strBenfactorID + "'"; msq.getmysqlcom(strUpdDirect); } } if (benfactorType.SelectedValue == "4") //募捐箱 { string strmujuan = string.Format("insert into e_benfactor (benfactorID,benfactorName,handlingunitID,benfactorFrom,benfactorType,Contacts,TEL,email,moneyboxNo,remainMoney) values('{0}','{1}',{2},'{3}',{4},'{5}','{6}','{7}','{8}',{9})", strBenfactorID, strName, strbranchID, ddlBranch.SelectedItem.Text.ToString(), strBenfactorType, Contacts.Text.ToString(), strTEL, email.Text.ToString(), moneyboxNo.Text.ToString(), "0"); msq.getmysqlcom(strmujuan); if (rdbNaming.Checked) { string strUpdNaming = "update e_benfactor set naming=1,namingSelected='" + ddlNaming.SelectedItem.Text.ToString() + "' where benfactorID='" + strBenfactorID + "'"; msq.getmysqlcom(strUpdNaming); } if (rdbDirect.Checked) { string strUpdDirect = "update e_benfactor set direction=1,recipientsType='" + recipientsType.SelectedItem.Text.ToString() + "',recipientsDescription='" + description.Text.ToString() + "' where benfactorID='" + strBenfactorID + "'"; msq.getmysqlcom(strUpdDirect); } } if (benfactorType.SelectedValue == "5") //冠名捐助金 { string strgongyi = string.Format("insert into e_benfactor (benfactorID,benfactorName,handlingunitID,benfactorFrom,benfactorType,Contacts,TEL,email,namingAge,deadline,bftRange,bftRemark,remainMoney) values('{0}','{1}',{2},'{3}',{4},'{5}','{6}','{7}',{8},'{9}','{10}','{11}',{12})", strBenfactorID, strName, strbranchID, ddlBranch.SelectedItem.Text.ToString(), strBenfactorType, Contacts.Text.ToString(), strTEL, email.Text.ToString(), ddlAge.Text.ToString(), ViewState["deadline"].ToString(), txtRange.Text.ToString(), txtRemark.Text.ToString(), "0"); msq.getmysqlcom(strgongyi); if (ddlCycle.SelectedValue != "0") { string strRemind = string.Format("insert into e_remind (benfactorID,cycle,flag) values ('{0}',{1},{2})", strBenfactorID, ddlCycle.SelectedValue.ToString(), ddlAge.SelectedValue.ToString()); msq.getmysqlcom(strRemind); } } NLogTest nlog = new NLogTest(); string sss = "添加了捐赠人:" + strName; nlog.WriteLog(Session["UserName"].ToString(), sss); tbReset(); labError.Text = "添加成功!"; //loadPage(); //foreach (System.Web.UI.Control stl in this.Form.Controls) //{ // if (stl is System.Web.UI.WebControls.TextBox) // { // TextBox tb = (TextBox)stl; // tb.Text = ""; // } //} } catch { labError.Text = "添加失败,手机号重复!"; } }
protected void mod_Click(object sender, EventArgs e) { //int flag = 1; if (!CheckBox1.Checked && !CheckBox2.Checked && !CheckBox3.Checked && !CheckBox4.Checked && !CheckBox5.Checked && !CheckBox6.Checked && !CheckBox7.Checked) { //LabelError.Text = "请选择受助类型"; HttpContext.Current.Response.Write("<script>alert('请选择受助类型');</script>"); return; //flag = 0; } else { //LabelError.Text = ""; if (recipientsADD.Text.Trim() == "") { //LabelError.Text = "未填写受助人户籍"; HttpContext.Current.Response.Write("<script>alert('未填写受助人户籍');</script>"); recipientsADD.BackColor = Color.FromArgb((int)0xFFE1FF); recipientsADD.Focus(); return; //flag = 0; } else { recipientsADD.BackColor = Color.White; } if (recipientsName.Text.Trim() == "") { //LabelError.Text = "未填写受助人姓名"; HttpContext.Current.Response.Write("<script>alert('未填写受助人姓名');</script>"); recipientsName.BackColor = Color.FromArgb((int)0xFFE1FF); recipientsName.Focus(); return; //flag = 0; } else { recipientsName.BackColor = Color.White; } //验证第二代身份证,共18位 Regex pidReg = new Regex("(^\\d{18}$)|(^\\d{17}(\\d|X)$)"); if (recipientsPIdcard.Text.Trim() == "") { //LabelError.Text = "未填写身份证号"; HttpContext.Current.Response.Write("<script>alert('未填写身份证号');</script>"); recipientsPIdcard.BackColor = Color.FromArgb((int)0xFFE1FF); recipientsPIdcard.Focus(); return; //flag = 0; } else { if (pidReg.IsMatch(recipientsPIdcard.Text.Trim())) { recipientsPIdcard.BackColor = Color.White;//验证通过 } else { HttpContext.Current.Response.Write("<script>alert('身份证号格式不对,第二代身份证由18位组成(最后一位的X为大写)');</script>"); recipientsPIdcard.BackColor = Color.FromArgb((int)0xFFE1FF); recipientsPIdcard.Focus(); return; } } //if (recipientsPIdcard.Text.Length <= 0) //{ // //LabelError.Text = "未填写身份证号"; // HttpContext.Current.Response.Write("<script>alert('未填写身份证号');</script>"); // return; // //flag = 0; //} if (recipientsADDnow.Text.Trim() == "") { //LabelError.Text = "未填写现住址"; HttpContext.Current.Response.Write("<script>alert('未填写现住址');</script>"); recipientsADDnow.BackColor = Color.FromArgb((int)0xFFE1FF); recipientsADDnow.Focus(); return; //flag = 0; } else { recipientsADDnow.BackColor = Color.White; } if (telphoneADD.Text.Trim() == "") { //LabelError.Text = "未填写联系电话"; HttpContext.Current.Response.Write("<script>alert('未填写联系电话');</script>"); telphoneADD.BackColor = Color.FromArgb((int)0xFFE1FF); telphoneADD.Focus(); return; //flag = 0; } else { telphoneADD.BackColor = Color.White; } if (workplace.Text.Trim() == "") { HttpContext.Current.Response.Write("<script>alert('未填写工作单位');</script>"); workplace.BackColor = Color.FromArgb((int)0xFFE1FF); workplace.Focus(); return; } else { workplace.BackColor = Color.White; } if (arrIncome.Text.Trim() == "") { //LabelError.Text = "未填写平均月收入"; HttpContext.Current.Response.Write("<script>alert('未填写平均月收入');</script>"); arrIncome.BackColor = Color.FromArgb((int)0xFFE1FF); arrIncome.Focus(); return; //flag = 0; } else { arrIncome.BackColor = Color.White; } if (CheckBox2.Checked) { if (illness.Text.Trim() == "") { //LabelError.Text = "未填写大病种类"; HttpContext.Current.Response.Write("<script>alert('未填写大病种类');</script>"); illness.BackColor = Color.FromArgb((int)0xFFE1FF); illness.Focus(); return; //flag = 0; } else { illness.BackColor = Color.White; } if (illtime.Text.Trim() == "") { //LabelError.Text = "未填写就诊时间"; HttpContext.Current.Response.Write("<script>alert('未填写就诊时间');</script>"); illtime.BackColor = Color.FromArgb((int)0xFFE1FF); illtime.Focus(); return; //flag = 0; } else { illtime.BackColor = Color.White; } if (illpay.Text.Trim() == "") { //LabelError.Text = "未填写花费数额"; HttpContext.Current.Response.Write("<script>alert('未填写花费数额');</script>"); illpay.BackColor = Color.FromArgb((int)0xFFE1FF); illpay.Focus(); return; //flag = 0; } else { illpay.BackColor = Color.White; } } if (CheckBox1.Checked) { if (studySchool.Text.Trim() == "") { //LabelError.Text = "未填写就读学校"; HttpContext.Current.Response.Write("<script>alert('未填写就读学校');</script>"); studySchool.BackColor = Color.FromArgb((int)0xFFE1FF); studySchool.Focus(); return; //flag = 0; } else { studySchool.BackColor = Color.White; } if (studyGrade.Text.Trim() == "") { //LabelError.Text = "未填写就读年级"; HttpContext.Current.Response.Write("<script>alert('未填写就读年级');</script>"); studyGrade.BackColor = Color.FromArgb((int)0xFFE1FF); studyGrade.Focus(); return; //flag = 0; } else { studyGrade.BackColor = Color.White; } if (guardianName.Text.Trim() == "") { //LabelError.Text = "未填写与被监护人姓名"; HttpContext.Current.Response.Write("<script>alert('未填写与被监护人姓名');</script>"); guardianName.BackColor = Color.FromArgb((int)0xFFE1FF); guardianName.Focus(); return; //flag = 0; } else { guardianName.BackColor = Color.White; } if (guardianGuanxi.Text.Trim() == "") { //LabelError.Text = "未填写与被监护人关系"; HttpContext.Current.Response.Write("<script>alert('未填写与被监护人关系');</script>"); guardianGuanxi.BackColor = Color.FromArgb((int)0xFFE1FF); guardianGuanxi.Focus(); return; //flag = 0; } else { guardianGuanxi.BackColor = Color.White; } if (guardianTelADD.Text.Trim() == "") { //LabelError.Text = "未填写监护人电话"; HttpContext.Current.Response.Write("<script>alert('未填写监护人电话');</script>"); guardianTelADD.BackColor = Color.FromArgb((int)0xFFE1FF); guardianTelADD.Focus(); return; //flag = 0; } else { guardianTelADD.BackColor = Color.White; } } if (CheckBox3.Checked) { if (canjijibie.Text.Trim() == "") { //LabelError.Text = "未填写残疾级别"; HttpContext.Current.Response.Write("<script>alert('未填写残疾级别');</script>"); canjijibie.BackColor = Color.FromArgb((int)0xFFE1FF); canjijibie.Focus(); return; //flag = 0; } else { canjijibie.BackColor = Color.White; } if (canjileibie.Text.Trim() == "") { //LabelError.Text = "未填写残疾类别"; HttpContext.Current.Response.Write("<script>alert('未填写残疾类别');</script>"); canjileibie.BackColor = Color.FromArgb((int)0xFFE1FF); canjileibie.Focus(); return; //flag = 0; } else { canjileibie.BackColor = Color.White; } } if (CheckBox5.Checked) { if (shiDu.Text == "是") { if (sonName.Text.Trim() == "") { //LabelError.Text = "未填写子女姓名"; HttpContext.Current.Response.Write("<script>alert('未填写子女姓名');</script>"); sonName.BackColor = Color.FromArgb((int)0xFFE1FF); sonName.Focus(); return; //flag = 0; } else { sonName.BackColor = Color.White; } if (deathReason.Text.Trim() == "") { //LabelError.Text = "未填写死亡原因"; HttpContext.Current.Response.Write("<script>alert('未填写死亡原因');</script>"); deathReason.BackColor = Color.FromArgb((int)0xFFE1FF); deathReason.Focus(); return; //flag = 0; } else { deathReason.BackColor = Color.White; } } } if (CheckBox6.Checked) { if (army.Text.Trim() == "") { HttpContext.Current.Response.Write("<script>alert('未填写部队名称');</script>"); army.BackColor = Color.FromArgb((int)0xFFE1FF); army.Focus(); return; } else { army.BackColor = Color.White; } if (title.Text.Trim() == "") { HttpContext.Current.Response.Write("<script>alert('未填写职位');</script>"); title.BackColor = Color.FromArgb((int)0xFFE1FF); title.Focus(); return; } else { title.BackColor = Color.White; } } if (CheckBox7.Checked) { if (disaster.Text.Trim() == "") { HttpContext.Current.Response.Write("<script>alert('未填写灾害名称');</script>"); disaster.BackColor = Color.FromArgb((int)0xFFE1FF); disaster.Focus(); return; } else { disaster.BackColor = Color.White; } } #region //if(famIncome1.Text.Length<=0) //{ // LabelError.Text = "未填写成员收入1"; // flag = 0; //} //if(famWork1.Text.Length<=0) //{ // LabelError.Text = "未填写成员职业1"; // flag = 0; //} //if(famTel1.Text.Length <= 0) //{ // LabelError.Text = "未填写成员联系方式1"; // flag = 0; //} ////if (famWorkplace1.Text.Length <= 0) ////{ //// LabelError.Text = "未填写成员工作单位1"; ////} //if (famRelation1.Text.Length <= 0) //{ // LabelError.Text = "未填写与本人关系1"; // flag = 0; //} //if (famName1.Text.Length <= 0) //{ // LabelError.Text = "未填写家庭成员姓名1"; // flag = 0; //} #endregion } //if(flag==1)//信息填写完 //{ #region //数据入库 string strName = Regex.Replace(recipientsName.Text.ToString(), @"\s", ""); string str113 = string.Format("update e_recipients set benfactorFrom='{0}',recipientsADD='{1}',recipientsName='{2}',sex='{3}',recipientsPIdcard='{4}',recipientsADDnow='{5}',incomlowID='{6}',telphoneADD='{7}',workplace='{8}',famName1='{9}',famRelation1='{10}',famWorkplace1='{11}',famTel1='{12}',famWork1='{13}',famIncome1='{14}',famName2='{15}',famRelation2='{16}',famWorkplace2='{17}',famTel2='{18}',famWork2='{19}',famIncome2='{20}',famName3='{21}',famRelation3='{22}',famWorkplace3='{23}',famTel3='{24}',famWork3='{25}',famIncome3='{26}',famName4='{27}',famRelation4='{28}',famWorkplace4='{29}',famTel4='{30}',famWork4='{31}',famIncome4='{32}',arrIncome='{33}',marryNow='{34}',canjijibie='{35}',canjileibie='{36}',shuoming3='{37}',illness='{38}',illtime='{39}',illpay='{40}',shuoming1='{41}',timeDis='{42}',shiDu='{43}',sonName='{44}',deathReason='{45}',shuoming5='{46}',shiNeng='{47}',shuoming4='{48}',studySchool='{49}',studyGrade='{50}',guardianName='{51}',guardianGuanxi='{52}',guardianTelADD='{53}',shuoming2='{54}',reason='{55}',canID='{57}',officerID='{58}',army='{59}',title='{60}',disaster='{61}' where recipientsID='{56}'", benfactorFrom.SelectedValue.Trim(), recipientsADD.Text.Trim(), strName, sex.Text.Trim(), recipientsPIdcard.Text.Trim(), recipientsADDnow.Text.Trim(), incomlowID.Text.Trim(), telphoneADD.Text.Trim(), workplace.Text.Trim(), famName1.Text.Trim(), famRelation1.Text.Trim(), famWorkplace1.Text.Trim(), famTel1.Text.Trim(), famWork1.Text.Trim(), famIncome1.Text.Trim(), famName2.Text.Trim(), famRelation2.Text.Trim(), famWorkplace2.Text.Trim(), famTel2.Text.Trim(), famWork2.Text.Trim(), famIncome2.Text.Trim(), famName3.Text.Trim(), famRelation3.Text.Trim(), famWorkplace3.Text.Trim(), famTel3.Text.Trim(), famWork3.Text.Trim(), famIncome3.Text.Trim(), famName4.Text.Trim(), famRelation4.Text.Trim(), famWorkplace4.Text.Trim(), famTel4.Text.Trim(), famWork4.Text.Trim(), famIncome4.Text.Trim(), arrIncome.Text.Trim(), marryNow.Text.Trim(), canjijibie.Text.Trim(), canjileibie.Text.Trim(), shuoming3.Text.Trim(), illness.Text.Trim(), illtime.Text.Trim(), illpay.Text.Trim(), shuoming1.Text.Trim(), timeDis.Text.Trim(), shiDu.Text.Trim(), sonName.Text.Trim(), deathReason.Text.Trim(), shuoming5.Text.Trim(), shiNeng.Text.Trim(), shuoming4.Text.Trim(), studySchool.Text.Trim(), studyGrade.Text.Trim(), guardianName.Text.Trim(), guardianGuanxi.Text.Trim(), guardianTelADD.Text.Trim(), shuoming2.Text.Trim(), reason.Text.Trim(), ViewState["IDNow"].ToString(), canjiID.Text.Trim(), tbOfficerID.Text.Trim(), army.Text.Trim(), title.Text.Trim(), disaster.Text.Trim()); int res = -1; try { res = msq.getmysqlcom(str113); } catch (MySqlException ex) { HttpContext.Current.Response.Write("<script>alert('身份证号重复了');</script>"); //throw ex; return; } if (CheckBox1.Checked) { string str114 = string.Format("update e_recipients set isstu=1 where recipientsID='{0}'", ViewState["IDNow"].ToString()); msq.getmysqlcom(str114); } else { string str1141 = string.Format("update e_recipients set isstu=0 where recipientsID='{0}'", ViewState["IDNow"].ToString()); msq.getmysqlcom(str1141); } if (CheckBox2.Checked) { string str115 = string.Format("update e_recipients set isdoc=1 where recipientsID='{0}'", ViewState["IDNow"].ToString()); msq.getmysqlcom(str115); } else { string str1151 = string.Format("update e_recipients set isdoc=0 where recipientsID='{0}'", ViewState["IDNow"].ToString()); msq.getmysqlcom(str1151); } if (CheckBox3.Checked) { string str116 = string.Format("update e_recipients set iscan=1 where recipientsID='{0}'", ViewState["IDNow"].ToString()); msq.getmysqlcom(str116); } else { string str1161 = string.Format("update e_recipients set iscan=0 where recipientsID='{0}'", ViewState["IDNow"].ToString()); msq.getmysqlcom(str1161); } if (CheckBox4.Checked) { string str117 = string.Format("update e_recipients set isold=1 where recipientsID='{0}'", ViewState["IDNow"].ToString()); msq.getmysqlcom(str117); } else { string str1171 = string.Format("update e_recipients set isold=0 where recipientsID='{0}'", ViewState["IDNow"].ToString()); msq.getmysqlcom(str1171); } if (CheckBox5.Checked) { string str118 = string.Format("update e_recipients set iskun=1 where recipientsID='{0}'", ViewState["IDNow"].ToString()); msq.getmysqlcom(str118); } else { string str1181 = string.Format("update e_recipients set iskun=0 where recipientsID='{0}'", ViewState["IDNow"].ToString()); msq.getmysqlcom(str1181); } if (CheckBox6.Checked) { msq.getmysqlcom(string.Format("update e_recipients set isyong=1 where recipientsID='{0}'", ViewState["IDNow"].ToString())); } else { msq.getmysqlcom(string.Format("update e_recipients set isyong=0 where recipientsID='{0}'", ViewState["IDNow"].ToString())); } if (CheckBox7.Checked) { msq.getmysqlcom(string.Format("update e_recipients set isdst=1 where recipientsID='{0}'", ViewState["IDNow"].ToString())); } else { msq.getmysqlcom(string.Format("update e_recipients set isdst=0 where recipientsID='{0}'", ViewState["IDNow"].ToString())); } if (res > 0) { NLogTest nlog = new NLogTest(); string sss = "修改了受助人:" + strName + "的信息"; nlog.WriteLog(Session["UserName"].ToString(), sss); HttpContext.Current.Response.Write("<script>alert('受助人信息修改成功');</script>"); } else { HttpContext.Current.Response.Write("<script>alert('受助人信息修改失败');</script>"); } ////数据入库之后的操作 //foreach (System.Web.UI.Control stl in this.Form.Controls) //{ // if (stl is System.Web.UI.WebControls.TextBox) // { // TextBox tb = (TextBox)stl; // tb.Text = ""; // } //} //CheckBox1.Checked = CheckBox2.Checked = CheckBox3.Checked = CheckBox4.Checked = CheckBox5.Checked = false; //CheckBox1.Enabled = CheckBox4.Enabled = true; //shiNeng.Text = shiDu.Text = "否"; //mask(); #endregion //} }
//protected void ddlAge_SelectedIndexChanged(object sender, EventArgs e) //{//更改截止日期 // deadline.Text = Convert.ToDateTime(deadline.Text.ToString()).AddYears(Convert.ToInt16(ddlAge.SelectedValue) - Convert.ToInt16(ViewState["namingAge"].ToString())).ToString(); // ViewState["namingAge"] = ddlAge.SelectedValue;//更改年限 //} //protected void benfactorType_SelectedIndexChanged(object sender, EventArgs e) //{ // if (benfactorType.SelectedValue == "1") // { // Lb11.Text = "公益组织名称:"; // trSex.Visible = false; // trAge.Visible = false; // trContact.Visible = true; // trMoneyboxNo.Visible = false; // trDeadline.Visible = false; // //定向 // tbDirect.Visible = true; // trRcpType.Visible = false; // rdbDirect.Checked = rdbUndirect.Checked = false; // //冠名 // tbNaming.Visible = true; // trFundName.Visible = false; // rdbNaming.Checked = rdbUnNaming.Checked = false; // return; // } // if (benfactorType.SelectedValue == "2") // { // Lb11.Text = "单位名称:"; // trSex.Visible = false; // trAge.Visible = false; // trContact.Visible = true; // trMoneyboxNo.Visible = false; // trDeadline.Visible = false; // tbDirect.Visible = true; // trRcpType.Visible = false; // rdbDirect.Checked = rdbUndirect.Checked = false; // tbNaming.Visible = true; // trFundName.Visible = false; // rdbNaming.Checked = rdbUnNaming.Checked = false; // return; // } // if (benfactorType.SelectedValue == "3") // { // Lb11.Text = "姓名:"; // trSex.Visible = true; // trAge.Visible = false; // trContact.Visible = false; // trMoneyboxNo.Visible = false; // trDeadline.Visible = false; // tbDirect.Visible = true; // trRcpType.Visible = false; // rdbDirect.Checked = rdbUndirect.Checked = false; // tbNaming.Visible = true; // trFundName.Visible = false; // rdbNaming.Checked = rdbUnNaming.Checked = false; // return; // } // if (benfactorType.SelectedValue == "4") // { // Lb11.Text = "募捐箱名称:"; // trSex.Visible = false; // trAge.Visible = false; // trContact.Visible = true; // trMoneyboxNo.Visible = true; // trDeadline.Visible = false; // tbDirect.Visible = true; // trRcpType.Visible = false; // rdbDirect.Checked = rdbUndirect.Checked = false; // tbNaming.Visible = true; // trFundName.Visible = false; // rdbNaming.Checked = rdbUnNaming.Checked = false; // return; // } // if (benfactorType.SelectedValue == "5") // { // Lb11.Text = "冠名慈善捐助金名称:"; // trSex.Visible = false; // trAge.Visible = true; // trContact.Visible = true; // trMoneyboxNo.Visible = false; // trDeadline.Visible = true; // tbDirect.Visible = false; // tbNaming.Visible = false; // return; // } //} protected void Btinput_Click(object sender, EventArgs e)//提交修改 { //经办单位ID //strBranchID //捐助人类型 //strBenfactorType //手机号 //strTEL //捐赠人ID //ViewState["IDNow"].ToString() //以上是不变的 try { if (benfactorType.SelectedValue == "1")//公益组织 { string strgongyi = string.Format("update e_benfactor set Contacts='{0}',email='{1}',TEL='{3}' where benfactorID='{2}'", Contacts.Text.ToString(), email.Text.ToString(), ViewState["IDNow"].ToString(), TEL.Text.Trim()); msq.getmysqlcom(strgongyi); if (rdbNaming.Checked) { string strUpdNaming = "update e_benfactor set naming=1,namingSelected='" + ddlNaming.SelectedItem.Text.ToString() + "' where benfactorID='" + ViewState["IDNow"].ToString() + "'"; msq.getmysqlcom(strUpdNaming); } if (rdbDirect.Checked) { string strUpdDirect = "update e_benfactor set direction=1,recipientsType='" + recipientsType.SelectedItem.Text.ToString() + "' where benfactorID='" + ViewState["IDNow"].ToString() + "'"; msq.getmysqlcom(strUpdDirect); } labError.Text = "修改成功"; } if (benfactorType.SelectedValue == "2")//单位 { string strfaren = string.Format("update e_benfactor set Contacts='{0}',email='{1}',TEL='{3}' where benfactorID='{2}'", Contacts.Text.ToString(), email.Text.ToString(), ViewState["IDNow"].ToString(), TEL.Text.Trim()); msq.getmysqlcom(strfaren); if (rdbNaming.Checked) { string strUpdNaming = "update e_benfactor set naming=1,namingSelected='" + ddlNaming.SelectedItem.Text.ToString() + "' where benfactorID='" + ViewState["IDNow"].ToString() + "'"; msq.getmysqlcom(strUpdNaming); } if (rdbDirect.Checked) { string strUpdDirect = "update e_benfactor set direction=1,recipientsType='" + recipientsType.SelectedItem.Text.ToString() + "' where benfactorID='" + ViewState["IDNow"].ToString() + "'"; msq.getmysqlcom(strUpdDirect); } labError.Text = "修改成功"; } if (benfactorType.SelectedValue == "3")//个人 { string strziran = string.Format("update e_benfactor set sex='{0}',email='{1}',TEL='{3}' where benfactorID='{2}'", ddlSex.SelectedValue.ToString(), email.Text.ToString(), ViewState["IDNow"].ToString(), TEL.Text.Trim()); msq.getmysqlcom(strziran); if (rdbNaming.Checked) { string strUpdNaming = "update e_benfactor set naming=1,namingSelected='" + ddlNaming.SelectedItem.Text.ToString() + "' where benfactorID='" + ViewState["IDNow"].ToString() + "'"; msq.getmysqlcom(strUpdNaming); } if (rdbDirect.Checked) { string strUpdDirect = "update e_benfactor set direction=1,recipientsType='" + recipientsType.SelectedItem.Text.ToString() + "' where benfactorID='" + ViewState["IDNow"].ToString() + "'"; msq.getmysqlcom(strUpdDirect); } labError.Text = "修改成功"; } if (benfactorType.SelectedValue == "4")//募捐箱 { string strmujuan = string.Format("update e_benfactor set Contacts='{0}',email='{1}',moneyboxNo='{2}',TEL='{4}' where benfactorID='{3}'", Contacts.Text.ToString(), email.Text.ToString(), moneyboxNo.Text.ToString(), ViewState["IDNow"].ToString(), TEL.Text.Trim()); msq.getmysqlcom(strmujuan); if (rdbNaming.Checked) { string strUpdNaming = "update e_benfactor set naming=1,namingSelected='" + ddlNaming.SelectedItem.Text.ToString() + "' where benfactorID='" + ViewState["IDNow"].ToString() + "'"; msq.getmysqlcom(strUpdNaming); } if (rdbDirect.Checked) { string strUpdDirect = "update e_benfactor set direction=1,recipientsType='" + recipientsType.SelectedItem.Text.ToString() + "' where benfactorID='" + ViewState["IDNow"].ToString() + "'"; msq.getmysqlcom(strUpdDirect); } labError.Text = "修改成功"; } if (benfactorType.SelectedValue == "5") //冠名慈善捐助金 { //更改年限 string strgongyi = string.Format("update e_benfactor set Contacts='{0}',email='{1}',namingAge='{2}',deadline='{3}',TEL='{5}' where benfactorID='{4}'", Contacts.Text.ToString(), email.Text.ToString(), lblAge.Text.Trim(), deadline.Text.ToString(), ViewState["IDNow"].ToString(), TEL.Text.Trim()); msq.getmysqlcom(strgongyi); labError.Text = "修改成功"; } NLogTest nlog = new NLogTest(); string sss = "修改了捐赠人:" + benfactorName.Text.Trim() + "的信息"; nlog.WriteLog(Session["UserName"].ToString(), sss); } catch { labError.Text = "添加失败"; } }
protected void btnImport_Click(object sender, EventArgs e) { lblError.Text = ""; if (lblID.Text.Trim() == "") { lblError.Text = "请输入项目ID"; return; } int idNum = 0; string selectIdString = "select count(*) as countNum from e_project where projectID='" + lblID.Text.Trim() + "'"; MySqlDataReader mysqlreadID = msq.getmysqlread(selectIdString); while (mysqlreadID.Read()) { idNum = mysqlreadID.GetInt32("countNum"); } if (idNum == 0) { lblError.Text = "请输入正确的项目ID"; return; } if (FileUpload1.HasFile == false)//HasFile用来检查FileUpload是否有指定文件 { Response.Write("<script>alert('请选择Excel文件')</script> "); return; //当无文件时,返回 } string IsXlsx = System.IO.Path.GetExtension(FileUpload1.FileName).ToString().ToLower(); //System.IO.Path.GetExtension获得文件的扩展名 if (IsXlsx != ".xlsx" && IsXlsx != ".xls") { Response.Write("<script>alert('只可以选择Excel文件')</script>"); return; //当选择的不是Excel文件时,返回 } string filename = FileUpload1.FileName; //获取Excle文件名 DateTime日期函数 string savePath = Server.MapPath(("selectRecipients\\") + filename); //Server.MapPath 获得虚拟服务器相对路径 //检查文件是否存在 if (File.Exists(savePath)) { Response.Write("<script>alert('使用过的Excel文件')</script>"); return; } else { FileUpload1.SaveAs(savePath); //SaveAs 将上传的文件内容保存在服务器上 } DataSet ds = ExcelSqlConnection(savePath, filename); //调用自定义方法 DataRow[] dr = ds.Tables[0].Select(); //定义一个DataRow数组 int rowsnum = ds.Tables[0].Rows.Count; if (rowsnum == 0) { Response.Write("<script>alert('Excel表为空表,无数据!')</script>"); //当Excel表为空时,对用户进行提示 } else { //Stopwatch sw = new Stopwatch(); //sw.Start(); List <string> SQLStringList = new List <string>(); string strSelectID = "select recipientsID from e_recipients where recipientsPIdcard="; MySqlDataReader mysqlread; //while (mysqlread.Read()) for (int i = 0; i < dr.Length; i++) { //前面除了你需要在建立一个“selectRecipients”的文件夹外,其他的都不用管了,你只需要通过下面的方式获取Excel的值,然后再将这些值用你的方式去插入到数据库里面 string strIdCard = dr[i]["身份证号"].ToString(); string strReadId = strSelectID + "'" + strIdCard + "'"; mysqlread = msq.getmysqlread(strReadId); string strRcptId = ""; while (mysqlread.Read()) { strRcptId = mysqlread.GetString(0); } string str113 = string.Format("insert ignore into e_pr (projectID,recipientID,request) values ({0},{1},'{2}')", lblID.Text.Trim(), strRcptId, dr[i]["救助申请"].ToString()); SQLStringList.Add(str113); } ExecuteSqlTran(SQLStringList); //sw.Stop(); NLogTest nlog = new NLogTest(); string sss = "批量选择了受助人:" + filename; nlog.WriteLog(Session["UserName"].ToString(), sss); Response.Write("<script>alert('Excle表导入成功!');</script>"); //TimeSpan timeSpan = sw.Elapsed; } }