コード例 #1
0
        protected void Get_guard_list()
        {
            DataTable dt = new DataTable();

            if (this.cbo_branch.Text == string.Empty)
            {
                MessageBox.Show("Select a branch to search", "Guard Deployments", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }
            else if (SystemConst._user_department == "Accounts" && cbo_deploy_period.Text == string.Empty)
            {
                MessageBox.Show("Please select a payment period to proceed with search", "Guard Deployments", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }
            string   text  = this.cbo_branch.Text;
            string   str   = this.txt_guard_number.Text;
            DateTime date  = this.dt_start_date.Value.Date;
            DateTime value = this.dt_end_date.Value;

            //dt = Guard_deployment.select_list_of_guards_for_additional_deployment_data_entry("select_list_of_guards_for_additional_deployment_data_entry", text, str, date, value.Date, SystemConst._user_id);
            dt = Guard_deployment.select_list_of_guards_for_additional_deployment_data_entry(text, str, date, value.Date, SystemConst._user_id);
            MessageBox.Show(dt.Rows.Count.ToString() + " Records Found");

            if (dt.Rows.Count <= 0)
            {
                this.gdv_guards.DataSource = null;
                return;
            }
            this.gdv_guards.DataSource = dt;

            this.gdv_guards.Columns["auto_id"].Visible       = false;
            this.gdv_guards.Columns["payment_month"].Visible = false;
            this.gdv_guards.Columns["branch"].ReadOnly       = true;
            this.gdv_guards.Columns["guard_number"].ReadOnly = true;
            this.gdv_guards.Columns["days_worked"].ReadOnly  = true;
            //this.gdv_guards.Columns["overtime"].ReadOnly = true;
            this.gdv_guards.Columns["days_absent"].ReadOnly              = true;
            this.gdv_guards.Columns["full_name"].ReadOnly                = true;
            this.gdv_guards.Columns["guard_number"].HeaderText           = "Guard No.";
            this.gdv_guards.Columns["full_name"].HeaderText              = "Name";
            this.gdv_guards.Columns["branch"].HeaderText                 = "Branch";
            this.gdv_guards.Columns["days_worked"].HeaderText            = "Days";
            this.gdv_guards.Columns["overtime"].HeaderText               = "Ovt";
            this.gdv_guards.Columns["days_absent"].HeaderText            = "Absent";
            this.gdv_guards.Columns["total_advance_in_month"].HeaderText = "Advance";
            this.gdv_guards.Columns["total_arrears_in_month"].HeaderText = "Arrears";
            this.gdv_guards.Columns["special_cash_additions"].HeaderText = "Special";
            this.gdv_guards.Columns["residential_cost"].HeaderText       = "Residential";
            this.gdv_guards.Columns["uniform_costs"].HeaderText          = "Uniform";
            this.gdv_guards.Columns["local_service_tax_cost"].HeaderText = "LST";
            this.gdv_guards.Columns["other_penalties_cost"].HeaderText   = "Penalty";
            this.gdv_guards.Columns["other_refunds"].HeaderText          = "Refund";
            this.gdv_guards.Columns["full_name"].Width        = 250;
            this.gdv_guards.Columns["guard_number"].Width     = 120;
            this.gdv_guards.Columns["residential_cost"].Width = 100;

            this.gdv_guards.RowsDefaultCellStyle.BackColor            = Color.LightGray;
            this.gdv_guards.AlternatingRowsDefaultCellStyle.BackColor = Color.Beige;
            this.gdv_guards.ColumnHeadersDefaultCellStyle.ForeColor   = Color.White;
            this.gdv_guards.ColumnHeadersDefaultCellStyle.BackColor   = Color.Black;
            this.gdv_guards.RowHeadersDefaultCellStyle.BackColor      = Color.Black;
            this.gdv_guards.DefaultCellStyle.SelectionBackColor       = Color.Cyan;
            this.gdv_guards.DefaultCellStyle.SelectionForeColor       = Color.Black;
            this.gdv_guards.BorderStyle = BorderStyle.FixedSingle;

            foreach (DataGridViewColumn c in this.gdv_guards.Columns)
            {
                c.DefaultCellStyle.Font = new System.Drawing.Font("Arial", 11f, GraphicsUnit.Pixel);
            }
            this.gdv_guards.ColumnHeadersDefaultCellStyle.BackColor = Color.CadetBlue;
            this.gdv_guards.EnableHeadersVisualStyles = false;
        }
        protected void Get_guard_list()
        {
            if (cbo_branch.Text == String.Empty)
            {
                MessageBox.Show("Select a branch to search", "Guard Deployments", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            else
            {
                DataTable dt = Guard_deployment.select_list_of_guards_for_additional_deployment_data_entry("select_list_of_guards_for_additional_deployment_data_entry", cbo_branch.Text, dt_start_date.Value.Date, dt_end_date.Value.Date);
                if (dt.Rows.Count > 0)
                {
                    gdv_guards.DataSource = dt;

                    gdv_guards.Columns["auto_id"].Visible       = false;
                    gdv_guards.Columns["payment_month"].Visible = false;

                    //set read only columns
                    gdv_guards.Columns["branch"].ReadOnly       = true;
                    gdv_guards.Columns["guard_number"].ReadOnly = true;
                    gdv_guards.Columns["days_worked"].ReadOnly  = true;
                    gdv_guards.Columns["overtime"].ReadOnly     = true;
                    gdv_guards.Columns["days_absent"].ReadOnly  = true;
                    gdv_guards.Columns["full_name"].ReadOnly    = true;

                    //set head texts
                    gdv_guards.Columns["guard_number"].HeaderText           = "Guard No.";
                    gdv_guards.Columns["full_name"].HeaderText              = "Name";
                    gdv_guards.Columns["branch"].HeaderText                 = "Branch";
                    gdv_guards.Columns["days_worked"].HeaderText            = "Days";
                    gdv_guards.Columns["overtime"].HeaderText               = "Ovt";
                    gdv_guards.Columns["days_absent"].HeaderText            = "Absent";
                    gdv_guards.Columns["total_advance_in_month"].HeaderText = "Advance";
                    gdv_guards.Columns["total_arrears_in_month"].HeaderText = "Arrears";
                    gdv_guards.Columns["special_cash_additions"].HeaderText = "Special";
                    gdv_guards.Columns["residential_cost"].HeaderText       = "Residential";
                    gdv_guards.Columns["uniform_costs"].HeaderText          = "Uniform";
                    gdv_guards.Columns["local_service_tax_cost"].HeaderText = "LST";
                    gdv_guards.Columns["other_penalties_cost"].HeaderText   = "Penalty";
                    gdv_guards.Columns["other_refunds"].HeaderText          = "Refund";

                    gdv_guards.Columns["full_name"].Width        = 250;
                    gdv_guards.Columns["guard_number"].Width     = 120;
                    gdv_guards.Columns["residential_cost"].Width = 100;

                    gdv_guards.RowsDefaultCellStyle.BackColor            = Color.LightGray;
                    gdv_guards.AlternatingRowsDefaultCellStyle.BackColor = Color.Beige;

                    // Set the row and column header styles.
                    gdv_guards.ColumnHeadersDefaultCellStyle.ForeColor = Color.White;
                    gdv_guards.ColumnHeadersDefaultCellStyle.BackColor = Color.Black;
                    gdv_guards.RowHeadersDefaultCellStyle.BackColor    = Color.Black;

                    // Set the selection background color for all the cells.
                    gdv_guards.DefaultCellStyle.SelectionBackColor = Color.Cyan;
                    gdv_guards.DefaultCellStyle.SelectionForeColor = Color.Black;

                    //set gridlines style
                    this.gdv_guards.BorderStyle = BorderStyle.FixedSingle;

                    foreach (DataGridViewColumn c in gdv_guards.Columns)
                    {
                        c.DefaultCellStyle.Font = new Font("Arial", 11F, GraphicsUnit.Pixel);
                    }

                    //set the background color of the header row
                    gdv_guards.ColumnHeadersDefaultCellStyle.BackColor = Color.CadetBlue;
                    gdv_guards.EnableHeadersVisualStyles = false;
                }
                else
                {
                    DataTable dtNull = null;
                    gdv_guards.DataSource = dtNull;
                }
            }
        }