Exemplo n.º 1
0
 public int SaveSupplier(Supplier supplier)
 {
     SupplierDL supplierDL = new SupplierDL();
     if (supplier.SupplierID > 0)
         return supplierDL.UpdateSupplier(supplier);
     else
         return supplierDL.SaveSupplier(supplier);
 }
Exemplo n.º 2
0
        public int SaveSupplier(Supplier supplier)
        {
            int status = 0;
            using (SqlConnection objConn = new SqlConnection(WebConfigurationManager.ConnectionStrings["eshopConnectionString"].ConnectionString))
            {
                using (SqlCommand objComm = new SqlCommand("saveSupplier", objConn))
                {
                    objConn.Open();
                    objComm.CommandType = CommandType.StoredProcedure;
                    objComm.Parameters.Add("@name", SqlDbType.NVarChar, 50).Value = supplier.Name;

                    SqlParameter supplierID = new SqlParameter("@supplierID", SqlDbType.Int);
                    supplierID.Direction = ParameterDirection.Output;
                    objComm.Parameters.Add(supplierID);

                    status = objComm.ExecuteNonQuery();

                    supplier.SupplierID = int.Parse(objComm.Parameters["@supplierID"].Value.ToString());
                }
            }
            return supplier.SupplierID;
        }
Exemplo n.º 3
0
        public int UpdateSupplier(Supplier supplier)
        {
            int status = 0;
            using (SqlConnection objConn = new SqlConnection(WebConfigurationManager.ConnectionStrings["eshopConnectionString"].ConnectionString))
            {
                using (SqlCommand objComm = new SqlCommand("updateSupplier", objConn))
                {
                    objComm.CommandType = CommandType.StoredProcedure;
                    objComm.Parameters.Add("@name", SqlDbType.NVarChar, 50).Value = supplier.Name;

                    status = objComm.ExecuteNonQuery();
                }
            }
            return status;
        }