Beispiel #1
0
        private SqlParameter[] Createparameters(Order order)
        {
            SqlParameter[] param;
            int count = 0;
            if (order.ID != 0)
            {
                param = new SqlParameter[8];
                param[0] = new SqlParameter("User_id", order.ID);
                count++;
            }
            else
            {
                param = new SqlParameter[7];
            }


            param[count] = new SqlParameter("@order_no", order.OrderNo);
            param[count + 1] = new SqlParameter("@date", order.Date);
            //Combobox
            param[count + 2] = new SqlParameter("@type_of_work", order.TypeOfWork.ToString());

            param[count + 3] = new SqlParameter("@no_of_copies", order.NOC);
            param[count + 4] = new SqlParameter("@rate", order.Rate);
            param[count + 5] = new SqlParameter("@total", order.Total);
            param[count + 6] = new SqlParameter("customer_id", order.CustomerId);
            return param;

        }
Beispiel #2
0
        private void dgv_order_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex > -1 && e.ColumnIndex > -1)
            {
                string txtval = txt_searchfield.Text;
                if (order == null)
                    order = new Order();


                order.CustomerId = new OrderManager().GetCustId(cb_search.SelectedItem.ToString(), txtval);

                //Edit
                if (e.ColumnIndex == 0)
                {
                    Personal_Details pd = new Personal_Details();
                    pd.UpdateCustomer(order.CustomerId);
                    pd.UpdateOrder(order.CustomerId);
                    pd.ShowDialog();

                } //Delete
                else if (e.ColumnIndex == 1)
                {

                }
            }
        }
Beispiel #3
0
        public IEnumerable<Order> GetAllOrders()
        {
            string Query = "sp_customerorder_select";
            DataTable dt = new ConnectionManager().ExecuteGetDataTable(Query);

            List<Order> lst = new List<Order>();
            if (dt != null && dt.Rows.Count > 0)
            {
                foreach (DataRow r in dt.Rows)
                {
                    Order order = new Order();
                    order.ID = Convert.ToInt32(r["User_id"]);
                    order.OrderNo = Convert.ToInt32(r["order_no"]);
                    order.Date = Convert.ToDateTime(r["date"]);
                    order.TOW = Convert.ToString(r["type_of_work"]);
                    order.TypeOfWork = (TypeOfWorks)Enum.Parse(typeof(TypeOfWorks), r["type_of_work"].ToString());
                    order.NOC = Convert.ToInt32(r["number_of_copies"]);
                    order.Rate = Convert.ToSingle(r["rate"]);
                    order.Total = Convert.ToSingle(r["total"]);
                    order.CustomerId = Convert.ToInt32(r["Customer_Id"]);
                    lst.Add(order);
                }
            }
            return lst;
        }
Beispiel #4
0
        private void btn_searchorder_Click(object sender, EventArgs e)
        {
            if (txt_searchfield.Tag != null)
            {
                //OrderManager om;
                //new OrderManager().GenerateOrderNo(dtp_startdate.Value.Month, dtp_startdate.Value.Year);
                string txtvalue = txt_searchfield.Text;
                if (order == null)
                    order = new Order();
                order.CustomerId = int.Parse(txt_searchfield.Tag.ToString()); //new OrderManager().GetCustId(cb_search.SelectedItem.ToString(), txtvalue);

                DataTable dt = new OrderManager().GetData(dtp_startdate.Value.Date, dtp_enddate.Value.Date, cb_search.Text, txt_searchfield.Text, order.CustomerId);

                dgv_order.DataSource = dt;
                dgv_order.Columns[0].ReadOnly = true;
            }
        }
Beispiel #5
0
 public int InsertOrder(Order order)
 {
     string Query = "sp_customerorder_insert";
     //The Stored_Procedure is used to...
     string queselect = "sp_odermanager_select";
     int result = new ConnectionManager().ExecuteNonQuery(Query, Createparameters(order));
     object id = new ConnectionManager().ExecuteScalar(queselect);
     if (id != null && id != DBNull.Value)
     {
         order.ID = (int)id;
     }
     else
     {
         throw new Exception("Could not be saved!");
     }
     return result;
 }
Beispiel #6
0
        private void btn_print_Click(object sender, EventArgs e)
        {

            string txtvalue = txt_searchfield.Text;
            if (order == null)
                order = new Order();

            order.CustomerId = new OrderManager().GetCustId(cb_search.SelectedItem.ToString(), txtvalue);

            //int custid = Convert.ToInt32(order.CustomerId);
            if (order.CustomerId > 0)
            {
                frmReportViewer frv = new frmReportViewer(order.CustomerId);
                frv.Show();
            }
            else
            {
                MessageBox.Show("Please specify the required value!", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        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);
            }
        }
        private void btnadd_Click(object sender, EventArgs e)
        {
            order = new Order();
            order.OrderNo = new OrderManager().GenerateOrderNo(DateTime.Now.Month, DateTime.Now.Year);
            txt_ordernum.Text = order.OrderNo.ToString();
            ResetForm1(true, false);

        }
Beispiel #9
0
 public int UpdateOrder(Order order)
 {
     string Query = "sp_customerorder_update";
     return new ConnectionManager().ExecuteNonQuery(Query, Createparameters(order));
 }
Beispiel #10
0
        internal Order GetAllData(string Query)
        {
            // throw new NotImplementedException();
            //Order ord = (Order)new ConnectionManager().ExecuteScalar(que, CommandType.Text);
            //return ord;
            DataTable dt = new ConnectionManager().ExecuteGetDataTable(Query);

            if (dt != null && dt.Rows.Count > 0)
            {
                Order order = new Order();
                order.ID = Convert.ToInt32(dt.Rows[0]["User_id"]);
                order.OrderNo = Convert.ToInt32(dt.Rows[0]["order_no"]);
                order.Date = Convert.ToDateTime(dt.Rows[0]["date"]);
                order.TOW = Convert.ToString(dt.Rows[0]["type_of_work"]);
               // order.TypeOfWork = (TypeOfWorks)Enum.Parse(typeof(TypeOfWorks), dt.Rows[0]["type_of_work"].ToString());
                order.NOC = Convert.ToInt32(dt.Rows[0]["no_of_copies"]);
                order.Rate = Convert.ToSingle(dt.Rows[0]["rate"]);
                order.Total = Convert.ToSingle(dt.Rows[0]["total"]);
                order.CustomerId = Convert.ToInt32(dt.Rows[0]["Customer_Id"]);
                return order;
            }
            else
            {
                return null;
            }
        }