public int Puts(Stockin m)
 {
     System.Random rdn = new System.Random();
     m.OrderNo    = Convert.ToInt32(rdn.Next(99999999).ToString().PadLeft(8, '0'));
     m.CreateDate = DateTime.Now.ToString();
     return(dal.Upt(m));
 }
Example #2
0
        public IActionResult StockInAdd(Stockin stockin)
        {
            stockin.CreateDate    = DateTime.Now;
            stockin.StockInStatus = 1;
            bool b = _stockin.Add(stockin);

            return(Json(AjaxResult(b)));
        }
        //Check Error
        public bool IsError(Stockin stockin)
        {
            if (!(string.IsNullOrEmpty(stockin.ErrorText)))
            {
                return(true);
            }

            return(false);
        }
        //Verified Field
        public bool IsVerified(Stockin stockin)
        {
            if (string.IsNullOrEmpty(stockin.Item) || string.IsNullOrEmpty(stockin.Category) || string.IsNullOrEmpty(stockin.Company) || string.IsNullOrEmpty(stockin.SIQuantity.ToString()))
            {
                return(true);
            }

            return(false);
        }
Example #5
0
        //Update Item
        public bool IsAdd(Stockin stockin)
        {
            SqlConnection conn    = new SqlConnection(connection.connectionDb);
            string        query   = @"update Inventory set Quantity = (select Quantity from Inventory Where ItemId = (Select Id from Items where name = '" + stockin.Item + "') ) + " + stockin.SIQuantity + " Where ItemId = (Select Id from Items where name = '" + stockin.Item + "')";
            SqlCommand    command = new SqlCommand(query, conn);

            conn.Open();
            bool isRowAffected = command.ExecuteNonQuery() > 0;

            conn.Close();
            return(isRowAffected);
        }
        public IActionResult Post([FromBody] Stockin m)
        {
            System.Random rdn = new System.Random();
            m.OrderNo       = Convert.ToInt32(rdn.Next(99999999).ToString().PadLeft(8, '0'));
            m.StockInStatus = 0;
            m.CreateDate    = DateTime.Now.ToString();
            //存放数据
            _redis.StringSet("Adds", dal.Add(m));
            //取出数据
            var Addss = _redis.StringGet("Adds");

            return(new JsonResult(Addss));
        }
Example #7
0
        //Load Items
        public DataTable LoadItem(Stockin stockin)
        {
            SqlConnection conn    = new SqlConnection(connection.connectionDb);
            string        query   = @"SELECT * FROM Items WHERE CategoryId = " + stockin.CategoryId + " AND CompanyId = " + stockin.CompanyId + " ";
            SqlCommand    command = new SqlCommand(query, conn);

            conn.Open();
            SqlDataReader sd = command.ExecuteReader();
            DataTable     dt = new DataTable();

            dt.Load(sd);
            conn.Close();
            return(dt);
        }
Example #8
0
        public PageStu Show(Stockin person, int CurrentPage = 1, int PageSize = 10)
        {
            using (IDbConnection connection = new SqlConnection(conn.ConnectionString))
            {
                var sql = @"select * from Stockin where StockInStatus=" + person.StockInStatus;
                if (person.StockInType != "")
                {
                    sql += " and StockInType=@stockInType";
                }
                if (person.CreateDate != "" && person.ModifiedDate != "")
                {
                    sql += "and CreateDate>=@createDate and ModifiedDate<=@modifiedDate";
                }

                var     list = connection.Query <Stockin>(sql, new { stockInType = person.StockInType, createDate = person.CreateDate, modifiedDate = person.ModifiedDate }).ToList();
                PageStu ps   = new PageStu();      //实例化

                ps.TotalCount = list.Count();      //总记录数

                if (ps.TotalCount % PageSize == 0) //计算总页数
                {
                    ps.TotalPage = ps.TotalCount / PageSize;
                }
                else
                {
                    ps.TotalPage = (ps.TotalCount / PageSize) + 1;
                }
                //纠正index页
                if (CurrentPage < 1)
                {
                    CurrentPage = 1;
                }
                if (CurrentPage > ps.TotalPage)
                {
                    CurrentPage = ps.TotalPage;
                }
                //赋值index为当前页
                ps.CurrentPage = CurrentPage;
                //linq查询
                ps.stockins = list.Skip(PageSize * (CurrentPage - 1)).Take(PageSize).ToList();
                return(ps);
            }
        }
Example #9
0
        public IActionResult StockinEdit(Stockin stockin)
        {
            var model = _stockin.GetModel(c => c.StockInId == stockin.StockInId);

            if (model == null)
            {
                return(Json(Failed("查询不到数据")));
            }
            model.StockInId     = stockin.StockInId;
            model.StockInNo     = stockin.StockInNo;
            model.StockInStatus = stockin.StockInStatus;
            model.StockInType   = stockin.StockInType;
            model.SupplierId    = stockin.SupplierId;
            model.OrderNo       = stockin.OrderNo;
            model.Remark        = stockin.Remark;
            model.CreateBy      = stockin.CreateBy;
            model.CreateDate    = stockin.CreateDate;
            model.ModifiedBy    = stockin.ModifiedBy;
            model.ModifiedDate  = stockin.ModifiedDate;

            bool b = _stockin.Update(model);

            return(Json(AjaxResult(b)));
        }
        //Save Category
        public bool IsAdded(Stockin stockin)
        {
            bool add = stockinRepository.IsAdd(stockin);

            return(add);
        }
Example #11
0
        //修改
        public int Upt(Stockin m)
        {
            string sql = string.Format("update Stockin set SupplierId='{0}',OrderNo='{1}',StockInStatus='{2}',Remark='{3}',CreateBy='{4}',CreateDate='{5}',ModifiedBy='{6}',ModifiedDate='{7}' where StockInId={8}", m.SupplierId, m.OrderNo, m.StockInStatus, m.Remark, m.CreateBy, m.CreateDate, m.ModifiedBy, m.ModifiedDate, m.StockInId);

            return(DBHelper.ExecuteNonQuery(sql));
        }
Example #12
0
        //显示入库库存列表
        //public List<Stockin> Show()
        //{
        //    string sql = "select * from Stockin";
        //    return DBHelper.GetToList<Stockin>(sql);
        //}
        //添加入库库存
        public int Add(Stockin m)
        {
            string sql = string.Format("insert into Stockin values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}')", m.StockInType, m.SupplierId, m.OrderNo, m.StockInStatus, m.Remark, m.CreateBy, m.CreateDate, m.ModifiedBy, m.ModifiedDate);

            return(DBHelper.ExecuteNonQuery(sql));
        }
Example #13
0
 public PageStu Gets(Stockin person)
 {
     return(dal.Show(person));
 }