示例#1
0
        public bool addCustomer(Customer c)
        {
            try
            {
                int param = 5;

                string[] name = new string[param];
                object[] value = new object[param];

                name[0] = "@name"; value[0] = c.Name;
                name[1] = "@cmnd"; value[1] = c.Cmnd;
                name[2] = "@phonenumber"; value[2] = c.Phonenumber;
                name[3] = "@adress"; value[3] = c.Adress;
                name[4] = "@submit"; value[4] = c.Commit;
                int result = this.Update("customer_Insert", name, value, param);
                if (result != 0)
                {
                    return true;
                }
            }
            catch (System.Exception ex)
            {
                Console.WriteLine("Message = {1}", ex.Message);
            }

            return false;
        }
 public bool addCustomer(Customer c, out string customerId)
 {
     var result = customerDAT.addCustomer(c);
     if (result.Rows[0].ItemArray[0].ToString() == "0")
     {
         customerId = result.Rows[0].ItemArray[1].ToString();
         return true;
     }
     customerId = "";
     return false;
 }
示例#3
0
 public CustomerEdit(Customer c)
 {
     InitializeComponent();
     this.objCustomer = c;
     if (objCustomer != null)
     {
         this.idCustomerEdit.Text = c.Id;
         this.idCustomerEdit.ReadOnly = true;
         this.nameCustomerEdit.Text = c.Name;
         this.cmndCustomerEdit.Text = c.Cmnd;
         this.phoneCustomerEdit.Text = c.Phonenumber.ToString();
         this.addressCustomerEdit.Text = c.Adress;
         this.submitCus.Checked = c.Commit;
     }
 }
        //public bool addCustomer(Customer c)
        //{
        //    try
        //    {
        //        int param = 5;
        //        string[] name = new string[param];
        //        object[] value = new object[param];
        //        name[0] = "@name"; value[0] = c.Name;
        //        name[1] = "@cmnd"; value[1] = c.Cmnd;
        //        name[2] = "@phonenumber"; value[2] = c.Phonenumber;
        //        name[3] = "@adress"; value[3] = c.Adress;
        //        name[4] = "@submit"; value[4] = c.Commit;
        //        int result = this.Update("customer_Insert", name, value, param);
        //        if (result != 0)
        //        {
        //            return true;
        //        }
        //    }
        //    catch (System.Exception ex)
        //    {
        //        Console.WriteLine("Message = {1}", ex.Message);
        //    }
        //    return false;
        //}
        public DataTable addCustomer(Customer cus)
        {
            try
            {
                int param = 5;

                string[] name = new string[param];
                object[] value = new object[param];

                name[0] = "@p_NAME"; value[0] = cus.Name;
                name[1] = "@p_CMND"; value[1] = cus.Cmnd;
                name[2] = "@p_PHONENUMBER"; value[2] = cus.Phonenumber;
                name[3] = "@p_ADRESS"; value[3] = cus.Address;
                name[4] = "@p_SUBMIT"; value[4] = cus.Commit;

                return this.ExcuteStoreProcedure("CUSTOMER_Ins", name, value);
            }
            catch (System.Exception ex)
            {
                Console.WriteLine("Message = {1}", ex.Message);
            }

            return null;
        }
 public bool updateCustomer(Customer c)
 {
     return customerDAT.updateCustomer(c);
 }
        private void btnEditCustomer_Click(object sender, EventArgs e)
        {
            Customer cus = new Customer()
            {
                Id = txtCustomerId.Text,
                Name = txtCustomerName.Text,
                Address = txtAddress.Text,
                Cmnd = txtCMND.Text,
                Phonenumber = txtPhone.Text
            };

            CustomerEdit cusEdit = new CustomerEdit(cus);
            cusEdit.EditCompletedHandler += FormCustomerEdit_Completed;
            cusEdit.ShowDialog();
        }
示例#7
0
        public bool updateCustomer(Customer c)
        {
            try
            {

                string sql = "Update customer set name =('" + c.Name + "'), cmnd =('" + c.Cmnd + "'),  phonenumber =('" + c.Phonenumber + "'),  adress =('" + c.Adress + "') ,  submit =('" + c.Commit + "') where id = ('" + c.Id.Trim() + "')";
                int result = this.ExecuteNonQuery(sql);
                if (result != 0)
                {
                    return true;
                }
            }
            catch (System.Exception ex)
            {
                Console.WriteLine("Message = {1}", ex.Message);
            }
            return false;
        }