public void UpdateSupplierAndSalesAssistantInDB(ClassSupplier cs, ClassSalesAssistant csa)
 {
     try
     {
         FunctionExecuteStoredProcedures("UpdateSupplierAndSalesAssistant", "@supplierid", cs.id.ToString(), "@businessName", cs.businessName, "@address", cs.address, "@zip", cs.zipAndCity.Substring(0, cs.zipAndCity.LastIndexOf(" - ")), "@country", cs.country, "@supplierPhone", cs.phone, "@supplierMail", cs.mail, "@status", cs.status.ToString(), "@saID", cs.salesAssistantId.ToString(), "@name", csa.saName, "@phone", csa.saPhone, "@directPhone", csa.saDirectPhone, "@directMail", csa.saDirectMail);
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Fejl i DB kommunikationen", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Example #2
0
 public ClassBIZ()
 {
     textLock              = "true";
     comboLock             = "false";
     classCallWebAPI       = new ClassCallWebAPI();
     classLuxYachtDieselDB = new ClassLuxYachtDieselDB();
     currency              = new ClassCurrency();
     selectedCustomer      = new ClassCustomer();
     selectedSupplier      = new ClassSupplier();
     fallbackCustomer      = new ClassCustomer();
     fallbackSupplier      = new ClassSupplier();
     listCountry           = GetAllCountries();
     listDieselPrice       = GetAllDieselPricesForListFromDB();
     //country = new List<ClassCountry>();
     listCustomers = GetAllCustomersForListFromDB();
     listSupplier  = GetAllSuplliersForListFromDB();
     dieselPrice   = GetDieselPriceFromDB();
     order         = new ClassOrder();
 }
Example #3
0
        /// <summary>
        /// This method updates existing suppliers in the DB
        /// </summary>
        /// <param name="inSupplier">ClassSupplier</param>
        public void UpdateSupplierInDB(ClassSupplier inSupplier)
        {
            SqlCommand command = new SqlCommand();

            command.Connection  = con;
            command.CommandType = CommandType.StoredProcedure;
            command.CommandText = "spSupplier_Update";

            command.Parameters.Add("@supplierId", SqlDbType.Int).Value       = inSupplier.Id;
            command.Parameters.Add("@companyName", SqlDbType.NVarChar).Value = inSupplier.firmName;
            command.Parameters.Add("@contactName", SqlDbType.NVarChar).Value = inSupplier.contactName;
            command.Parameters.Add("@address", SqlDbType.NVarChar).Value     = inSupplier.address;
            command.Parameters.Add("@city", SqlDbType.NVarChar).Value        = inSupplier.city;
            command.Parameters.Add("@postalCode", SqlDbType.NVarChar).Value  = inSupplier.postalCode;
            command.Parameters.Add("@country", SqlDbType.Int).Value          = inSupplier.country.Id;
            command.Parameters.Add("@phone", SqlDbType.NVarChar).Value       = inSupplier.phone;
            command.Parameters.Add("@mail", SqlDbType.NVarChar).Value        = inSupplier.mailAdr;

            MakeCallToStoredProcedure(command);
        }
Example #4
0
        /// <summary>
        /// This method saves(inserts) new suppliers in the DB
        /// </summary>
        /// <param name="inSupplier">ClassSupplier</param>
        public void SaveSupplierInDB(ClassSupplier inSupplier)
        {
            SqlCommand command = new SqlCommand();             //

            command.Connection  = con;                         // Tell which db to connect to, con is declared in ClassDbCon
            command.CommandType = CommandType.StoredProcedure; // Declare which type of command we want to run
            command.CommandText = "spSuppliers_Insert";        // Name of our stored procedure

            // Our parameters for
            command.Parameters.Add("@companyName", SqlDbType.NVarChar).Value = inSupplier.firmName;
            command.Parameters.Add("@contactName", SqlDbType.NVarChar).Value = inSupplier.contactName;
            command.Parameters.Add("@address", SqlDbType.NVarChar).Value     = inSupplier.address;
            command.Parameters.Add("@city", SqlDbType.NVarChar).Value        = inSupplier.city;
            command.Parameters.Add("@postalCode", SqlDbType.NVarChar).Value  = inSupplier.postalCode;
            command.Parameters.Add("@country", SqlDbType.NVarChar).Value     = inSupplier.country.Id;
            command.Parameters.Add("@phone", SqlDbType.NVarChar).Value       = inSupplier.phone;
            command.Parameters.Add("@mail", SqlDbType.NVarChar).Value        = inSupplier.mailAdr;

            MakeCallToStoredProcedure(command); // Call method with our command as paramter. Is returned as a datatable
        }
Example #5
0
        /// <summary>
        /// This method gets data from the DB by calling a stored procedure.
        /// It calls the method MakeCallToStoredProcedure and sends command as a parametre.
        /// Command contains con(our connection string), the command type and the name of the stored procedure.
        /// As this method needs to get everthing from the table in the DB, we get several sets of data,
        /// hence we put the result of the call in a List.
        /// </summary>
        /// <returns>List<ClassSupplier>List<ClassSupplier></returns>
        public List <ClassSupplier> GetAllSuppliersFromDB()
        {
            List <ClassSupplier> listsupplierRes = new List <ClassSupplier>();
            SqlCommand           command         = new SqlCommand();

            command.Connection  = con;
            command.CommandType = CommandType.StoredProcedure;
            command.CommandText = "spSuppliers_GetAll";
            DataTable dataTable = MakeCallToStoredProcedure(command);

            foreach (DataRow row in dataTable.Rows)
            {
                ClassSupplier supplier = new ClassSupplier(); // Initialize a new empty instance of ClassPerson
                ClassCountry  country  = new ClassCountry();

                country.Id           = Convert.ToInt32(row["Id"]);
                country.country      = row["country"].ToString();
                country.countryCode  = row["countryCode"].ToString();
                country.currency     = row["currency"].ToString();
                country.currencyCode = row["currencyCode"].ToString();

                // Insert the values from the current row into each ones respective instance of ClassPerson
                supplier.Id          = Convert.ToInt32(row["supplierId"]);
                supplier.firmName    = row["companyName"].ToString();
                supplier.contactName = row["contactName"].ToString();
                supplier.address     = row["address"].ToString();
                supplier.city        = row["city"].ToString();
                supplier.postalCode  = row["postalCode"].ToString();
                supplier.country     = country;
                supplier.phone       = row["phone"].ToString();
                supplier.mailAdr     = row["mailAdr"].ToString();

                listsupplierRes.Add(supplier); // Instance of ClassPerson is inserted into listPersonRes which is of the datatype List<ClassPerson>
            }
            return(listsupplierRes);
        }
Example #6
0
 /// <summary>
 /// This method prompts the update of a customer to the DB
 /// </summary>
 public void UpdateSupplierInDB()
 {
     classLuxYachtDieselDB.UpdateSupplierInDB(selectedSupplier);
     selectedSupplier = new ClassSupplier();
     GetAllSuplliersForListFromDB();
 }
 /// <summary>
 /// Resetter ClassSupplier og ClassSalesAssistant, så de er klar til at få ny data ind
 /// </summary>
 public void ClearGrainSupplierData()
 {
     CS  = new ClassSupplier();
     CSA = new ClassSalesAssistant();
 }