public int Upt(Model.Commodity cc) { try { string sql = $"update Commodity set CommodityName='{cc.CommodityName}',CommodityPic='{cc.CommodityPic}',ShopPrice='{cc.ShopPrice}',ShopNum={cc.ShopNum},Repertory={cc.Repertory},Sort={cc.Sort},State={cc.State},OperationDate='{cc.OperationDate}' where CommodityId={cc.CommodityId}"; return(DapperHelper.Execute(sql)); } catch (Exception) { throw; } }
public int Insert(Model.Commodity Model) { try { string sql = $"insert into Commodity values(null,'{Model.CommodityName}','{Model.CommodityPic}','{Model.ShopPrice}',{Model.ShopNum},{Model.Repertory},{Model.Sort},0,now(),{Model.TId},'{Model.Remark}',{Model.TemplateId},'{Model.CommodityKey}','{Model.SendAddress}','{Model.Job}',{Model.Integral},{Model.SId},'{Model.Color}','{Model.Size}',0,0,{Model.CostPrice},{Model.ColonelID},{Model.Mid})"; return(DapperHelper.Execute(sql)); } catch (Exception) { throw; } }
protected void Button1_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(txtContent.Text)) { Page.ClientScript.RegisterClientScriptBlock(typeof(Object), "alert", "<script>alert('请输入信息后再点击!');</script>"); } else { Model.Commodity ns = new Model.Commodity(); ns.C_Name = TextBox1.Text.Trim(); ns.C_Price = TextBox2.Text.Trim(); ns.C_Color = TextBox3.Text.Trim(); ns.C_Kucun = TextBox4.Text.Trim(); ns.C_Size = TextBox5.Text.Trim(); ns.C_Biaoshi = TextBox6.Text.Trim(); ns.C_Content = txtContent.Text.Trim(); try { if (FileUpload1.HasFile) { string filePath = FileUpload1.PostedFile.FileName; string filename = filePath.Substring(filePath.LastIndexOf("\\") + 1); string serverpath = Server.MapPath(@"img\") + filename; string relativepath = @"img\" + filename; FileUpload1.PostedFile.SaveAs(serverpath); ns.C_Photo = relativepath; } else { Page.ClientScript.RegisterClientScriptBlock(typeof(Object), "alert", "<script>alert('请先上传商品图片!');</script>"); return; } if (CommodityManager.publishShangping(ns) == 1) { Page.ClientScript.RegisterClientScriptBlock(typeof(Object), "alert", "<script>alert('添加成功!');</script>"); } else { Page.ClientScript.RegisterClientScriptBlock(typeof(object), "alert", "<script>alert('添加失败!');</script>"); } } catch (Exception ex) { Response.Write("错误原因:" + ex.Message); } } }
public int Upt(Model.Commodity cc) { return(_commodityRepository.Upt(cc)); }