Example #1
0
        public Entity.Item GetByID(int id)
        {
            /*
             * SqlDataReader dr;
             * cmd = new SqlCommand("Select * From Masro2.dbo.Item where IID = '" + id + "'", cn);
             * cn.Open();
             * dr = cmd.ExecuteReader();
             * Entity.Item item = null;
             * if (dr.Read())
             * {
             *  item = new Entity.Item(Convert.ToInt32(dr["IID"].ToString()),
             *      dr["Type"].ToString(), dr["Location"].ToString(), Convert.ToDateTime(dr["Date"].ToString()), dr["Description"].ToString(), (byte[])dr["Image"]);
             * }
             * dr.Close();
             * cn.Close();
             * return item;
             */
            Entity.Item    item = null;
            SqlDataAdapter da;
            DataSet        ds = new DataSet();

            da = new SqlDataAdapter("Select * From Masro2.dbo.Item where IID = '" + id + "'", cn);
            da.Fill(ds);

            item = new Entity.Item(Convert.ToInt32(ds.Tables[0].Rows[0]["IID"].ToString()),
                                   ds.Tables[0].Rows[0]["Type"].ToString(), ds.Tables[0].Rows[0]["Location"].ToString(),
                                   Convert.ToDateTime(ds.Tables[0].Rows[0]["Date"].ToString()), ds.Tables[0].Rows[0]["Description"].ToString(),
                                   (byte[])ds.Tables[0].Rows[0]["Image"]);
            return(item);
        }
 public int Add(Entity.Item item)
 {
     try
     {
         string query = string.Format("INSERT INTO Item(ItemCode, ItemName, Description, CategoryID, Price, Stock) VALUES('{0}', '{1}', '{2}', '{3}', {4}, {5})", item.ItemCode, item.ItemName, item.Description, item.CategoryID, item.Price, item.Stock);
         return(DataAccess.ExecuteQuery(query));
     }catch
     {
         System.Windows.Forms.MessageBox.Show("This itemcode is already assigned!");
     }
     return(0);
 }
 public int Edit(Entity.Item item)
 {
     try
     {
         string query = string.Format("UPDATE Item SET ItemName='" + item.ItemName + "', Description='" + item.Description + "', CategoryID='" + item.CategoryID + "', Price='" + item.Price + "', Stock='" + item.Stock + "' WHERE ItemCode='{0}'", item.ItemCode);
         return(DataAccess.ExecuteQuery(query));
     }
     catch
     {
         System.Windows.Forms.MessageBox.Show("This itemcode is already assigned!");
     }
     return(0);
 }
        private void addbutton_Click(object sender, EventArgs e)
        {
            MemoryStream ms = new MemoryStream();

            pictureBox.Image.Save(ms, pictureBox.Image.RawFormat);
            byte[]      picturebyte = ms.ToArray();
            Entity.Item item1       = new Entity.Item(postServices.GetCount() + 1, typecombo.Text, locationtext.Text
                                                      , dateTime.Value, descriptiontext.Text, picturebyte);
            postServices.AddPost(item1);

            AddQuestion frm = new AddQuestion();

            frm.IIdtext.Text = item1.getIID().ToString();
            frm.ShowDialog();
            this.Close();
        }
        private void button1_Click(object sender, EventArgs e)
        {
            AddItemForm frm = new AddItemForm();
            int         iID = Convert.ToInt32(dataGridView1.CurrentRow.Cells[0].Value.ToString());

            Entity.Item item1 = services.GetItemByID(iID);
            frm.typecombo.Text       = item1.getType();
            frm.dateTime.Value       = item1.getDate();
            frm.locationtext.Text    = item1.getLocation();
            frm.descriptiontext.Text = item1.getDescription();

            /*MemoryStream ms = new MemoryStream(item1.getImage());
             * frm.pictureBox.Image = Image.FromStream(ms);*/
            frm.browsebutton.Enabled = false;
            frm.addbutton.Enabled    = false;
            frm.ShowDialog();
        }
        public Entity.Item GetById(string id)
        {
            string        query  = "SELECT ItemCode, ItemName, Description, CategoryID, Price, Stock FROM Item";
            SqlDataReader reader = DataAccess.GetData(query);

            reader.Read();

            Entity.Item item = null;
            if (reader.HasRows)
            {
                item             = new Entity.Item(reader["ItemCode"].ToString());
                item.ItemName    = reader["ItemName"].ToString();
                item.Description = reader["Description"].ToString();
                item.CategoryID  = reader["CategoryID"].ToString();
                item.Price       = Convert.ToDouble(reader["Price"]);
                item.Stock       = Convert.ToInt32(reader["Stock"]);
            }
            return(item);
        }
        public List <Entity.Item> GetAll()
        {
            string        query  = "SELECT ItemCode, ItemName, Description, CategoryID, Price, Stock FROM Item";
            SqlDataReader reader = DataAccess.GetData(query);

            Entity.Item        item     = null;
            List <Entity.Item> itemList = new List <Entity.Item>();

            while (reader.Read())
            {
                item             = new Entity.Item(reader["ItemCode"].ToString());
                item.ItemName    = reader["ItemName"].ToString();
                item.Description = reader["Description"].ToString();
                item.CategoryID  = reader["CategoryID"].ToString();
                item.Price       = Convert.ToDouble(reader["Price"]);
                item.Stock       = Convert.ToInt32(reader["Stock"]);

                itemList.Add(item);
            }
            return(itemList);
        }
Example #8
0
        public void AddItem(Entity.Item item1)
        {
            try
            {
                cmd = new SqlCommand(

                    "insert into Masro2.dbo.Item (UserName,Type,Location,Date,Image,Description) values ('" + Program.username +
                    "','" + item1.getType() + "','" + item1.getLocation() + "','" + item1.getDate() + "','" + item1.getImage() +
                    "','" + item1.getDescription() + "')", cn);
                cn.Open();
                cmd.ExecuteNonQuery();
            }
            catch (SqlException ex)
            {
                //
            }
            finally
            {
                cn.Close();
            }
        }
Example #9
0
        public int AddMenuItem(Entity.Item item)
        {
            String Query = "INSERT into MENU (MENUID,MENUNAME,CATEGORYID) values ('" + item.MenuId + "','" + item.MenuName + "','" + item.CategoryId + "')";

            return(DataAccess.ExecuteQuery(Query));
        }
Example #10
0
 public void AddPost(Entity.Item item1) //add questions
 {
     itemAccess.AddItem(item1);
     //add questions
 }
Example #11
0
        public int AddCategory(Entity.Item item)
        {
            String Query = "INSERT into Category (CATEGORYID,CATEGORYNAME,IMAGE,CATEGORYPRICE,DEPTID) values ('" + item.CategoryId + "','" + item.CategoryName + "','" + item.Image + "','" + item.CategoryPrice + "','" + item.DeptId + "')";

            return(DataAccess.ExecuteQuery(Query));
        }
Example #12
0
        public int AddDept(Entity.Item item)
        {
            String Query = "INSERT into Department (DEPTID,DEPTNAME) values ('" + item.DeptId + "','" + item.DeptName + "')";

            return(DataAccess.ExecuteQuery(Query));
        }
Example #13
0
 public int Edit(Entity.Item item)
 {
     return(ItemService.itemDataAccess.Edit(item));
 }
Example #14
0
 public int Add(Entity.Item item)
 {
     return(ItemService.itemDataAccess.Add(item));
 }