Esempio 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);
 }
Esempio 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;
        }
Esempio 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;
        }