Example #1
0
        public static FurnitureStore GetStore()
        {
            var s = new FurnitureStore();

            using (var con = new SqlConnection(ConfigurationManager.ConnectionStrings["POP"].ConnectionString))
            {
                con.Open();

                SqlCommand     cmd = con.CreateCommand();
                SqlDataAdapter da  = new SqlDataAdapter();
                DataSet        ds  = new DataSet();

                cmd.CommandText  = "SELECT * FROM FurnitureStore;";
                da.SelectCommand = cmd;
                da.Fill(ds, "FurnitureStore");

                foreach (DataRow row in ds.Tables["FurnitureStore"].Rows)
                {
                    s.ID        = Convert.ToInt32(row["ID"]);
                    s.Name      = row["Name"].ToString();
                    s.Address   = row["Address"].ToString();
                    s.Phone     = row["Phone"].ToString();
                    s.Email     = row["Email"].ToString();
                    s.Website   = row["Website"].ToString();
                    s.CompanyNo = row["CompanyNo"].ToString();
                    s.AccountNo = row["AccountNo"].ToString();
                    s.Pib       = row["Pib"].ToString();
                }
            }
            return(s);
        }
        private void About_Click(object sender, RoutedEventArgs e)
        {
            FurnitureStore fs = new FurnitureStore();
            var            s  = Project.Instance.Store;

            fs.ID        = s.ID;
            fs.Name      = s.Name;
            fs.Phone     = s.Phone;
            fs.Address   = s.Address;
            fs.Email     = s.Email;
            fs.Website   = s.Website;
            fs.CompanyNo = s.CompanyNo;
            fs.AccountNo = s.AccountNo;
            fs.Pib       = s.Pib;
            StoreWindow sw = new StoreWindow(fs);

            sw.Show();
        }
Example #3
0
 public StoreWindow(FurnitureStore store)
 {
     InitializeComponent();
     if (Project.Instance.User.UserType.Equals(TypeOfUser.SALESMAN))
     {
         btnSave.Visibility = Visibility.Hidden;
     }
     this.store              = store;
     DataContext             = this;
     tbName.DataContext      = store;
     tbPhone.DataContext     = store;
     tbAddress.DataContext   = store;
     tbEmail.DataContext     = store;
     tbWebsite.DataContext   = store;
     tbCompanyNo.DataContext = store;
     tbAccountNo.DataContext = store;
     tbPib.DataContext       = store;
 }
Example #4
0
        public static void Update(FurnitureStore store)
        {
            try
            {
                using (var con = new SqlConnection(ConfigurationManager.ConnectionStrings["POP"].ConnectionString))
                {
                    con.Open();

                    SqlCommand cmd = con.CreateCommand();

                    cmd.CommandText  = "UPDATE FurnitureStore SET Name = @Name, Address = @Address, Phone = @Phone, Email = @Email, Website = @Website, CompanyNo = @CompanyNo, AccountNo=@AccountNo, Pib = @Pib;";
                    cmd.CommandText += "SELECT SCOPE_IDENTITY();";
                    cmd.Parameters.AddWithValue("Name", store.Name);
                    cmd.Parameters.AddWithValue("Address", store.Address);
                    cmd.Parameters.AddWithValue("Phone", store.Phone);
                    cmd.Parameters.AddWithValue("Email", store.Email);
                    cmd.Parameters.AddWithValue("Website", store.Website);
                    cmd.Parameters.AddWithValue("CompanyNo", store.CompanyNo);
                    cmd.Parameters.AddWithValue("AccountNo", store.AccountNo);
                    cmd.Parameters.AddWithValue("Pib", store.Pib);

                    cmd.ExecuteNonQuery();

                    var s = Project.Instance.Store;
                    s.Name      = store.Name;
                    s.Address   = store.Address;
                    s.Phone     = store.Phone;
                    s.Email     = store.Email;
                    s.Website   = store.Website;
                    s.CompanyNo = store.CompanyNo;
                    s.AccountNo = store.AccountNo;
                    s.Pib       = store.Pib;
                }
            }
            catch
            {
                MessageBox.Show("Database error!", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }