Пример #1
0
        /////////////////////////////////////////////////////////////////////////// Update ///////////////////////////////////////////////////////
        public bool Update(ClassStock z)
        {
            bool isSuccess = false;

            SqlConnection conn2 = new SqlConnection(myid2);

            try
            {
                string sql2 = "UPDATE Stocks SET PatternID=@PatternID, PatternName=@PatternName, AvailableQty=@AvailableQty, AddedQty=@AddedQty, AddedDate=@AddedDate WHERE Sid=@Sid";

                SqlCommand cmd2 = new SqlCommand(sql2, conn2);

                cmd2.Parameters.AddWithValue("@Sid", z.Sid);
                cmd2.Parameters.AddWithValue("@PatternID", z.PatternID);
                cmd2.Parameters.AddWithValue("@PatternName", z.PatternName);
                cmd2.Parameters.AddWithValue("@AvailableQty", z.AvailableQty);
                cmd2.Parameters.AddWithValue("@AddedQty", z.AddedQty);
                cmd2.Parameters.AddWithValue("@AddedDate", z.AddedDate);

                conn2.Open();

                int rows = cmd2.ExecuteNonQuery();

                if (rows > 0)
                {
                    isSuccess = true;
                }
                else
                {
                    isSuccess = false;
                }
            }
            catch (Exception)
            {
            }

            finally
            {
                conn2.Close();
            }
            return(isSuccess);
        }
Пример #2
0
        /////////////////////////////////////////////////////////////////////////// Insert ///////////////////////////////////////////////////////
        public bool Insert(ClassStock z)
        {
            bool isSuccess = false;

            SqlConnection conn2 = new SqlConnection(myid2);

            try
            {
                string sql2 = "INSERT INTO Stocks(PatternID, PatternName, AvailableQty, AddedQty, AddedDate) VALUES(@PatternID, @PatternName, @AvailableQty, @AddedQty, @AddedDate)";

                SqlCommand cmd2 = new SqlCommand(sql2, conn2);

                //cmd2.Parameters.AddWithValue("@Sid", z.Sid);
                cmd2.Parameters.AddWithValue("@PatternID", z.PatternID);
                cmd2.Parameters.AddWithValue("@PatternName", z.PatternName);
                cmd2.Parameters.AddWithValue("@AvailableQty", z.AvailableQty);
                cmd2.Parameters.AddWithValue("@AddedQty", z.AddedQty);
                cmd2.Parameters.AddWithValue("@AddedDate", z.AddedDate);

                conn2.Open();

                int rows = cmd2.ExecuteNonQuery();

                if (rows > 0)
                {
                    isSuccess = true;
                }
                else
                {
                    isSuccess = false;
                }
            }

            catch (Exception)
            {
                conn2.Close();
            }

            return(isSuccess);
        }
Пример #3
0
        /////////////////////////////////////////////////////////////////////////// Delete ///////////////////////////////////////////////////////
        public bool Delete(ClassStock z)
        {
            bool isSuccess = false;

            SqlConnection conn2 = new SqlConnection(myid2);

            try
            {
                string sql2 = "DELETE FROM Stocks WHERE Sid=@Sid";

                SqlCommand cmd2 = new SqlCommand(sql2, conn2);

                cmd2.Parameters.AddWithValue("@Sid", z.Sid);

                conn2.Open();

                int rows = cmd2.ExecuteNonQuery();

                if (rows > 0)
                {
                    isSuccess = true;
                }
                else
                {
                    isSuccess = false;
                }
            }
            catch (Exception)
            {
            }
            finally
            {
                conn2.Close();
            }
            return(isSuccess);
        }