Exemplo n.º 1
0
        public static List <string> getStoreroomList()
        {
            Storeroom       storeroom = new Storeroom();
            List <string>   flist     = new List <string>();
            MySqlDataReader rdr       = null;

            try
            {
                string tableName = "storeroom";
                string query     = "SELECT * FROM " + tableName;

                MySqlCommand cmd = new MySqlCommand(query, MysqlDbc.Instance.getConn());
                rdr = cmd.ExecuteReader();

                while (rdr.Read())
                {
                    storeroom.Description = rdr.GetString("description");
                    flist.Add(storeroom.Description);
                }
            }
            catch (MySqlException ex)
            {
                Console.WriteLine("Error: {0}", ex.ToString());
            }
            finally
            {
                if (rdr != null)
                {
                    rdr.Close();
                }
            }

            return(flist);
        }
        public IActionResult Create(StoreroomEditViewModel model)
        {
            if (ModelState.IsValid)
            {
                var storeroom = new Storeroom()
                {
                    Name = model.Name
                };
                Storeroom storeroomCreated = _storeroomData.Add(storeroom);

                return(RedirectToAction(nameof(Details), new { id = storeroomCreated.Id }));
            }
            else
            {
                return(View());
            }
        }
Exemplo n.º 3
0
        //新加的按照用户编号查询的接口2020-04-07
        static public Storeroom QueryByUserNum(string userNum)
        {
            string        command = $"select storeID from [User] where num = '{userNum}'";
            SqlDataReader read    = SQL.getData(command);

            if (read == null)
            {
                SQL.Dispose();
                return(null);
            }
            if ((int)read["storeID"] == -1)
            {
                SQL.Dispose();
                return(null);
            }
            Storeroom storeroom = new Storeroom((int)read["storeID"], null, null, null);

            SQL.Dispose();
            return(storeroom);
        }
Exemplo n.º 4
0
        public void addStock()
        {
            Storeroom store = new Storeroom();

            store.Description = descriptionText.Text;
            store.StoringQty  = Convert.ToInt32(storeNumericUpDown.Value);
            store.Temperature = Int32.Parse(tempText.Text);
            bool avail        = false;
            int  availability = availabilityBox.SelectedIndex;

            if (availability == 1)
            {
                avail = true;
            }
            store.Availability = avail;
            InsertSQL storeHnd  = new InsertSQL();
            int       addrecord = storeHnd.addNewStore(store);

            MessageBox.Show(addrecord + " Your record is added");
        }
        public static bool Login(string username, string password, out string msg)
        {
            password = GenerateMD5(password);
            Dictionary <string, string> dictionary = UserDAL.QueryByUserName(username, password, out msg);

            if (dictionary == null)
            {
                return(false);
            }
            if (dictionary["authority"].Substring(4).Contains("1"))
            {
                Storeroom storeroom = StoreroomDAL.QueryByUserNum(dictionary["num"]);
                if (storeroom != null)
                {
                    dictionary.Add("storeID", storeroom.id.ToString());
                }
            }
            HttpContext.Current.Session["user"] = dictionary;
            return(true);
        }
Exemplo n.º 6
0
        static public bool Add(Storeroom storeroom, out string msg)
        {
            string command = $"insert into Storeroom(name,site) values('{storeroom.name}','{storeroom.site}');";

            try
            {
                msg = null;
                return(SQL.Excute(command));
            }
            catch (SqlException e)
            {
                if (e.Number == 2627)
                {
                    msg = "请检查仓库名称是否重复或库管员是否已经绑定仓库";
                }
                else
                {
                    msg = e.Message;
                }
                return(false);
            }
        }
Exemplo n.º 7
0
        static public bool Update(Storeroom storeroom, out string msg)
        {
            string command = $"update Storeroom set name = '{storeroom.name}',site = '{storeroom.site}' where id = '{storeroom.id}'";

            try
            {
                msg = null;
                return(SQL.Excute(command));
            }
            catch (SqlException e)
            {
                if (e.Number == 2627)
                {
                    msg = "请检查仓库名称是否重复或库管员是否已经绑定仓库";
                }
                else
                {
                    msg = e.Message;
                }
                return(false);
            }
        }
Exemplo n.º 8
0
        public Storeroom GetStoreroomFromID(int itemId)
        {
            Storeroom ss1 = new Storeroom();

            MySqlDataReader rdr = null;

            try
            {
                string tableName = "storeroom";
                string query     = "SELECT * FROM " + tableName + " WHERE id = " + itemId;

                MySqlCommand cmd = new MySqlCommand(query, MysqlDbc.Instance.getConn());
                rdr = cmd.ExecuteReader();

                while (rdr.Read())
                {
                    ss1.Id           = itemId;
                    ss1.Description  = rdr.GetString("description");
                    ss1.StoringQty   = rdr.GetInt32("storingQty");
                    ss1.Temperature  = rdr.GetInt32("temperature");
                    ss1.Availability = rdr.GetBoolean("availability");
                }
            }
            catch (MySqlException ex)
            {
                Console.WriteLine("Error: {0}", ex.ToString());
            }
            finally
            {
                if (rdr != null)
                {
                    rdr.Close();
                }
            }

            return(ss1);
        }
 public Storeroom Add(Storeroom storeroom)
 {
     _context.Storerooms.Add(storeroom);
     _context.SaveChanges();
     return(storeroom);
 }
 static public bool Add(Storeroom storeroom, out string msg)
 {
     return(StoreroomDAL.Add(storeroom, out msg));
 }
 static public bool Update(Storeroom storeroom, out string msg)
 {
     return(StoreroomDAL.Update(storeroom, out msg));
 }
 public Storeroom Add(Storeroom storeroom)
 {
     storeroom.Id = _storerooms.Max(s => s.Id) + 1;
     _storerooms.Add(storeroom);
     return(storeroom);
 }