/// <summary> /// 修改公司信息 /// </summary> /// <param name="Model">Company实体</param> /// <returns>更新是否成功</returns> public static bool ModifyCompany(CompanyModel Model) { if (Model == null) return false; if (Model.ModifiedUserID == null) Model.ModifiedUserID = ((UserInfoUtil)SessionUtil.Session["UserInfo"]).UserID; try { return CompanyDBHelper.ModifyCompany(Model); } catch (System.Exception ex) { throw ex; } }
/// <summary> /// 修改公司信息 /// </summary> /// <param name="Model">Company实体</param> /// <returns></returns> public static bool ModifyCompany(CompanyModel Model) { StringBuilder sql = new StringBuilder(); sql.AppendLine("update pubdba.company set"); sql.AppendLine("[CompanyNameCn] = @CompanyNameCn,"); sql.AppendLine("[CompanyNameEn] = @CompanyNameEn,"); sql.AppendLine("[ProvCD] = @ProvCD,[CityCD] = @CityCD,"); sql.AppendLine("[Addr] = @Addr,[Contact] = @Contact,"); sql.AppendLine("[Tel] = @Tel,[Fax] = @Fax,"); sql.AppendLine("[Post] = @Post,[HomePage] = @HomePage,"); sql.AppendLine("[Email] = @Email,[QQ] = @QQ,"); sql.AppendLine("[MSN] = @MSN,[IM] = @IM,"); sql.AppendLine("[TradeCD] = @TradeCD,[Staff] = @Staff,"); sql.AppendLine("[Size] = @Size,[Production] = @Production,"); sql.AppendLine("[Sale] = @Sale,[Credit] = @Credit,[Remark] = @Remark,"); sql.AppendLine("[ModifiedDate] = getdate(), [ModifiedUserID] =ModifiedUserID where CompanyCD=@CompanyCD"); SqlParameter[] parms = new SqlParameter[23]; parms[0] = SqlHelper.GetParameter("@CompanyCD", Model.CompanyCD); parms[1] = SqlHelper.GetParameter("@CompanyNameCn", Model.CompanyNameCn); parms[2] = SqlHelper.GetParameter("@CompanyNameEn", Model.CompanyNameEn); parms[3] = SqlHelper.GetParameter("@ProvCD", Model.ProvCD); parms[4] = SqlHelper.GetParameter("@CityCD", Model.CityCD); parms[5] = SqlHelper.GetParameter("@Addr", Model.Addr); parms[6] = SqlHelper.GetParameter("@Contact", Model.Contact); parms[7] = SqlHelper.GetParameter("@Tel", Model.Tel); parms[8] = SqlHelper.GetParameter("@Fax", Model.Fax); parms[9] = SqlHelper.GetParameter("@Post", Model.Post); parms[10] = SqlHelper.GetParameter("@HomePage", Model.HomePage); parms[11] = SqlHelper.GetParameter("@Email", Model.Email); parms[12] = SqlHelper.GetParameter("@QQ", Model.QQ); parms[13] = SqlHelper.GetParameter("@MSN", Model.MSN); parms[14] = SqlHelper.GetParameter("@IM", Model.IM); parms[15] = SqlHelper.GetParameter("@TradeCD", Model.TradeCD); parms[16] = SqlHelper.GetParameter("@Staff", Model.Staff); parms[17] = SqlHelper.GetParameter("@Size", Model.Size); parms[18] = SqlHelper.GetParameter("@Production", Model.Production); parms[19] = SqlHelper.GetParameter("@Sale", Model.Sale); parms[20] = SqlHelper.GetParameter("@Credit", Model.Credit); parms[21] = SqlHelper.GetParameter("@Remark", Model.Remark); parms[22] = SqlHelper.GetParameter("@ModifiedUserID", Model.ModifiedUserID); SqlHelper.ExecuteTransSql(sql.ToString(), parms); return SqlHelper.Result.OprateCount > 0 ? true : false; }
/// <summary> /// 增加公司信息 /// </summary> /// <returns></returns> public static bool AddCompany(CompanyModel Model) { StringBuilder sql = new StringBuilder(); sql.AppendLine("Insert into pubdba.company(CompanyCD,CompanyNameCn,CompanyNameEn,"); sql.AppendLine("ProvCD,CityCD,Addr,Contact,Tel,Fax,Post,HomePage,Email,QQ,"); sql.AppendLine("MSN,IM,TradeCD,Staff,Size,Production,Sale,Credit,Remark,ModifiedDate,ModifiedUserID)"); sql.AppendLine("Values(@CompanyCD,@CompanyNameCn,@CompanyNameEn,@ProvCD,@CityCD,@Addr,"); sql.AppendLine("@Contact,@Tel,@Fax,@Post,@HomePage,@Email,@QQ,@MSN,"); sql.AppendLine("@IM,@TradeCD,@Staff,@Size,@Production,@Sale,@Credit,@Remark,getdate(),@ModifiedUserID)"); SqlParameter[] parms = new SqlParameter[23]; parms[0] = SqlHelper.GetParameter("@CompanyCD", Model.CompanyCD); parms[1] = SqlHelper.GetParameter("@CompanyNameCn", Model.CompanyNameCn); parms[2] = SqlHelper.GetParameter("@CompanyNameEn", Model.CompanyNameEn); parms[3] = SqlHelper.GetParameter("@ProvCD", Model.ProvCD); parms[4] = SqlHelper.GetParameter("@CityCD", Model.CityCD); parms[5] = SqlHelper.GetParameter("@Addr", Model.Addr); parms[6] = SqlHelper.GetParameter("@Contact", Model.Contact); parms[7] = SqlHelper.GetParameter("@Tel", Model.Tel); parms[8] = SqlHelper.GetParameter("@Fax", Model.Fax); parms[9] = SqlHelper.GetParameter("@Post", Model.Post); parms[10] = SqlHelper.GetParameter("@HomePage", Model.HomePage); parms[11] = SqlHelper.GetParameter("@Email", Model.Email); parms[12] = SqlHelper.GetParameter("@QQ", Model.QQ); parms[13] = SqlHelper.GetParameter("@MSN", Model.MSN); parms[14] = SqlHelper.GetParameter("@IM", Model.IM); parms[15] = SqlHelper.GetParameter("@TradeCD", Model.TradeCD); parms[16] = SqlHelper.GetParameter("@Staff", Model.Staff); parms[17] = SqlHelper.GetParameter("@Size", Model.Size); parms[18] = SqlHelper.GetParameter("@Production", Model.Production); parms[19] = SqlHelper.GetParameter("@Sale", Model.Sale); parms[20] = SqlHelper.GetParameter("@Credit", Model.Credit); parms[21] = SqlHelper.GetParameter("@Remark", Model.Remark); parms[22] = SqlHelper.GetParameter("@ModifiedUserID", Model.ModifiedUserID); SqlHelper.ExecuteTransSql(sql.ToString(),parms); return SqlHelper.Result.OprateCount > 0 ? true : false; }
protected void btnModify_Click(object sender, ImageClickEventArgs e) { CompanyModel Model = new CompanyModel(); Model.CityCD = HideAction.Value; Model.CompanyCD = this.txtCompanyCD.Text.Trim(); Model.CompanyNameCn = this.txtCompanyCn.Text.Trim(); Model.CompanyNameEn = this.txtCompanyEn.Text.Trim(); Model.ProvCD = this.SetPro.Value; Model.Addr = this.txtAddress.Text.Trim(); Model.Contact = this.txtContact.Text.Trim(); Model.Tel = this.txtTel.Text.Trim(); Model.Fax = this.txtFax.Text.Trim(); Model.Post = this.txtPost.Text.Trim(); Model.HomePage = this.txtHomePage.Text.Trim(); Model.Email = this.txtMail.Text.Trim(); Model.QQ = this.txtQQ.Text.Trim(); Model.MSN = this.txtMSN.Text.Trim(); Model.IM = this.txtIM.Text.Trim(); if (this.txtTradeCD.Text != "") { Model.TradeCD = Convert.ToInt32(this.txtTradeCD.Text); } if (this.txtStaff.Text != "") { Model.Staff = Convert.ToInt32(this.txtStaff.Text.Trim()); } Model.Size = DrpSize.SelectedValue; Model.Production = this.txtProduction.Text.Trim(); if (this.txtSale.Text != "") { Model.Sale = Convert.ToDecimal(this.txtSale.Text); } Model.Credit =this.txtCredit.Text.Trim(); Model.Remark = this.txtRemark.Text.Trim(); Model.ModifiedUserID = "admin"; try { if (Action == ActionUtil.Add.ToString()) { CompanyBus.AddCompany(Model); string url = "Company_Query.aspx?CompanyCD=" + Model.CompanyCD; Response.Redirect(url); //Response.Write("<script language='javascript'>window.location='Company_Query.aspx'</script>"); } else if (Action == ActionUtil.Edit.ToString()) { bool reult=CompanyBus.ModifyCompany(Model); string url = "Company_Query.aspx?CompanyCD=" + Model.CompanyCD; Response.Redirect(url); // Response.Write("<script language='javascript'>window.location='Company_Query.aspx?CompanyCD='"++"''</script>"); } } catch { lblMessage.Text = "数据操作失败,请联系管理员!"; } }