예제 #1
0
        public RequestItemsForm(int id, RequestForm rForm)
        {
            InitializeComponent();

            requestID = id;

            requestForm = rForm;
        }
        //Handler for the complete request button
        private void completeRequestButton_Click(object sender, EventArgs e)
        {
            int    requestId = 0;
            int    empId     = 0;
            int    supId     = supID;
            string date      = null;
            int    status    = 0;

            if (newRequestListView.SelectedItems.Count == 1)
            {
                foreach (ListViewItem i in newRequestListView.SelectedItems)
                {
                    requestId = Convert.ToInt32(i.SubItems[0].Text);
                }

                DialogResult result = MessageBox.Show("Are you sure you want to complete request #" + requestId.ToString() + "?", "Complete Request", MessageBoxButtons.YesNo);

                if (result == DialogResult.Yes)
                {
                    SqlConnection cnn      = new SqlConnection();
                    DBcnn         database = new DBcnn(cnn);
                    database.connect(null);
                    database.open();
                    SqlCommand cmd = new SqlCommand("SELECT * FROM REQUEST WHERE REQUEST_ID=@requestId", cnn);
                    cmd.Parameters.AddWithValue("@requestId", requestId);
                    cmd.ExecuteNonQuery();
                    SqlDataAdapter da = new SqlDataAdapter(cmd);
                    DataTable      dt = new DataTable();
                    da.Fill(dt);
                    database.close();
                    foreach (DataRow dr in dt.Rows)
                    {
                        empId  = Convert.ToInt32(dr["EMPLOYEE_ID"]);
                        status = Convert.ToInt32(dr["COUNTER"]);
                        date   = dr["EMPLOYEE_ID"].ToString();
                    }

                    Request     request      = new Request(requestId, supId, empId, 0, 0, 0, date);
                    RequestForm r            = new RequestForm(requestId);
                    string      employeeName = GetEmployeeName(empId);
                    r.EmployeeNameLabel = employeeName;

                    r.ShowDialog();

                    RefreshListViews();
                }
            }
            else
            {
                MessageBox.Show("Please Select a Request.");
            }
        }
예제 #3
0
        //Handler for the button click
        private void button1_Click(object sender, EventArgs e)
        {
            RequestForm r = new RequestForm(101);

            r.ShowDialog();
        }