示例#1
0
        public bool Insert(StringBuilder message, GrupeProizvoda objekt)
        {
            SqlCommand sqlUpit = new SqlCommand();

            sqlUpit.Connection  = client.sqlConnection;
            sqlUpit.CommandType = CommandType.Text;

            sqlUpit.CommandText = "Insert Into MT_GrupeProizvoda (Naziv, TS) Values (@Naziv, @TS)";

            sqlUpit.Parameters.Add(new SqlParameter("@Naziv", objekt.pNaziv));
            sqlUpit.Parameters.Add(new SqlParameter("@TS", DateTime.Now));

            try
            {
                sqlUpit.ExecuteNonQuery();
                return(true);
            }
            catch (SqlException greska)
            {
                message.Append(greska.Message);
                return(false);
            }
            catch (Exception greska)
            {
                message.Append(greska.Message);
                return(false);
            }
        }
示例#2
0
        public bool Update(StringBuilder message, GrupeProizvoda objekt)
        {
            SqlCommand sqlUpit = new SqlCommand();

            sqlUpit.Connection  = client.sqlConnection;
            sqlUpit.CommandType = CommandType.Text;

            sqlUpit.CommandText = "Update MT_GrupeProizvoda Set Naziv = @Naziv, TS = @TS Where ID = @ID";

            sqlUpit.Parameters.Add(new SqlParameter("@Naziv", objekt.pNaziv));
            sqlUpit.Parameters.Add(new SqlParameter("@ID", pID));
            sqlUpit.Parameters.Add(new SqlParameter("@TS", DateTime.Now));

            try
            {
                sqlUpit.ExecuteNonQuery();
                return(true);
            }
            catch (SqlException greska)
            {
                message.Append(greska.Message);
                return(false);
            }
            catch (Exception greska)
            {
                message.Append(greska.Message);
                return(false);
            }
        }