/// <summary> /// 根据物品编号,获取某种物品 /// </summary> /// <param name="nnum">物品编号</param> public Model.Goods getGoodsByNum(string nnum) { Model.Goods good = null; string sqltext = "select * from goods where goodsNum=@goodsNum"; List <SqlParameter> para = new List <SqlParameter>(); SqlParameter sqlpara1 = new SqlParameter("@goodsNum", nnum); para.Add(sqlpara1); SqlDataReader sdr = DBTools.exereaderSQL(sqltext, para); while (sdr.Read()) { good = new Model.Goods(); good.GoodsNum = sdr["goodsNum"].ToString(); good.GoodsTypeNum = sdr["goodsTypeNum"].ToString(); good.GoodsName = sdr["goodsName"].ToString(); good.GoodsStyle = sdr["goodsStyle"].ToString(); good.GoodsColor = sdr["goodsColor"].ToString(); good.GoodsSmell = sdr["goodsSmell"].ToString(); good.GoodsShape = sdr["goodsShape"].ToString(); good.GoodsPer = sdr["per"].ToString(); good.GoodsCondition = sdr["condition"].ToString(); good.GoodsCount = this.GoodsCountByNum(good.GoodsNum); good.GoodsType = new DAL.GoodsTypeDAO().getGoodsTypeByNum(good.GoodsTypeNum); } sdr.Close(); DBTools.DBClose(); return(good); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(Model.Goods model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into mtms_Goods("); strSql.Append("Name,CategoryName,Unit,Code"); strSql.Append(") values ("); strSql.Append("@Name,@CategoryName,@Unit,@Code"); strSql.Append(") "); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@Name", SqlDbType.VarChar, 254), new SqlParameter("@CategoryName", SqlDbType.VarChar, 254), new SqlParameter("@Unit", SqlDbType.VarChar, 254), new SqlParameter("@Code", SqlDbType.VarChar, 254) }; parameters[0].Value = model.Name; parameters[1].Value = model.CategoryName; parameters[2].Value = model.Unit; parameters[3].Value = model.Code; object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters); if (obj == null) { return(0); } else { return(Convert.ToInt32(obj)); } }
/// <summary> /// 修改类型 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnSave_Click(object sender, EventArgs e) { Model.Goods modl = new Model.Goods(); Model.cost_type models = new Model.cost_type(); string types = (Request.QueryString["type"].ToString()); bool result; if (types == "0") { modl.Goods_name = txt_name.Value; modl.id = Convert.ToInt32(Request.QueryString["id"].ToString()); modl.Goods_number = fmshif.GetModel(Convert.ToInt32(Request.QueryString["id"].ToString())).Goods_number; modl.Goods_ifType = 0; result = fmshif.Update(modl); } else { models.ct_name = txt_name.Value; models.id = Convert.ToInt32(Request.QueryString["id"].ToString()); models.ct_iftype = 0; models.ct_number = fmcost.GetModel(Convert.ToInt32(Request.QueryString["id"].ToString())).ct_number; result = fmcost.Update(models); } if (result) { ClientScript.RegisterStartupScript(GetType(), "message", "<script language='javascript' defer>alert('修改成功!');parent.Window_Close();</script>"); } else { ClientScript.RegisterStartupScript(GetType(), "message", "<script language='javascript' defer>alert('修改失败!');</script>"); } }
/// <summary> /// 获取所有物品。 /// </summary> public List <Model.Goods> getAllGoods() { List <Model.Goods> good = new List <Model.Goods>(); string sqltext = "select * from goods"; SqlDataReader sdr = DBTools.exereaderSQL(sqltext, new List <SqlParameter> ()); while (sdr.Read()) { Model.Goods g = new Model.Goods(); g.GoodsNum = sdr["goodsNum"].ToString(); g.GoodsTypeNum = sdr["goodsTypeNum"].ToString(); g.GoodsName = sdr["goodsName"].ToString(); g.GoodsStyle = sdr["goodsStyle"].ToString(); g.GoodsColor = sdr["goodsColor"].ToString(); g.GoodsSmell = sdr["goodsSmell"].ToString(); g.GoodsShape = sdr["goodsShape"].ToString(); g.GoodsPer = sdr["per"].ToString(); g.GoodsCondition = sdr["condition"].ToString(); g.GoodsCount = this.GoodsCountByNum(g.GoodsNum); g.GoodsType = new DAL.GoodsTypeDAO().getGoodsTypeByNum(g.GoodsTypeNum); good.Add(g); } sdr.Close(); DBTools.DBClose(); return(good); }
/// <summary> /// 获得数据列表 /// </summary> public List <Model.Goods> DataTableToList(DataTable dt) { List <Model.Goods> modelList = new List <Model.Goods>(); int rowsCount = dt.Rows.Count; if (rowsCount > 0) { Model.Goods model; for (int n = 0; n < rowsCount; n++) { model = new Model.Goods(); if (dt.Rows[n]["Id"].ToString() != "") { model.Id = int.Parse(dt.Rows[n]["Id"].ToString()); } model.Name = dt.Rows[n]["Name"].ToString(); model.CategoryName = dt.Rows[n]["CategoryName"].ToString(); model.Unit = dt.Rows[n]["Unit"].ToString(); model.Code = dt.Rows[n]["Code"].ToString(); modelList.Add(model); } } return(modelList); }
public override void ProcessRequest(HttpContext context) { base.ProcessRequest(context); Model.Member memberModel = (TModel == null ? BllModel.TModel : TModel); string strWhere = " IsDeleted=0 and MID='" + memberModel.MID + "' and Status=1"; int count; List <Model.ShopCar> List = BLL.ShopCar.GetList(strWhere, pageIndex, pageSize, out count); StringBuilder sb = new StringBuilder(); for (int i = 0; i < List.Count; i++) { sb.Append(List[i].Id + "~"); sb.Append((i + 1) + (pageIndex - 1) * pageSize + "~"); Model.Goods good = BLL.Goods.GetModel(List[i].GId); if (good != null) { sb.Append("<img class='appImg' alt=\"" + good.GName + "\" src='" + good.ImageAddr + "'/>"); sb.Append(good.GName + "<input type='hidden' value='" + List[i].Id + "' class='hidCId'/> ~"); sb.Append("<span class='spSprice'>" + good.CostPrice + "</span>/" + good.Unit + "~"); string str = @"<span class='goodNum numDesc' onclick='numDesc(this)'> - </span><input type='text' class='numVal' readonly='readonly' value='" + List[i].GCount + "'/> <span class='goodNum numAsc' onclick='numAsc(this)'> + </span>"; sb.Append(str + "~"); sb.Append("<span class='spTotal'>" + (List[i].GCount * good.CostPrice).ToFixedString() + "</span>~"); //sb.Append("<span class='spTotalDis'>" + (List[i].GCount * good.CostPrice /** BLL.Configuration.Model.E_GWDiscount*/).ToFixedString() + "</span>~"); sb.Append(good.SellingCount); sb.Append("≌"); } } var info = new { PageData = Traditionalized(sb), TotalCount = count }; context.Response.Write(JavaScriptConvert.SerializeObject(info)); }
private bool DoEdit(int _id) { bool result = false; BLL.Goods bll = new BLL.Goods(); Model.Goods model = bll.GetModel(_id); model.CustomerId = int.Parse(ddlCustomer.SelectedValue); model.StoreModeId = int.Parse(ddlStoreMode.SelectedValue); model.HandlingModeId = int.Parse(ddlHandlingMode.SelectedValue); model.UnitId = int.Parse(ddlUnit.SelectedValue); model.Name = txtName.Text; string[] attributeNames = Request.Form.GetValues("AttributeName"); string[] attributeValues = Request.Form.GetValues("AttributeValue"); string[] attributeRemarks = Request.Form.GetValues("AttributeRemark"); if (attributeNames != null && attributeValues != null && attributeRemarks != null && attributeNames.Length > 0 && attributeValues.Length > 0 && attributeRemarks.Length > 0) { for (int i = 0; i < attributeNames.Length; i++) { model.AddAttributeValues(new GoodsAttributeValues(attributeNames[i], attributeValues[i], attributeRemarks[i])); } } if (bll.Update(model)) { AddAdminLog(DTEnums.ActionEnum.Edit.ToString(), "修改客户信息:" + model.Name); //记录日志 result = true; } return(result); }
protected override string btnModify_Click() { string sid = Request.Form["hidId"]; Hashtable myHs = new Hashtable(); if (string.IsNullOrEmpty(sid) || sid == "0") { //添加 Model.Goods obj = GoodsModel; BLL.Goods.Insert(obj, myHs); SaveImgs(obj.GoodsCode, myHs); } else { Model.Goods obj = GoodsModel; BLL.Goods.Update(obj, myHs); DeleteImgs(myHs); SaveImgs(obj.GoodsCode, myHs); } if (BLL.CommonBase.RunHashtable(myHs)) { return("操作成功"); } return("操作失败"); }
private bool DoAdd() { bool result = false; Model.Goods model = new Model.Goods(); BLL.Goods bll = new BLL.Goods(); model.CustomerId = int.Parse(ddlCustomer.SelectedValue); model.StoreModeId = int.Parse(ddlStoreMode.SelectedValue); model.HandlingModeId = int.Parse(ddlHandlingMode.SelectedValue); model.UnitId = int.Parse(ddlUnit.SelectedValue); model.Name = txtName.Text; string[] attributeNames = Request.Form.GetValues("AttributeName"); string[] attributeValues = Request.Form.GetValues("AttributeValue"); string[] attributeRemarks = Request.Form.GetValues("AttributeRemark"); if (attributeNames != null && attributeValues != null && attributeRemarks != null && attributeNames.Length > 0 && attributeValues.Length > 0 && attributeRemarks.Length > 0) { for (int i = 0; i < attributeNames.Length; i++) { model.AddAttributeValues(new GoodsAttributeValues(attributeNames[i], attributeValues[i], attributeRemarks[i])); } } if (bll.Add(model)) { AddAdminLog(DTEnums.ActionEnum.Add.ToString(), "添加客户:" + model.Name); //记录日志 result = true; } return result; }
/// <summary> /// 得到一个对象实体 /// </summary> public Model.Goods GetModel(int Id) { StringBuilder strSql = new StringBuilder(); strSql.Append("select Id, Name, CategoryName, Unit, Code "); strSql.Append(" from mtms_Goods "); strSql.Append(" where Id=@Id"); SqlParameter[] parameters = { new SqlParameter("@Id", SqlDbType.Int, 4) }; parameters[0].Value = Id; Model.Goods model = new Model.Goods(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { if (ds.Tables[0].Rows[0]["Id"].ToString() != "") { model.Id = int.Parse(ds.Tables[0].Rows[0]["Id"].ToString()); } model.Name = ds.Tables[0].Rows[0]["Name"].ToString(); model.CategoryName = ds.Tables[0].Rows[0]["CategoryName"].ToString(); model.Unit = ds.Tables[0].Rows[0]["Unit"].ToString(); model.Code = ds.Tables[0].Rows[0]["Code"].ToString(); return(model); } else { return(null); } }
private void ShowInfo(int _id) { BLL.Goods bll = new BLL.Goods(); Model.Goods model = bll.GetModel(_id); txtName.Text = model.Name; txtCategroy.Text = model.CategoryName; txtCode.Text = model.Code; txtUnit.Text = model.Unit; }
protected override string btnModify_Click() { lock (lockObj) { string oid = Session["OrderId"] != null ? Session["OrderId"].ToString() : ""; //查看订单信息 if (!string.IsNullOrEmpty(oid)) { Model.Order model = BLL.Order.GetModel(oid); if (model != null) { decimal totaoPay = model.TotalPrice; if (BLL.ChangeMoney.EnoughChange(model.MID, totaoPay, "MGP")) { Hashtable MyHs = new Hashtable(); //货币转换 BLL.ChangeMoney.HBChangeTran(totaoPay, TModel.MID, BLL.Member.ManageMember.TModel.MID, "GW", null, "MGP", "支付订单" + model.Code, MyHs); //库存减少 foreach (Model.OrderDetail od in model.OrderDetail) { Model.Goods good = BLL.Goods.GetModel(od.GId); if (good != null) { good.SelledCount = good.SelledCount + od.GCount; good.SellingCount = good.SellingCount - od.GCount; BLL.Goods.Update(good, MyHs); } } //修改订单状态 model.Status = 2; BLL.Order.Update(model); if (BLL.CommonBase.RunHashtable(MyHs)) { Session["OrderId"] = null; return("支付成功!"); } else { return("支付失败,请重试!"); } } else { Session["OrderId"] = null; return("您的消费积分不足,请充值后购买!"); } } } else { return("该订单信息出现异常,请重新进入该页面支付"); } return("操作失败"); } }
protected override void SetValue(string id) { string mid = HttpUtility.UrlDecode(Request["id"].Trim()); hidId.Value = mid; model = BLL.Goods.GetModel(mid); var list = BLL.GoodsPic.GetList("IsDeleted=0 and GId='" + model.GoodsCode + "'"); rep_PicList.DataSource = list; rep_PicList.DataBind(); }
protected void ddlGoods_SelectedIndexChanged(object sender, EventArgs e) { if (!string.IsNullOrEmpty(ddlGoods.SelectedValue)) { BLL.Goods bll = new BLL.Goods(); Model.Goods m = bll.GetModel(Convert.ToInt32(ddlGoods.SelectedValue)); if (m != null) { txtUnit.Text = m.Unit; } } }
/// <summary> /// 增加一条数据 /// </summary> public static Hashtable Insert(Model.Goods model, Hashtable MyHs) { string guid = Guid.NewGuid().ToString(); StringBuilder strSql = new StringBuilder(); strSql.Append("insert into Goods("); strSql.Append("GroupPrice,GroupPV,ImageAddr,SelledCount,SellingCount,Unit,IsDeleted,Status,GoodsCode,GParentCode,GParentName,GName,CostPrice,CostPV,MemberPrice,MemberPV,Remark"); strSql.Append(") values ("); strSql.Append("@GroupPrice,@GroupPV,@ImageAddr,@SelledCount,@SellingCount,@Unit,@IsDeleted,@Status,@GoodsCode,@GParentCode,@GParentName,@GName,@CostPrice,@CostPV,@MemberPrice,@MemberPV,@Remark"); strSql.Append(") "); strSql.AppendFormat(";select '{0}'", guid); SqlParameter[] parameters = { new SqlParameter("@GroupPrice", SqlDbType.Decimal, 9), new SqlParameter("@GroupPV", SqlDbType.Decimal, 9), new SqlParameter("@ImageAddr", SqlDbType.VarChar, 255), new SqlParameter("@SelledCount", SqlDbType.Decimal, 9), new SqlParameter("@SellingCount", SqlDbType.Decimal, 9), new SqlParameter("@Unit", SqlDbType.VarChar, 10), new SqlParameter("@IsDeleted", SqlDbType.Bit, 1), new SqlParameter("@Status", SqlDbType.Int, 4), new SqlParameter("@GoodsCode", SqlDbType.VarChar, 50), new SqlParameter("@GParentCode", SqlDbType.VarChar, 50), new SqlParameter("@GParentName", SqlDbType.VarChar, 50), new SqlParameter("@GName", SqlDbType.VarChar, 50), new SqlParameter("@CostPrice", SqlDbType.Decimal, 9), new SqlParameter("@CostPV", SqlDbType.Decimal, 9), new SqlParameter("@MemberPrice", SqlDbType.Decimal, 9), new SqlParameter("@MemberPV", SqlDbType.Decimal, 9), new SqlParameter("@Remark", SqlDbType.NVarChar, 2000) }; parameters[0].Value = model.GroupPrice; parameters[1].Value = model.GroupPV; parameters[2].Value = model.ImageAddr; parameters[3].Value = model.SelledCount; parameters[4].Value = model.SellingCount; parameters[5].Value = model.Unit; parameters[6].Value = model.IsDeleted; parameters[7].Value = model.Status; parameters[8].Value = model.GoodsCode; parameters[9].Value = model.GParentCode; parameters[10].Value = model.GParentName; parameters[11].Value = model.GName; parameters[12].Value = model.CostPrice; parameters[13].Value = model.CostPV; parameters[14].Value = model.MemberPrice; parameters[15].Value = model.MemberPV; parameters[16].Value = model.Remark; MyHs.Add(strSql.ToString(), parameters); return(MyHs); }
protected override void SetPowerZone() { Spare2.DataSource = BLL.C_Car.GetList(" IsDelete = 0 and CType='牵引车' order by ID"); Spare2.DataTextField = "PZCode"; Spare2.DataValueField = "PZCode"; Spare2.DataBind(); CSpare2.DataSource = BLL.C_Car.GetList(" IsDelete = 0 and CType='挂车' order by ID"); CSpare2.DataTextField = "PZCode"; CSpare2.DataValueField = "PZCode"; CSpare2.DataBind(); //ListItem lt = new ListItem(); //lt.Value = ""; //lt.Text = "空项"; //CSpare2.Items.Insert(0, lt); CarSJ1.DataSource = BLL.Member.ManageMember.GetMemberEntityList(" RoleCode='SiJi' AND FMID='1' AND IsClock=0 AND IsClose=0 order by ID"); CarSJ1.DataTextField = "MName"; CarSJ1.DataValueField = "MID"; //CarSJ1.Items.Insert(0, "--请选择--"); CarSJ1.DataBind(); CarSJ2.DataSource = BLL.Member.ManageMember.GetMemberEntityList(" RoleCode='SiJi' AND FMID IN('2','3') AND IsClock=0 AND IsClose=0 order by ID"); CarSJ2.DataTextField = "MName"; CarSJ2.DataValueField = "MID"; CarSJ2.DataBind(); //CarSJ2.Items.Insert(0, "--请选择--"); if (!string.IsNullOrEmpty(Request.QueryString["oid"])) { ocode.Value = Request.QueryString["oid"]; oid.Value = Request.QueryString["oid"]; } if (!string.IsNullOrEmpty(Request.QueryString["id"])) { string id = Request.QueryString["id"]; Model.C_CarTast car = BLL.C_CarTast.GetModel(Convert.ToInt32(id)); Spare2.Value = car.Spare2.ToString(); CSpare2.Value = car.CSpare2.ToString(); CarSJ1.Value = car.CarSJ1.ToString(); CarSJ2.Value = car.CarSJ2.ToString(); if (!string.IsNullOrEmpty(car.OCode)) { Model.OrderDetail od = BLL.OrderDetail.GetModelCode(car.OCode); goodcount = od.GCount.ToString(); Model.Goods good = BLL.Goods.GetModel(od.GId.ToString()); goodname = good.GName; } } }
/// <summary> /// 获得商品详情信息 /// </summary> private void GetGoodsInfo() { BLL.Goods bllgood = new BLL.Goods(); int id = Convert.ToInt32(context.Request.QueryString["id"]); Model.Goods modelgood = bllgood.GetModel(id); string res = string.Empty; if (modelgood != null) { res = js.Serialize(modelgood); } context.Response.Write(res); }
protected override void SetPowerZone() { 车辆里程 = Convert.ToDecimal(BLL.CommonBase.GetSingle("select ISNULL( SUM(DiffCount),0) from C_Mileage where DATEDIFF(MONTH,CreateDate,GETDATE())=0")); 本月费用 = Convert.ToDecimal(BLL.CommonBase.GetSingle("select ISNULL( SUM(CostMoney),0) from C_CostDetalis where DATEDIFF(MONTH,CareteDate,GETDATE())=0")); 非空车数量 = Convert.ToInt32(BLL.CommonBase.GetSingle("select COUNT(*) from C_Car where CType='牵引车' and PZCode in(select Spare2 from C_CarTast where TState!=1 and TState!=2)")) + Convert.ToInt32(BLL.CommonBase.GetSingle("select COUNT(*) from C_Car where CType='挂车' and PZCode in(select CSpare2 from C_CarTast where (TState!=1 and TState!=2))")); int 总车辆数量 = Convert.ToInt32(BLL.CommonBase.GetSingle("select COUNT(*) from C_Car where IsDelete=0;")); 空车数量 = 总车辆数量 - 非空车数量; listPowers = TModel.Role.PowersList.Where(emp => emp.Content.VState).ToList(); List <Model.Goods> list = BLL.Goods.GetList(" isdeleted=0 "); foreach (var item in list) { DataTable dt = BLL.CommonBase.GetTable("select CONVERT(varchar(7),DATEADD(month,-1,CreatedTime),120) dt,ISNULL(sum(ReCount),0) my from OrderDetail where gid=" + item.GID + " and OrderCode in(select OCode from C_CarTast where TState=1) group by CONVERT(varchar(7),DATEADD(month,-1,CreatedTime),120);"); if (dt.Rows.Count > 0) { Model.Goods g = BLL.Goods.GetModel(item.GID); goodsList += "{name:'" + g.GName + "',data:["; for (int i = 0; i < dt.Rows.Count; i++) { DateTime dt2 = Convert.ToDateTime(dt.Rows[i]["dt"]); goodsList += "[Date.UTC(" + dt2.ToString("yyyy") + ", " + dt2.ToString("MM") + ")," + dt.Rows[i]["my"].ToString() + "],"; } goodsList += "]},"; } } goodsList = goodsList.Length > 0 ? goodsList.Substring(0, goodsList.Length - 1) : ""; decimal zctotal = Convert.ToDecimal(BLL.CommonBase.GetSingle(" select ISNULL(SUM(recount),0) from OrderDetail where OrderCode in(select OCode from C_CarTast where ttype=1 and TState=1) ")); if (zctotal > 0) { foreach (var item in list) { Model.Goods g = BLL.Goods.GetModel(item.GID); decimal zcgoodstotal = Convert.ToDecimal(BLL.CommonBase.GetSingle(" select ISNULL(SUM(recount),0) from OrderDetail where gid=" + item.GID + " and OrderCode in(select OCode from C_CarTast where ttype=1 and TState=1) ")); goodspic += "['" + g.GName + "', " + zcgoodstotal / zctotal * 100 + "],"; } } goodspic = goodspic.Length > 0 ? goodspic.Substring(0, goodspic.Length - 1) : goodspic; }
/// <summary> /// 保存 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnAdd_Click(object sender, EventArgs e) { string id = Request.QueryString["id"].ToString(); Model.Goods frmtype = new Model.Goods(); frmtype.Goods_number = txtBH.Value; frmtype.Goods_name = txtName.Value; frmtype.Goods_ifType = 1; frmtype.Goods_unit = txt_unit.Value; if (txt_Jf.Value == "") { frmtype.Goods_jf = 0; } else { frmtype.Goods_jf = Convert.ToInt32(txt_Jf.Value); } frmtype.Goods_categories = Convert.ToInt32(DDlfylb.SelectedValue); frmtype.Goods_price = Convert.ToDecimal(txtPrice.Value); if (radStatu.Checked == true) { frmtype.Goods_state = radStatu.Value; } else { frmtype.Goods_state = radStatus.Value; } // frmtype.Goods_categories = Convert.ToInt32(DDlfylb.SelectedValue); if (id == "") { int Result = fmcost.Add(frmtype); if (Result > 0) { //Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功!", ""); ScriptManager.RegisterStartupScript(this, this.GetType(), "click", "alert('保存成功');parent.Window_Close();", true); } } else { frmtype.id = Convert.ToInt32(id); if (fmcost.Update(frmtype)) { ScriptManager.RegisterStartupScript(this, this.GetType(), "click", "alert('更新成功');parent.Window_Close();", true); } } }
private void ShowInfo(int _id) { BLL.Goods bll = new BLL.Goods(); Model.Goods model = bll.GetModel(_id); ddlCustomer.SelectedValue = model.CustomerId.ToString(); ddlStoreMode.SelectedValue = model.StoreModeId.ToString(); ddlHandlingMode.SelectedValue = model.HandlingModeId.ToString(); ddlUnit.SelectedValue = model.UnitId.ToString(); txtName.Text = model.Name; BLL.GoodsAttributeValues attributeBLL = new BLL.GoodsAttributeValues(); DataTable attributeDT = attributeBLL.GetList(" GoodsId = " + _id + "").Tables[0]; this.rptAttributeList.DataSource = attributeDT; this.rptAttributeList.DataBind(); }
public static List <YF.Model.Goods> Dotolist(DataTable dt) { List <YF.Model.Goods> list = new List <Model.Goods>();//空的泛型对象 转换 for (int i = 0; i < dt.Rows.Count; i++) { YF.Model.Goods goods = new Model.Goods();//空对象 goods.Id = int.Parse(dt.Rows[i]["id"].ToString()); goods.Title = dt.Rows[i]["title"].ToString(); goods.Price = int.Parse(dt.Rows[i]["price"].ToString()); goods.Num = int.Parse(dt.Rows[i]["num"].ToString()); goods.Img = dt.Rows[i]["img"].ToString(); goods.Detail = dt.Rows[i]["detail"].ToString(); goods.State = int.Parse(dt.Rows[i]["state"].ToString()); goods.Addate = DateTime.Parse(dt.Rows[i]["addate"].ToString()); list.Add(goods); //空的泛型对象+数据 } return(list); }
private bool DoAdd() { bool result = false; Model.Goods model = new Model.Goods(); BLL.Goods bll = new BLL.Goods(); model.Name = txtName.Text.Trim(); model.CategoryName = txtCategroy.Text.Trim(); model.Code = string.IsNullOrEmpty(txtCode.Text.Trim()) ? "" : txtCode.Text.Trim(); model.Unit = txtUnit.Text.Trim(); if (bll.Add(model) > 0) { AddAdminLog(DTEnums.ActionEnum.Add.ToString(), "添加客户:" + model.Name); //记录日志 result = true; } return(result); }
private bool DoEdit(int _id) { bool result = false; BLL.Goods bll = new BLL.Goods(); Model.Goods model = bll.GetModel(_id); model.Name = txtName.Text.Trim(); model.CategoryName = txtCategroy.Text.Trim(); model.Code = string.IsNullOrEmpty(txtCode.Text.Trim()) ? "" : txtCode.Text.Trim(); model.Unit = txtUnit.Text.Trim(); if (bll.Update(model)) { AddAdminLog(DTEnums.ActionEnum.Edit.ToString(), "修改客户信息:" + model.Name); //记录日志 result = true; } return(result); }
private void btConfirm_Click(object sender, EventArgs e) { if (tbID.Text.Trim() == "" || tbRoomType.Text.Trim() == "") { MessageBox.Show("输入信息不完整!", "修改失败", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); flag = 1; } if (flag == 0) { if (tbRoomType.Text.Trim() == "双人间" || tbRoomType.Text.Trim() == "单人间" || tbRoomType.Text.Trim() == "套房") { Maticsoft.BLL.Goods go = new BLL.Goods(); string str1 = string.Format("goodsID = '{0}'", tbID.Text.Trim()); Model.Goods gmodel = new Model.Goods(); if (go.GetRecordCount(str1) > 0) { gmodel.goodsID = tbID.Text.Trim(); gmodel.goodsName = tbName.Text.Trim(); gmodel.goodsPrice = Convert.ToDecimal(tbPrice.Text.Trim()); gmodel.roomTypeID = tbRoomType.Text.Trim(); if (go.Update(gmodel) == true) { MessageBox.Show("修改成功!"); ((Main_Admin)this.Owner).RoomGoodsLoad(); this.DialogResult = DialogResult.OK; this.Close(); } else { MessageBox.Show("修改失败!"); } } else { MessageBox.Show("不存在此物品编号!", "修改失败", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } else { MessageBox.Show("房型不存在!", "修改失败", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } }
private bool DoAdd() { bool result = false; Model.Goods model = new Model.Goods(); BLL.Goods bll = new BLL.Goods(); model.Name = txtName.Text.Trim(); model.CategoryName = txtCategroy.Text.Trim(); model.Code = string.IsNullOrEmpty(txtCode.Text.Trim()) ? "" : txtCode.Text.Trim(); model.Unit = txtUnit.Text.Trim(); model.Variety = txtVariety.Text.Trim(); if (bll.Add(model) > 0) { AddAdminLog(DTEnums.ActionEnum.Add.ToString(), "添加客户:" + model.Name); //记录日志 result = true; } return result; }
protected override string btnModify_Click() { try { string req = Request.Form["gid"]; Model.Goods cc = BLL.Goods.GetModel(int.Parse(req)); if (cc != null) { return(cc.Unit); } else { return("-1"); } } catch (Exception e) { return("-1"); } }
protected override void SetValue(string id) { Model.Account c = BLL.Account.GetModel(int.Parse(id)); CName.Value = c.CName; SuppName.Value = c.SupplierName; type.Value = c.AType.ToString(); Model.C_CarTast tast = BLL.C_CarTast.GetModel(c.CID); if (!string.IsNullOrEmpty(tast.OCode)) { Model.OrderDetail od = BLL.OrderDetail.GetModelCode(tast.OCode); Model.Goods goods = BLL.Goods.GetModel(od.GId); GoodName.Value = goods.GName; txtGoodCount.Value = c.OrderCount.ToString(); txtGoodPrice.Value = c.OrderPrice.ToString(); } Remark.Value = c.Spare2.ToString(); fid.Value = c.ID.ToString(); }
protected override void SetValue(string id) { string oid = HttpUtility.UrlDecode(Request["id"].Trim());//订单Id hidId.Value = oid; orderModel = BLL.Order.GetModel(oid); ReceiveInfoModel = BLL.ReceiveInfo.GetModel(orderModel.ReceiveId); ViewState["OrderInfo"] = orderModel; Session["OrderId"] = oid; List <Model.OrderDetail> listdetail = BLL.OrderDetail.GetList(" OrderCode='" + orderModel.Code + "';"); foreach (Model.OrderDetail item in listdetail) { Model.Goods gs = BLL.Goods.GetModel(item.GId); if (gs != null) { strgoods += gs.GName + " " + item.GCount + gs.Unit + ";<br/>"; } } }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(Model.Goods model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update mtms_Goods set "); strSql.Append(" Name = @Name , "); strSql.Append(" CategoryName = @CategoryName , "); strSql.Append(" Unit = @Unit , "); strSql.Append(" Variety = @Variety , "); strSql.Append(" Code = @Code "); strSql.Append(" where Id=@Id "); SqlParameter[] parameters = { new SqlParameter("@Id", SqlDbType.Int, 4), new SqlParameter("@Name", SqlDbType.VarChar, 254), new SqlParameter("@CategoryName", SqlDbType.VarChar, 254), new SqlParameter("@Unit", SqlDbType.VarChar, 254), new SqlParameter("@Code", SqlDbType.VarChar, 254), new SqlParameter("@Variety", SqlDbType.VarChar, 254) }; parameters[0].Value = model.Id; parameters[1].Value = model.Name; parameters[2].Value = model.CategoryName; parameters[3].Value = model.Unit; parameters[4].Value = model.Code; parameters[5].Value = model.Variety; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
public override ResponseBase Handler(AddGoodsRequest request) { try { if (request == null) { throw new Exception("商品信息无效"); } var service = ServiceProvider.GetService <IGoodsClassService>(); if (!service.ValidateGoodsClassID(new int[] { request.ClassID })) { throw new Exception("商品类别无效"); } var unitService = ServiceProvider.GetService <IUnitService>(); if (!unitService.ValidateUnitID(new int[] { request.UnitID })) { throw new Exception("计量单位无效"); } var model = new Model.Goods() { Name = request.Name, UnitID = request.UnitID, ClassID = request.ClassID }; var goodsService = ServiceProvider.GetService <IGoodsService>(); goodsService.AddGoods(model); return(new ResponseBase() { Result = 1, ResultInfo = "" }); } catch (Exception ex) { return(new ResponseBase() { Result = -1, ResultInfo = ex.Message }); } }
/// <summary> /// 添加一种物品。 /// </summary> /// <param name="goods">物品对象</param> /// <returns>通过布尔值判断操作是否成功。</returns> public bool addGoods(Model.Goods goods) { string sqltext = "insert goods(num,goodsNum,goodsTypeNum,goodsName,goodsStyle,goodsColor,goodsSmell,goodsShape,per,condition,max) values(@num,@goodsNum,@goodsTypeNum,@goodsName,@goodsStyle,@goodsColor,@goodsSmell,@goodsShape,@per,@condition,@max)"; List <SqlParameter> para = new List <SqlParameter>(); SqlParameter sqlpara = new SqlParameter("@num", goods.Num); SqlParameter sqlpara1 = new SqlParameter("@goodsNum", goods.GoodsNum); SqlParameter sqlpara2 = new SqlParameter("@goodsTypeNum", goods.GoodsTypeNum); SqlParameter sqlpara3 = new SqlParameter("@goodsName", goods.GoodsName); SqlParameter sqlpara4 = new SqlParameter("@goodsStyle", goods.GoodsStyle); SqlParameter sqlpara5 = new SqlParameter("@goodsColor", goods.GoodsColor); SqlParameter sqlpara6 = new SqlParameter("@goodsSmell", goods.GoodsSmell); SqlParameter sqlpara7 = new SqlParameter("@goodsShape", goods.GoodsShape); SqlParameter sqlpara8 = new SqlParameter("@per", goods.GoodsPer); SqlParameter sqlpara9 = new SqlParameter("@condition", goods.GoodsCondition); SqlParameter sqlpara10 = new SqlParameter("@max", goods.Max); para.Add(sqlpara); para.Add(sqlpara1); para.Add(sqlpara2); para.Add(sqlpara3); para.Add(sqlpara4); para.Add(sqlpara5); para.Add(sqlpara6); para.Add(sqlpara7); para.Add(sqlpara8); para.Add(sqlpara9); para.Add(sqlpara10); int i = DBTools.exenonquerySQL(sqltext, para); if (i == 1) { return(true); } else { return(false); } }
/// <summary> /// 商品点击量自增 /// </summary> /// <param name="articleId">商品唯一标识</param> /// <returns>是否新增成功</returns> public ReturnResult <bool> ClickCounIncrement(string goodsId) { ReturnResult <bool> result = new ReturnResult <bool>(); try { using (GoodsEntities GoodsDb = new GoodsEntities()) { Model.Goods query = GoodsDb.Goods.FirstOrDefault(goods => goods.id == goodsId && goods.state == 2); if (query == null) { result.code = -106; result.message = "找不到对应商品。"; return(result); } query.clickcount = (query.clickcount ?? 0) + 1; if (GoodsDb.SaveChanges() <= 0) { result.code = -107; result.message = "商品点击数未更新成功。"; return(result); } result.code = 1; result.data = true; } } catch (Exception exp) { result.code = -1; result.message = "服务已断开,请稍后重试!"; //记录日志 LogWriter.WebError(exp); } return(result); }
/// <summary> /// 获得数据列表 /// </summary> public List<Model.Goods> DataTableToList(DataTable dt) { List<Model.Goods> modelList = new List<Model.Goods>(); int rowsCount = dt.Rows.Count; if (rowsCount > 0) { Model.Goods model; for (int n = 0; n < rowsCount; n++) { model = new Model.Goods(); if (dt.Rows[n]["Id"].ToString() != "") { model.Id = int.Parse(dt.Rows[n]["Id"].ToString()); } model.Name = dt.Rows[n]["Name"].ToString(); model.CategoryName = dt.Rows[n]["CategoryName"].ToString(); model.Unit = dt.Rows[n]["Unit"].ToString(); model.Code = dt.Rows[n]["Code"].ToString(); modelList.Add(model); } } return modelList; }
/// <summary> /// 得到一个对象实体 /// </summary> public Model.Goods GetModel(int Id) { StringBuilder strSql = new StringBuilder(); strSql.Append("select Id, Name, CategoryName, Unit, Code "); strSql.Append(" from mtms_Goods "); strSql.Append(" where Id=@Id"); SqlParameter[] parameters = { new SqlParameter("@Id", SqlDbType.Int,4) }; parameters[0].Value = Id; Model.Goods model = new Model.Goods(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { if (ds.Tables[0].Rows[0]["Id"].ToString() != "") { model.Id = int.Parse(ds.Tables[0].Rows[0]["Id"].ToString()); } model.Name = ds.Tables[0].Rows[0]["Name"].ToString(); model.CategoryName = ds.Tables[0].Rows[0]["CategoryName"].ToString(); model.Unit = ds.Tables[0].Rows[0]["Unit"].ToString(); model.Code = ds.Tables[0].Rows[0]["Code"].ToString(); return model; } else { return null; } }