Exemplo n.º 1
0
        public int InsertCustomer(Customer cust)
        {
         
            string Query = "sp_customerdetails_insert";
            return new ConnectionManager().ExecuteNonQuery(Query, CreateParameters(cust));

        }
Exemplo n.º 2
0
 private IEnumerable<Customer> GetCustomers(string Query)
 {
     DataTable dt = new ConnectionManager().ExecuteGetDataTable(Query);
     List<Customer> lst = new List<Customer>();
     if (dt != null && dt.Rows.Count > 0)
     {
         foreach (DataRow r in dt.Rows)
         {
             Customer cs = new Customer();
             cs.Id = Convert.ToInt32(r["customer_id"]);
             cs.Name = r["first_name"].ToString();
             cs.Surname = r["last_name"].ToString();
             cs.Add = r["address"].ToString();
             cs.NameOfCom = r["name_of_com"].ToString();
             cs.Contact = r["contact_no"].ToString();
             cs.Mobile = r["mobile"].ToString();
             cs.Email= r["email_id"].ToString();
             lst.Add(cs);
         }
     }
     return lst;
 }
Exemplo n.º 3
0
 private SqlParameter[] CreateParameters(Customer cust)
 {
     SqlParameter[] param;
     int count = 0;
     if (cust.Id != 0)
     {
         param = new SqlParameter[8];
         param[0] = new SqlParameter("@customer_id", cust.Id);
         count++;
     }
     else
     {
         param = new SqlParameter[7];
     }
     param[count] = new SqlParameter("@first_name", cust.Name);
     param[count + 1] = new SqlParameter("@last_name", cust.Surname);            
     param[count + 2] = new SqlParameter("@address", cust.Add);
     param[count + 3] = new SqlParameter("@name_of_com", cust.NameOfCom);
     param[count + 4] = new SqlParameter("@contact_no", cust.Contact);
     param[count + 5] = new SqlParameter("@mobile", cust.Mobile);
     param[count + 6] = new SqlParameter("@email_id", cust.Email);
     return param;
 }
Exemplo n.º 4
0
        internal Customer GetAllCustData(string Query)
        {
            
            DataTable dt = new ConnectionManager().ExecuteGetDataTable(Query);
            List<Customer> lst = new List<Customer>();
            if (dt != null && dt.Rows.Count > 0)
            {

                Customer cs = new Customer();
                cs.Id = Convert.ToInt32(dt.Rows[0]["customer_id"]);
                cs.Name = dt.Rows[0]["first_name"].ToString();
                cs.Surname = dt.Rows[0]["last_name"].ToString();
                cs.Add = dt.Rows[0]["address"].ToString();
                cs.NameOfCom = dt.Rows[0]["name_of_com"].ToString();
                cs.Contact = dt.Rows[0]["contact_no"].ToString();
                cs.Mobile = dt.Rows[0]["mobile"].ToString();
                cs.Email = dt.Rows[0]["email_id"].ToString();
                return cs;

            }
            else
            {
                return null;
            }
           
        }
Exemplo n.º 5
0
        internal void UpdateOrder(int custo_id)
        {
            if (order == null)
                order = new Order();
            if (customer == null)
                customer = new Customer();

            string query = "SELECT * FROM Customer_Order where Customer_Id = " + custo_id;
            Order ord = new OrderManager().GetAllData(query);
            string query1 = "SELECT * FROM Customer_Details where customer_id = " + customer.Id;
            Customer cust = new CustomerManager().GetAllCustData(query1);

            order.CustomerId = customer.Id;
            if (ord.CustomerId > 0)
            {
                //Customer Order form
                ResetForm1_Update(true, false);
                txt_firstname.Text = customer.Name.ToString();
                txt_lastname.Text = customer.Surname.ToString();
                txt_contactno.Text = customer.Contact.ToString();
                txt_company.Text = customer.NameOfCom.ToString();

                txt_ordernum.Text = ord.OrderNo.ToString();
                cmb_tow.SelectedItem = ord.TypeOfWork.ToString();
                txt_noofcopy.Text = ord.NOC.ToString();
                txt_rate.Text = ord.Rate.ToString();
                txt_total.Text = ord.Total.ToString();
            }
            else
            {
                MessageBox.Show("Please provide the essential details!", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }
Exemplo n.º 6
0
        internal void UpdateCustomer(int custo_id)
        {
            if (customer == null)
                customer = new Customer();


            customer.Id = custo_id;
            string query = "SELECT * FROM Customer_Details where customer_id = " + customer.Id;
            Customer cust = new CustomerManager().GetAllCustData(query);

            if (cust.Id > 0)
            {
                //Personal Details Form
                ResetForm_Update(true, false);
                txt_fname.Text = cust.Name.ToString();
                txt_lname.Text = cust.Surname.ToString();
                txt_add.Text = cust.Add.ToString();
                txt_nameofcom.Text = cust.NameOfCom.ToString();
                txt_contact.Text = cust.Contact.ToString();
                txt_mobile.Text = cust.Mobile.ToString();
                txt_email.Text = cust.Email.ToString();


            }
            else
            {
                MessageBox.Show("Please provide the essential details!", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }
Exemplo n.º 7
0
        private void btn_add_Click(object sender, EventArgs e)
        {

            cs = new Customer();
            pnlentry.DataSource = cs;
            ResetForm(true, false);

        }