예제 #1
0
        public static Seller GetSeller(int sellerId)
        {
            try
            {
                var dbConn = Functions.GetConnection();
                var seller = new Seller();
                using (dbConn)
                {
                    dbConn.Open();
                    var cmd = dbConn.CreateCommand();
                    cmd.CommandType = CommandType.Text;
                    cmd.CommandText = "SELECT * FROM Seller WHERE Id = " + sellerId;
                    var rdr = cmd.ExecuteReader();
                    while (rdr.Read())
                    {
                        seller = new Seller(int.Parse(rdr["Id"].ToString()), rdr["Name"].ToString(), rdr["Phone"].ToString(), rdr["Comment"].ToString(), rdr["Email"].ToString());
                    }
                }

                if (seller.SellerNo == -1)
                {
                    throw new Exception("Felaktigt försäljarenummer");
                }
                return seller;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
예제 #2
0
 private void SetupNewSeller()
 {
     var seller = new Seller();
     int nextSellerNo = Seller.GetNextSellerNo();
     seller.SellerNo = nextSellerNo;
     txtNummer.Text = seller.SellerNo.ToString();
     txtNamn.Text = seller.Name;
     txtNamn.Select();
     txtEmail.Text = seller.Email;
     txtKommentar.Text = seller.Comment;
     txtTelefon.Text = seller.Telephone;
 }
예제 #3
0
 private void ShowSellerDetails(Seller seller)
 {
     txtNummer.Text = seller.SellerNo.ToString();
     txtNamn.Text = seller.Name;
     txtEmail.Text = seller.Email;
     txtTelefon.Text = seller.Telephone;
     txtKommentar.Text = seller.Comment;
 }
예제 #4
0
 private void SaveSeller()
 {
     try
     {
         var seller = new Seller();
         seller.Name = txtNamn.Text;
         seller.Comment = txtKommentar.Text;
         seller.Email = txtEmail.Text;
         seller.SellerNo = int.Parse(txtNummer.Text);
         seller.Telephone = txtTelefon.Text;
         seller.Save();
         GetSellerStatistics();
     }
     catch (Exception ex)
     {
         toolStripStatusLabel1.Text = ex.Message;
     }
 }