Пример #1
0
        public static void SetBAddr(DataRow bAddr)
        {
            String connString = Properties.Settings.Default.FAFOS;
            SqlConnection con = new SqlConnection(connString);
            SqlCommand BAddrsCommand;
            MFranchise f = new MFranchise();
            if (bAddr["locID"].ToString() == "")
            {
                String newID = f.getNewID("location_id", "Franchisee_Business_Address");
                BAddrsCommand = new SqlCommand("INSERT INTO Franchisee_Business_Address VALUES ("
                                                                            + newID + ", '"
                                                                            + bAddr["bAddr"].ToString() + "', '"
                                                                            + bAddr["bPostal"].ToString() + "', "
                                                                            + bAddr["bProvince"].ToString() + ", "
                                                                            + bAddr["bCity"].ToString() + ", "
                                                                            + bAddr["bCountry"].ToString() + ", "
                                                                            + Properties.Settings.Default.FranchiseeID + ")", con);

            }
            else
            {
                BAddrsCommand = new SqlCommand("UPDATE Franchisee_Business_Address " +
                                                  "SET address = '" + bAddr["bAddr"].ToString() +
                                               "', postal_code = '" + bAddr["bPostal"].ToString() +
                                               "', province_id = " + bAddr["bProvince"].ToString() +
                                                   ", city_id = " + bAddr["bCity"].ToString() +
                                                ", country_id = " + bAddr["bCountry"].ToString() +
                                            " WHERE location_id = " + bAddr["locID"].ToString(), con);

            }
            con.Open();
            BAddrsCommand.ExecuteNonQuery();
            con.Close();
        }
Пример #2
0
        public static void Set(DataRow usr)
        {
            MFranchise f = new MFranchise();
            String connString = Properties.Settings.Default.FAFOS;
            SqlConnection con = new SqlConnection(connString);
            SqlCommand UsersCommand;
            int n = usr.ItemArray.Length;
            for (int i = 0; i < n; i++)
                if (usr[i].ToString() == "")
                    usr[i] = "NULL";

            if (usr["usrIDCol"].ToString() == "NULL") // Create new User
            {
                string newID = f.getNewID("user_id", "[User]");// assign user id
                List<Bitmap> piclist = LoadImages();
                string newPicID = piclist.Count.ToString();
                piclist.Add(Properties.Resources.DefaultProPic);
                SaveImages(piclist);

                List<Bitmap> test = LoadImages();

                UsersCommand = new SqlCommand("INSERT INTO [User] VALUES (" + newID + ", '"
                                                                            + usr["fName"].ToString() + "', '"
                                                                            + usr["lName"].ToString() + "', '"
                                                                            + usr["mName"].ToString() + "', '"
                                                                            + usr["usrName"].ToString() + "', '"
                                                                            + usr["passSetCol"].ToString() + "', "
                                                                            + "'<empty>','<empty>','<empty>','<empty>','<empty>','<empty>','<empty>','<empty>', '"
                                                                            + usr["hqCol"].ToString() + "', '"
                                                                            + usr["adminCol"].ToString() + "', "
                                                                            + usr["PerOwnCol"].ToString()
                                                                            + ",1,1,1, "
                                                                            + Properties.Settings.Default.FranchiseeID + ", "
                                                                            + newPicID + ")", con);

            }
            else
            {
                UsersCommand = new SqlCommand("UPDATE [User] SET first_nm = '" + usr["fName"].ToString() +
                                                                "', last_nm = '" + usr["lName"].ToString() +
                                                              "', middle_nm = '" + usr["mName"].ToString() +
                                                               "', username = '******', password = '******', hq_user = '******', admin_user = '******', percentage_ownership = " + usr["PerOwnCol"].ToString() +
                                                             " WHERE user_id = " + usr["usrIDCol"].ToString(), con);

            }
            con.Open();
            UsersCommand.ExecuteNonQuery();
            con.Close();
        }