Ejemplo n.º 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;
            }
        }
Ejemplo n.º 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;
 }
Ejemplo n.º 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;
 }
Ejemplo n.º 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;
     }
 }