示例#1
0
        public ActionResult Edit(DBA.Model.CKRecord model)
        {
            if (model.ID == 0)
            {
                DBA.Model.Users usermodel = ubll.GetModelList(" LoginName='" + model.Str1 + "'").FirstOrDefault();
                if (usermodel == null)
                {
                    usermodel           = new DBA.Model.Users();
                    usermodel.Age       = model.Age;
                    usermodel.LoginName = model.Str1;
                    usermodel.Sex       = model.Sex;
                    usermodel.UserName  = model.Name;
                    ubll.Add(usermodel);
                }
                model.Time = DateTime.Now;
                DBA.Model.Goods Goods = bbll.GetModel(model.BookID);
                model.CreateUserName = DBA.BLL.Users.GetNowUserName();
                Goods.GoodsKC        = Goods.GoodsKC - Convert.ToInt32(model.Num);
                model.Str3           = Goods.Price;
                model.Str2           = (Convert.ToDouble(model.Num) * (Convert.ToDouble(Goods.Price) - Convert.ToDouble(Goods.GoodsKey))).ToString();
                bbll.Update(Goods);
            }

            bll.Edit(model);
            return(RedirectToAction("CKRecordManage"));
        }
示例#2
0
        public DBA.Model.Goods GetIsbn(String ISBN)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 ID,GoodsName,GoodsCBS,ISBN,GoodsZZ,GoodsKC,Price,CategoryID,Str1,Str2,GoodsKey,GoodsJJ,Max,Min,WarnName,StoreHouse from Goods ");
            strSql.Append(" where ISBN=@ISBN");
            SqlParameter[] parameters =
            {
                new SqlParameter("@ISBN", SqlDbType.VarChar, 4)
            };
            parameters[0].Value = ISBN;

            DBA.Model.Goods model = new DBA.Model.Goods();


            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);

            //DataRow t = new DataRow();
            //    t = ds.Tables[0].Rows[0];
            //Console.WriteLine(ds.Tables[0].Rows[0].ToString());
            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
