コード例 #1
0
ファイル: MainWindow.xaml.cs プロジェクト: kylealelis/.net2
        private void Button_Save_Credentials_Click(object sender, RoutedEventArgs e)
        {
            CustDetails collect = new CustDetails();

            //prevent errors
            collect.Cust_Id        = long.Parse(txtbox_CustomerID_CustomerManager.Text);
            collect.Cust_FirstName = FirstName.Text;
            collect.Cust_LastName  = LastName.Text;
            collect.Cust_Address   = tb_CustomerMan_Address.Text;
            if (comboBox.SelectedIndex == 0)
            {
                collect.Cust_Gender = "M";
            }
            else if (comboBox.SelectedIndex == 1)
            {
                collect.Cust_Gender = "F";
            }
            else
            {
                MessageBox.Show("Invalid Combo Box Index");
            }

            collect.Cust_Contact_No = long.Parse(Phone.Text);
            CustomerDAL.UpdateCustomer(collect);
            ClearCust();
        }
コード例 #2
0
ファイル: CustomerDAL.cs プロジェクト: kystring/.net2
        public static void UpdateCustomer(CustDetails obj)
        {
            try
            {
                using (SqlConnection connection = new SqlConnection(connString))
                    using (SqlCommand command = new SqlCommand("Customer.UpdateByCustomerId", connection))
                    {
                        connection.Open();
                        command.CommandType = CommandType.StoredProcedure;
                        command.Parameters.Add("Cust_Id", SqlDbType.Int).Value = obj.Cust_Id.ToDbParameter();
                        command.Parameters.Add("Cust_FirstName", SqlDbType.VarChar, 256).Value = obj.Cust_FirstName.ToDbParameter();
                        command.Parameters.Add("Cust_LastName", SqlDbType.VarChar, 50).Value   = obj.Cust_LastName.ToDbParameter();
                        command.Parameters.Add("Cust_Gender", SqlDbType.VarChar, 1).Value      = obj.Cust_Gender.ToDbParameter();
                        command.Parameters.Add("Cust_Address", SqlDbType.VarChar, 256).Value   = obj.Cust_Address.ToDbParameter();
                        command.Parameters.Add("Cust_Contact_No", SqlDbType.BigInt).Value      = obj.Cust_Contact_No.ToDbParameter();

                        command.ExecuteNonQuery();
                        connection.Close();
                        MessageBox.Show("Succesful Update Customer Details", "SUCCESFULL", MessageBoxButton.OK, MessageBoxImage.Information, MessageBoxResult.OK);
                    }
            }
            catch (Exception ex)
            {
                MessageBox.Show("ERROR: " + ex, "SQL Error", MessageBoxButton.OK, MessageBoxImage.Error, MessageBoxResult.OK);
            }
        }
コード例 #3
0
ファイル: CustomerDAL.cs プロジェクト: kystring/.net2
        public static List <CustDetails> searchByCustomer(long id)
        {
            List <CustDetails> search = new List <CustDetails>();

            try
            {
                using (SqlConnection connection = new SqlConnection(connString))
                    using (SqlCommand command = new SqlCommand("Customer.SearchByCustId", connection))
                    {
                        connection.Open();
                        command.CommandType = CommandType.StoredProcedure;
                        command.Parameters.AddWithValue("@Cust_Id", id);

                        using (SqlDataReader reader = command.ExecuteReader())
                        {
                            while (reader.Read())
                            {
                                CustDetails p = new CustDetails();
                                p.Cust_FirstName  = reader.SafeGetString(0);
                                p.Cust_LastName   = reader.SafeGetString(1);
                                p.Cust_Gender     = reader.SafeGetString(2);
                                p.Cust_Address    = reader.SafeGetString(3);
                                p.Cust_Contact_No = reader.GetInt64(4);
                                search.Add(p);
                            }
                        }
                    }
            }
            catch (Exception ex)
            {
                MessageBox.Show("ERROR: " + ex, "SQL Error", MessageBoxButton.OK, MessageBoxImage.Error, MessageBoxResult.OK);
            }

            return(search);
        }
コード例 #4
0
ファイル: MainWindow.xaml.cs プロジェクト: kylealelis/.net2
        public void Register()
        {
            CustDetails collect = new CustDetails();

            collect.Cust_FirstName = FirstName.Text;
            collect.Cust_LastName  = LastName.Text;
            collect.Cust_Address   = tb_CustomerMan_Address.Text;
            if (comboBox.Text == "Male")
            {
                collect.Cust_Gender = "M";
            }
            else
            {
                collect.Cust_Gender = "F";
            }

            collect.Cust_Contact_No = long.Parse(Phone.Text);

            CustomerDAL.addCustomer(collect);
        }