Exemple #1
0
        public bool Insert(StringBuilder message, TipSkladista objekt)
        {
            SqlCommand sqlUpit = new SqlCommand();

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

            sqlUpit.CommandText = "Insert Into MT_TipSkladista (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);
            }
        }
Exemple #2
0
        public bool Update(StringBuilder message, TipSkladista objekt)
        {
            SqlCommand sqlUpit = new SqlCommand();

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

            sqlUpit.CommandText = "Update MT_TipSkladista 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);
            }
        }