示例#3
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(DBA.Model.Goods model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into Goods(");
            strSql.Append("GoodsName,GoodsCBS,ISBN,GoodsZZ,GoodsKC,Price,CategoryID,Str1,Str2,GoodsKey,GoodsJJ,Max,Min,WarnName)");
            strSql.Append(" values (");
            strSql.Append("@GoodsName,@GoodsCBS,@ISBN,@GoodsZZ,@GoodsKC,@Price,@CategoryID,@Str1,@Str2,@GoodsKey,@GoodsJJ,@Max,@Min,@WarnName)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@GoodsName",  SqlDbType.NChar,     20),
                new SqlParameter("@GoodsCBS",   SqlDbType.NChar,     50),
                new SqlParameter("@ISBN",       SqlDbType.NChar,     10),
                new SqlParameter("@GoodsZZ",    SqlDbType.NChar,     10),
                new SqlParameter("@GoodsKC",    SqlDbType.Int,        4),
                new SqlParameter("@Price",      SqlDbType.NChar,     10),
                new SqlParameter("@CategoryID", SqlDbType.Int,        4),
                new SqlParameter("@Str1",       SqlDbType.NChar,     10),
                new SqlParameter("@Str2",       SqlDbType.NChar,     10),
                new SqlParameter("@GoodsKey",   SqlDbType.NChar,     10),
                new SqlParameter("@GoodsJJ",    SqlDbType.NChar,    500),
                new SqlParameter("@Max",        SqlDbType.NVarChar,  50),
                new SqlParameter("@Min",        SqlDbType.NVarChar,  50),
                new SqlParameter("@WarnName",   SqlDbType.NVarChar, 50)
            };
            parameters[0].Value  = model.GoodsName;
            parameters[1].Value  = model.GoodsCBS;
            parameters[2].Value  = model.ISBN;
            parameters[3].Value  = model.GoodsZZ;
            parameters[4].Value  = model.GoodsKC;
            parameters[5].Value  = model.Price;
            parameters[6].Value  = model.CategoryID;
            parameters[7].Value  = model.Str1;
            parameters[8].Value  = model.Str2;
            parameters[9].Value  = model.GoodsKey;
            parameters[10].Value = model.GoodsJJ;
            parameters[11].Value = model.Max;
            parameters[12].Value = model.Min;
            parameters[13].Value = model.WarnName;

            object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
        public ActionResult Create(string ID)
        {
            List <SelectListItem> select1 = new List <SelectListItem>();

            select1.Add(new SelectListItem
            {
                Text  = "请选择",
                Value = ""
            });
            List <DBA.Model.Category> list = depbll.GetModelList(" Str1='1'");

            for (int i = 0; i < list.Count; i++)
            {
                select1.Add(new SelectListItem
                {
                    Text  = list[i].CategoryName,
                    Value = list[i].ID.ToString()
                });
            }
            ;
            ViewData["CategoryID"] = new SelectList(select1, "Value", "Text", "");
            List <SelectListItem> select3 = new List <SelectListItem>();

            select3.Add(new SelectListItem
            {
                Text  = "请选择",
                Value = ""
            });
            List <DBA.Model.Warning> list3 = wbll.GetModelList(" 1=1");

            for (int i = 0; i < list3.Count; i++)
            {
                select3.Add(new SelectListItem
                {
                    Text  = list3[i].WarnType + "(" + list3[i].Min + "-" + list3[i].Max + ")",
                    Value = list3[i].ID.ToString()
                });
            }
            ;
            ViewData["Str1"] = new SelectList(select3, "Value", "Text", "");
            if (string.IsNullOrEmpty(ID))
            {
                DBA.Model.Goods model = new DBA.Model.Goods();
                model.Str1 = "";
                return(View(model));
            }
            else
            {
                return(View(bll.GetModel(Convert.ToInt32(ID))));
            }
        }
        public ActionResult Edit(DBA.Model.RRecord model)
        {
            model.Time = DateTime.Now;
            DBA.Model.Goods Goods = bbll.GetModel(model.BookID);
            //model.CategoryID = Goods.CategoryID;
            //if (Goods.GoodsKC == null)
            //{
            //    Goods.GoodsKC = 0;
            //}
            //Goods.GoodsKC = Goods.GoodsKC + Convert.ToInt32(model.Str1);
            //bbll.Update(Goods);

            bll.Edit(model);
            return(RedirectToAction("RRecordManage"));
        }
        public ActionResult YEdit(DBA.Model.RRecord model)
        {
            DBA.Model.Goods Goods = bbll.GetModelList(" ISBN='" + model.ISBN + "'").FirstOrDefault();
            if (Goods.GoodsKC == null)
            {
                Goods.GoodsKC = 0;
            }
            Goods.GoodsKC  = Goods.GoodsKC + Convert.ToInt32(model.Str1);
            Goods.GoodsKey = model.Str2;
            bbll.Update(Goods);

            DBA.Model.RRecord model2 = bll.GetModel(model.ID);
            model2.Str5 = "已批准";
            bll.Update(model2);
            return(RedirectToAction("RRecordManage"));
        }
 public ActionResult Edit(DBA.Model.Goods model)
 {
     bll.Edit(model);
     return(RedirectToAction("GoodsManage"));
 }
示例#8
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(DBA.Model.Goods model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update Goods set ");
            strSql.Append("GoodsName=@GoodsName,");
            strSql.Append("GoodsCBS=@GoodsCBS,");
            strSql.Append("ISBN=@ISBN,");
            strSql.Append("GoodsZZ=@GoodsZZ,");
            strSql.Append("GoodsKC=@GoodsKC,");
            strSql.Append("Price=@Price,");
            strSql.Append("CategoryID=@CategoryID,");
            strSql.Append("Str1=@Str1,");
            strSql.Append("Str2=@Str2,");
            strSql.Append("GoodsKey=@GoodsKey,");
            strSql.Append("GoodsJJ=@GoodsJJ,");
            strSql.Append("Max=@Max,");
            strSql.Append("Min=@Min,");
            strSql.Append("WarnName=@WarnName");
            strSql.Append(" where ID=@ID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@GoodsName",  SqlDbType.NChar,     20),
                new SqlParameter("@GoodsCBS",   SqlDbType.NChar,     50),
                new SqlParameter("@ISBN",       SqlDbType.NChar,     10),
                new SqlParameter("@GoodsZZ",    SqlDbType.NChar,     10),
                new SqlParameter("@GoodsKC",    SqlDbType.Int,        4),
                new SqlParameter("@Price",      SqlDbType.NChar,     10),
                new SqlParameter("@CategoryID", SqlDbType.Int,        4),
                new SqlParameter("@Str1",       SqlDbType.NChar,     10),
                new SqlParameter("@Str2",       SqlDbType.NChar,     10),
                new SqlParameter("@GoodsKey",   SqlDbType.NChar,     10),
                new SqlParameter("@GoodsJJ",    SqlDbType.NChar,    500),
                new SqlParameter("@Max",        SqlDbType.NVarChar,  50),
                new SqlParameter("@Min",        SqlDbType.NVarChar,  50),
                new SqlParameter("@WarnName",   SqlDbType.NVarChar,  50),
                new SqlParameter("@ID",         SqlDbType.Int, 4)
            };
            parameters[0].Value  = model.GoodsName;
            parameters[1].Value  = model.GoodsCBS;
            parameters[2].Value  = model.ISBN;
            parameters[3].Value  = model.GoodsZZ;
            parameters[4].Value  = model.GoodsKC;
            parameters[5].Value  = model.Price;
            parameters[6].Value  = model.CategoryID;
            parameters[7].Value  = model.Str1;
            parameters[8].Value  = model.Str2;
            parameters[9].Value  = model.GoodsKey;
            parameters[10].Value = model.GoodsJJ;
            parameters[11].Value = model.Max;
            parameters[12].Value = model.Min;
            parameters[13].Value = model.WarnName;
            parameters[14].Value = model.ID;

            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
示例#9
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public DBA.Model.Goods DataRowToModel(DataRow row)
 {
     DBA.Model.Goods model = new DBA.Model.Goods();
     if (row != null)
     {
         if (row["ID"] != null && row["ID"].ToString() != "")
         {
             model.ID = int.Parse(row["ID"].ToString());
         }
         if (row["GoodsName"] != null)
         {
             model.GoodsName = row["GoodsName"].ToString();
         }
         if (row["GoodsCBS"] != null)
         {
             model.GoodsCBS = row["GoodsCBS"].ToString();
         }
         if (row["ISBN"] != null)
         {
             model.ISBN = row["ISBN"].ToString();
         }
         if (row["GoodsZZ"] != null)
         {
             model.GoodsZZ = row["GoodsZZ"].ToString();
         }
         if (row["GoodsKC"] != null && row["GoodsKC"].ToString() != "")
         {
             model.GoodsKC = int.Parse(row["GoodsKC"].ToString());
         }
         if (row["Price"] != null)
         {
             model.Price = row["Price"].ToString();
         }
         if (row["CategoryID"] != null && row["CategoryID"].ToString() != "")
         {
             model.CategoryID = int.Parse(row["CategoryID"].ToString());
         }
         if (row["Str1"] != null)
         {
             model.Str1 = row["Str1"].ToString();
         }
         if (row["Str2"] != null)
         {
             model.Str2 = row["Str2"].ToString();
         }
         if (row["GoodsKey"] != null)
         {
             model.GoodsKey = row["GoodsKey"].ToString();
         }
         if (row["GoodsJJ"] != null)
         {
             model.GoodsJJ = row["GoodsJJ"].ToString();
         }
         if (row["Max"] != null)
         {
             model.Max = row["Max"].ToString();
         }
         if (row["Min"] != null)
         {
             model.Min = row["Min"].ToString();
         }
         if (row["WarnName"] != null)
         {
             model.WarnName = row["WarnName"].ToString();
         }
         if (row["StoreHouse"] != null)
         {
             model.Storehouse = row["StoreHouse"].ToString();
         }
     }
     return(model);
 }