/// <summary> /// 增加一条民非企业申请 /// </summary> /// <param name="AppCom">一个民非企业申请的对象</param> /// <returns>添加后那条记录的主键ID</returns> public static int AddAppCom(Approve_Company AppCom) { int iExecute = 0; try { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into Approve_Company11 ("); strSql.Append("UserName,Tel,CompanyName,AppType,AppStatus,Remark,AppTime,FilePath,QueryCode"); strSql.Append(") values("); strSql.Append("@UserName,@Tel,@CompanyName,@AppType,@AppStatus,@Remark,@AppTime,@FilePath,@QueryCode"); strSql.Append(");select @@IDENTITY"); SqlParameter[] para = new SqlParameter[] { new SqlParameter("@UserName",SqlDbType.NVarChar,50), new SqlParameter("@Tel",SqlDbType.NVarChar,20), new SqlParameter("@CompanyName",SqlDbType.NVarChar,50), new SqlParameter("@AppType",SqlDbType.NVarChar,20), new SqlParameter("@AppStatus",SqlDbType.NVarChar,50), new SqlParameter("@Remark",SqlDbType.Text), new SqlParameter("@AppTime",SqlDbType.DateTime), new SqlParameter("@FilePath",SqlDbType.Text), new SqlParameter("@QueryCode",SqlDbType.NVarChar,10), }; para[0].Value = AppCom.UserName; para[1].Value = AppCom.Tel; para[2].Value = AppCom.CompanyName; para[3].Value = AppCom.AppType; para[4].Value = AppCom.AppStatus; para[5].Value = AppCom.Remark; para[6].Value = AppCom.AppTime; para[7].Value = AppCom.FilePath; para[8].Value = AppCom.QueryCode; object obj = DbHelperSQL.GetSingle(strSql.ToString(), para); if (obj != null) { iExecute = Convert.ToInt32(obj); } } catch (Exception e) { Log4Net.LogWrite("err", "Controler\\AddAppCom" + e.Message); } return iExecute; }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { string code = Request.QueryString["code"]; Approve_Company AppCom = new Approve_Company(); try { AppCom = Ctrl_App_Com.FindAppComByQueryCode(code); if (AppCom != null) { lbUserName.Text = AppCom.UserName; lbCompany.Text = AppCom.CompanyName; lbType.Text = AppCom.AppType; lbStatus.Text = AppCom.AppStatus; lbCode.Text = AppCom.QueryCode; lbRemark.Text = AppCom.Remark; lbAppTime.Text = AppCom.AppTime.ToString("yyyy-MM-dd H:m:s"); if (AppCom.AppStatus == "未审核") { lbCheckTime.Text = " "; } else { lbCheckTime.Text = AppCom.CheckTime.ToString("yyyy-MM-dd H:m:s"); } } else { MessageBox.Show(this, "查询异常!"); return; } } catch (Exception) { MessageBox.Show(this, "查询异常!"); throw; } } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { int id = Convert.ToInt32(Request.QueryString["ID"]); AppCom = new Approve_Company(); try { AppCom = Ctrl_App_Com.FindAppComByID(id); if (AppCom != null) { lbUserName.Text = AppCom.UserName; lbTel.Text = AppCom.Tel; lbCompany.Text = AppCom.CompanyName; lbType.Text = AppCom.AppType; lbStatus.Text = AppCom.AppStatus; lbRemark.Text = AppCom.Remark; lbAppTime.Text = AppCom.AppTime.ToString("yyyy-MM-dd H:m:s"); txtRemark.Text = AppCom.Remark; if (AppCom.AppStatus == "未审核") { lbCheckTime.Text = " "; } else { lbCheckTime.Text = AppCom.CheckTime.ToString("yyyy-MM-dd H:m:s"); btnSubmit.Enabled = false; } } else { MessageBox.Show(this, "查询异常!"); return; } } catch (Exception) { MessageBox.Show(this, "查询异常!"); throw; } } }
/// <summary> /// 更新民非企业申请信息 /// </summary> /// <param name="AppCom"></param> /// <returns></returns> public static int UpdateAppCom(Approve_Company AppCom) { int iExecute = 0; try { string sqlStr = ""; sqlStr += "UPDATE Approve_Company11 SET "; sqlStr += "AppStatus=@AppStatus,Remark=@Remark,CheckTime=@CheckTime"; sqlStr += " where ID=@ID"; SqlParameter[] para = new SqlParameter[] { new SqlParameter("@AppStatus",SqlDbType.NVarChar,20), new SqlParameter("@Remark",SqlDbType.Text), new SqlParameter("@CheckTime",SqlDbType.DateTime), new SqlParameter("@ID",SqlDbType.Int), }; para[0].Value = AppCom.AppStatus; para[1].Value = AppCom.Remark; para[2].Value = AppCom.CheckTime; para[3].Value = AppCom.ID; object obj = DbHelperSQL.ExecuteSql(sqlStr, para); if (obj != null) { iExecute = Convert.ToInt32(obj); } } catch (Exception e) { Log4Net.LogWrite("err", "Controler\\UpdateAppCom" + e.Message); } return iExecute; }
/// <summary> /// 根据查询码查询申请记录 /// </summary> /// <param name="code">查询码</param> /// <returns>一条申请记录或null</returns> public static Approve_Company FindAppComByQueryCode(string code) { Approve_Company AppCom = new Approve_Company(); string sql = null; try { sql = "SELECT * FROM Approve_Company11 WHERE QueryCode=@QueryCode"; SqlParameter para = new SqlParameter("@QueryCode", SqlDbType.NVarChar, 10); para.Value = code; DataSet ds = null; ds = DbHelperSQL.Query(sql, para); if (ds != null) { DataTable dt = ds.Tables[0]; DataRow dr = dt.Rows[0]; AppCom.ID = Convert.ToInt32(dr["ID"]); AppCom.UserName = dr["UserName"].ToString(); AppCom.Tel = dr["Tel"].ToString(); AppCom.CompanyName = dr["CompanyName"].ToString(); AppCom.AppType = dr["AppType"].ToString(); AppCom.AppStatus = dr["AppStatus"].ToString(); AppCom.Remark = dr["Remark"].ToString(); AppCom.AppTime = Convert.ToDateTime(dr["AppTime"]); if (dr["CheckTime"] != DBNull.Value) { AppCom.CheckTime = Convert.ToDateTime(dr["CheckTime"]); } AppCom.FilePath = dr["FilePath"].ToString(); AppCom.QueryCode = code; } else { AppCom = null; } } catch (Exception e) { Log4Net.LogWrite("err", "Controler\\FindYouFu_TypeById" + e.Message); } return AppCom; }
protected void btnSubUpload_Click(object sender, EventArgs e) { Approve_Company AppCom = new Approve_Company(); string userName = txtUserName.Text.Trim(); string tel = txtTel.Text.Trim(); string companyName = txtCompany.Text.Trim(); if (string.IsNullOrEmpty(userName)) { MessageBox.Show(this, "请填写用户名!"); return; } if (string.IsNullOrEmpty(tel)) { MessageBox.Show(this, "请填写电话!"); return; } if (string.IsNullOrEmpty(companyName)) { MessageBox.Show(this, "请填写公司名!"); return; } int kindIndex = ddlApplyKind.SelectedIndex; string kind = ""; switch (kindIndex) { case 0: kind = "变更"; break; case 1: kind = "登记"; break; case 2: kind = "注销"; break; } if (fuApplyFile.HasFile) { string extentionName = System.IO.Path.GetExtension(fuApplyFile.FileName); if (extentionName == ".doc" || extentionName == ".docx") { string time = DateTime.Now.ToString("yyyyMMyyHms"); lbUploadWarning.Text = "正在上传请稍后。。。"; fuApplyFile.SaveAs(Server.MapPath("~/Uploads/" + kind + "/") + userName + time + extentionName); lbUploadWarning.Text = "上传成功!"; string code = Med_Ass.GenerateRandomNumber(6); AppCom.UserName = userName; AppCom.Tel = tel; AppCom.CompanyName = companyName; AppCom.AppType = kind; AppCom.FilePath = kind + "/" + userName + time + extentionName; AppCom.AppStatus = "未审核"; AppCom.AppTime = DateTime.Now; AppCom.QueryCode = code; int n = Ctrl_App_Com.AddAppCom(AppCom); if (n > 0) { MessageBox.Show(this, " 插入成功!"); Response.Redirect("Result.aspx?code=" + code); } else { MessageBox.Show(this, " 插入失败,请重试!"); return; } } else { MessageBox.Show(this, " 上传文档格式错误,只支持(doc docx)格式的文件"); return; } } else { lbUploadWarning.Text = "请选择要上传的文件"; } }