예제 #1
0
 public static bool InsertCustomer(Customer cus)
 {
     string sql = "spAddCustomer";
     SqlParameter CustomerID = new SqlParameter("CustomerID",cus.CustomerID);
     SqlParameter Name = new SqlParameter("Name", cus.Name);
     SqlParameter Address = new SqlParameter("Address", cus.Address);
     SqlParameter Phone = new SqlParameter("Phone", cus.Phone);
     return DataProvider.ExecuteNonQuery(sql, System.Data.CommandType.StoredProcedure, CustomerID,Name,Address,Phone);
 }
예제 #2
0
        private void btnOk_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                Customer cus = new Customer();
                cus.CustomerID = txtCustomerID.Text;
                cus.Name= txtFullName.Text;
                cus.Address =txtAddress.Text;
                cus.Phone = txtFullName.Text;
                bool sameID = false;
                var rows = dt.Rows;
                foreach (DataRow datarow in rows)
                {
                    if (datarow["CustomerID"].ToString().Equals(cus.CustomerID))
                    {
                        sameID = true;
                        break;
                    }
                }
                if (!sameID)
                {
                    CustomerBLL.AddCustomer(cus);
                    System.Windows.Forms.MessageBox.Show("Successfully");

                    if (AddFinished != null)
                    {
                        AddFinished(cus);
                    }
                }
                else
                {
                    System.Windows.Forms.MessageBox.Show("This ID was existed!!");
                }
            }
            catch (Exception g)
            {
                System.Windows.Forms.MessageBox.Show("Error: " + g.Message);
            }
            finally
            {
                this.Close();
            }
        }
예제 #3
0
 public static List<Customer> SelectAll()
 {
     List<Customer> cusList = new List<Customer>();
     string SelectAllCus = "spGetAllCustomer";
     SqlDataReader rd = DataProvider.ExecuteQueryWithDataReader(SelectAllCus, CommandType.StoredProcedure);
     if (rd.HasRows)
     {
         while (rd.Read())
         {
             Customer r = new Customer()
             {
                 CustomerID = rd.GetString(0),
                 Name = rd.GetString(1),
                 Address = rd.GetString(2),
                 Phone = rd.GetString(3),
                 Active = rd.GetBoolean(4)
             };
             cusList.Add(r);
         }
     }
     return cusList.OrderBy(p => p.CustomerID).ToList();
 }
예제 #4
0
 public static bool AddCustomer(Customer cus)
 {
     return CustomerData.InsertCustomer(cus);
 }