private void btn_Nhap_Click(object sender, EventArgs e)
        {
            int ViTri, GiaTri;

            ViTri  = Convert.ToInt32(txt_Vitri.Text);
            GiaTri = Convert.ToInt32(txt_Giatri.Text);

            #region KIỂM TRA GIÁ TRỊ NHÂP VÀO
            if (ViTri > Form1.SoPT - 1)
            {
                MessageBox.Show("không tồn tại vị trí phần tử");
                return;
            }


            if (GiaTri >= 100)
            {
                MessageBox.Show("0 <= giá trị nhập vào <= 100");
                this.txt_Giatri.Clear();
                return;
            }
            #endregion

            Form1.Array[ViTri]   = GiaTri;
            Form1.Bn[ViTri].Text = GiaTri.ToString();
            //tu dong tang gia tri cua vi tri phan tu
            this.txt_Vitri.Text = (ViTri + 1).ToString();

            Form1.Bn[ViTri].BackColor = Color.Green;
            Thread.Sleep(1000);
            Form1.Bn[ViTri].BackColor = Color.OrangeRed;
        }
Esempio n. 2
0
 public override FrameworkElement CreateCellEditElement(Telerik.Windows.Controls.GridView.GridViewCell cell, object dataItem)
 {
     try
     {
         cmbCommon = new RadComboBox();
         if (!dataItem.IsNullOrEmpty())
         {
             PropertyInfo property = null;
             object       oObject  = dataItem;
             if (!DieuKienDataMember.IsNullOrEmptyOrSpace())
             {
                 foreach (string str in DieuKienDataMember.Split('.').ToList())
                 {
                     property = oObject.GetType().GetProperty(str);
                     if (property != null)
                     {
                         DieuKien = property.GetValue(oObject, null).ToString();
                         oObject  = property.GetValue(oObject, null);
                     }
                 }
             }
             if (!sMaLoaiDM.Equals(""))
             {
                 lstComboBox = new List <AutoCompleteEntry>();
                 KhoiTaoGiaTriComboBox(ref lstComboBox, ref cmbCommon, sMaLoaiDM);
             }
             if (!GiaTriDataMember.IsNullOrEmptyOrSpace())
             {
                 oObject = dataItem;
                 foreach (string str in GiaTriDataMember.Split('.').ToList())
                 {
                     property = oObject.GetType().GetProperty(str);
                     if (property != null)
                     {
                         GiaTri  = property.GetValue(oObject, null).IsNullOrEmpty() ? "" : property.GetValue(oObject, null).ToString();
                         oObject = property.GetValue(oObject, null);
                     }
                 }
             }
             if (!GiaTri.IsNullOrEmptyOrSpace())
             {
                 cmbCommon.SelectedIndex = lstComboBox.IndexOf(lstComboBox.FirstOrDefault(i => i.KeywordStrings.First().Equals(GiaTri)));
             }
             else
             {
                 cmbCommon.SelectedIndex = -1;
             }
         }
         cmbCommon.Tag               = lstComboBox;
         cmbCommon.IsEnabled         = true;
         cmbCommon.SelectionChanged += new SelectionChangedEventHandler(cmbCommon_SelectionChanged);
     }
     catch (Exception ex)
     {
         LLogging.WriteLog(ex.TargetSite.Name, LLogging.LogType.ERR, ex);
     }
     cellEdit = cell;
     return(cmbCommon as FrameworkElement);
 }
        public void Truy_xuat_Bang_ma_lenh()
        {
            //string connection_SQL = "server=(local);database=3_ngay44;user=sa;password=psbinh";
            SqlConnection  conn = new SqlConnection(connection_SQL);
            SqlCommand     comm;
            SqlDataAdapter adapter;
            DataSet        ds = new DataSet();

            if (conn.State != ConnectionState.Open)
            {
                try
                {
                    conn.Open();
                    if (conn.State == ConnectionState.Open)
                    {
                        txtSQL_Status.Text      = "KẾT NỐI SQL: TỐT";
                        txtSQL_Status.BackColor = Color.LightGreen;
                    }
                    //MessageBox.Show("Kết nối DataBase SQL thành công");
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString());
                    txtSQL_Status.Text = "KẾT NỐI SQL: LỖI";
                }
            }

            comm    = new SqlCommand("SELECT Time_tao_lenh AS 'T.Gian TẠO LỆNH', Ma_lenh AS 'MÃ LỆNH', Ma_hang AS 'MÃ HÀNG', Ma_hong AS 'MÃ HỌNG', so_ptien AS 'SỐ XE', ma_ngan AS 'MÃ NGĂN', Nhiet_do AS 'NHIỆT ĐỘ', Luong_dat AS 'LƯỢNG ĐẶT', Luong_thuc_te AS 'LƯỢNG THỰC XUẤT'  FROM BX_BangMaLenh ORDER BY Time_tao_lenh", conn);
            adapter = new SqlDataAdapter(comm);
            adapter.Fill(ds);

            var GiaTriLay = from GiaTri in ds.Tables[0].AsEnumerable()
                            where (GiaTri.Field <DateTime>("T.Gian TẠO LỆNH") >= DateTime.Today)
                            select GiaTri;

            dataGridView1.DataSource = null;
            dataGridView1.DataSource = GiaTriLay.AsDataView();
            foreach (DataGridViewRow row in dataGridView1.Rows)
            {
                row.HeaderCell.Value = String.Format("{000}", row.Index + 1);
            }


            conn.Dispose();
            adapter.Dispose();
            comm.Dispose();
            malenhxuattoday = dataGridView1.RowCount;

            tinh_tong_luong_thuc_xuat();
        }
Esempio n. 4
0
 public override FrameworkElement CreateCellElement(Telerik.Windows.Controls.GridView.GridViewCell cell, object dataItem)
 {
     try
     {
         cmbCommon = new RadComboBox();
         if (!dataItem.IsNullOrEmpty())
         {
             PropertyInfo property = null;
             object       oObject  = dataItem;
             if (!DieuKienDataMember.IsNullOrEmptyOrSpace())
             {
                 foreach (string str in DieuKienDataMember.Split('.').ToList())
                 {
                     property = oObject.GetType().GetProperty(str);
                     if (property != null)
                     {
                         DieuKien = property.GetValue(oObject, null).ToString();
                         oObject  = property.GetValue(oObject, null);
                     }
                 }
             }
             if (!sTruyVan.Equals(""))
             {
                 List <string> lstDieuKien = new List <string>();
                 lstDieuKien.Add(DieuKien.ToString());
                 lstComboBox = new List <AutoCompleteEntry>();
                 KhoiTaoGiaTriComboBox(ref lstComboBox, ref cmbCommon, sTruyVan, lstDieuKien);
             }
             if (!GiaTriDataMember.IsNullOrEmptyOrSpace())
             {
                 this.SetBinding(GiaTriProperty, CreateValueBinding(dataItem));
             }
             if (!GiaTri.IsNullOrEmptyOrSpace())
             {
                 cmbCommon.SelectedIndex = lstComboBox.IndexOf(lstComboBox.FirstOrDefault(i => i.KeywordStrings.First().Equals(GiaTri)));
             }
             else
             {
                 cmbCommon.SelectedIndex = -1;
             }
         }
     }
     catch (Exception ex)
     {
         LLogging.WriteLog(ex.TargetSite.Name, LLogging.LogType.ERR, ex);
     }
     cmbCommon.IsEnabled = false;
     return(cmbCommon);
 }
        private void btnViewBX_alrm_Click(object sender, EventArgs e)
        {
            SqlConnection  conn = new SqlConnection(connection_SQL);
            SqlCommand     comm;
            SqlDataAdapter adapter;
            DataSet        ds = new DataSet();

            if (conn.State != ConnectionState.Open)
            {
                try
                {
                    conn.Open();
                    if (conn.State == ConnectionState.Open)
                    {
                        txtSQL_Status.Text      = "KẾT NỐI SQL: TỐT";
                        txtSQL_Status.BackColor = Color.LightGreen;
                    }
                    //MessageBox.Show("Kết nối DataBase SQL thành công");
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString());
                    txtSQL_Status.Text = "KẾT NỐI SQL: LỖI";
                }
            }

            comm    = new SqlCommand("SELECT Time AS 'THỜI GIAN', Ma_hong AS 'MÃ HỌNG', Ma_lenh AS 'MÃ LỆNH', Luong_dat AS 'LƯỢNG ĐẶT', Luong_tt AS 'LƯỢNG THỰC', ToC AS 'NHIỆT ĐỘ', ToC_tb AS 'NHIỆT ĐỘ TB', Luu_toc AS 'LƯU TỐC', BOM AS 'BƠM', Van1 AS 'VAN NO', Van2 AS 'VAN NC', Auto_man AS 'AUTO/MAN', Dung_su_co AS 'DỪNG SỰ CỐ'  FROM BX_Historys ORDER BY Time", conn);
            adapter = new SqlDataAdapter(comm);
            adapter.Fill(ds);

            var GiaTriLay = from GiaTri in ds.Tables[0].AsEnumerable()
                            where GiaTri.Field <int?>("MÃ HỌNG") == (cbbMaH.SelectedIndex + 1)
                            where (GiaTri.Field <DateTime>("THỜI GIAN") >= dateTimePicker5.Value) && (GiaTri.Field <DateTime>("THỜI GIAN") < dateTimePicker6.Value)
                            select GiaTri;

            dataGridView1.DataSource = null;
            dataGridView1.DataSource = GiaTriLay.AsDataView();

            conn.Dispose();
            adapter.Dispose();
            comm.Dispose();
        }
        public void Show_BN_BangMaLenh()
        {
            SqlConnection  conn = new SqlConnection(connection_SQL);
            SqlCommand     comm;
            SqlDataAdapter adapter;
            DataSet        ds = new DataSet();

            if (conn.State != ConnectionState.Open)
            {
                try
                {
                    conn.Open();
                    if (conn.State == ConnectionState.Open)
                    {
                        txtSQL_Status.Text      = "KẾT NỐI SQL: TỐT";
                        txtSQL_Status.BackColor = Color.LightGreen;
                    }
                    //MessageBox.Show("Kết nối DataBase SQL thành công");
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString());
                    txtSQL_Status.Text = "KẾT NỐI SQL: LỖI";
                }
            }

            comm    = new SqlCommand("SELECT * FROM BN_BangMaLenh", conn);
            adapter = new SqlDataAdapter(comm);
            adapter.Fill(ds);

            var GiaTriLay = from GiaTri in ds.Tables[0].AsEnumerable()
                            where (GiaTri.Field <DateTime>("Time_tao") >= DateTime.Today)
                            select GiaTri;

            dataGridView1.DataSource = null;
            dataGridView1.DataSource = GiaTriLay.AsDataView();

            conn.Dispose();
            adapter.Dispose();
            comm.Dispose();
        }
Esempio n. 7
0
        private void btn_Nhap_Click(object sender, EventArgs e)
        {
            int ViTri, GiaTri;

            ViTri  = Convert.ToInt32(txt_Vitri.Text);
            GiaTri = Convert.ToInt32(txt_Giatri.Text);

            #region KIỂM TRA GIÁ TRỊ NHÂP VÀO
            if (ViTri > Form1.SoPT - 1)
            {
                MessageBox.Show("không tồn tại vị trí phần tử");
                return;
            }


            if (GiaTri >= 100)
            {
                MessageBox.Show("0 <= giá trị nhập vào <= 100");
                this.txt_Giatri.Clear();
                return;
            }
            #endregion

            Form1.Array[ViTri]   = GiaTri;
            Form1.Bn[ViTri].Text = GiaTri.ToString();

            //tu dong tang gia tri cua vi tri phan tu
            this.txt_Vitri.Text = (ViTri + 1).ToString();

            //Đổi màu node khi nhận giá trị nhập vào
            Form1.Bn[ViTri].BackgroundImage = Properties.Resources.daxep;
            Form1.Bn[ViTri].Refresh();
            System.Threading.Thread.Sleep(1000);
            Form1.Bn[ViTri].BackgroundImage = Properties.Resources.chuaxep;
            Form1.Bn[ViTri].Refresh();
        }
        private void button1_Click_1(object sender, EventArgs e)
        {
            SqlConnection  conn = new SqlConnection(connection_SQL);
            SqlCommand     comm;
            SqlDataAdapter adapter;
            DataSet        ds = new DataSet();

            if (conn.State != ConnectionState.Open)
            {
                try
                {
                    conn.Open();
                    if (conn.State == ConnectionState.Open)
                    {
                        txtSQL_Status.Text      = "KẾT NỐI SQL: TỐT";
                        txtSQL_Status.BackColor = Color.LightGreen;
                    }
                    //MessageBox.Show("Kết nối DataBase SQL thành công");
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString());
                    txtSQL_Status.Text = "KẾT NỐI SQL: LỖI";
                }
            }

            comm    = new SqlCommand("SELECT Time AS 'THỜI GIAN', Ma_hong AS 'MÃ HỌNG', Canh_bao AS 'CẢNH BÁO'  FROM BX_Canhbao ORDER BY Time", conn);
            adapter = new SqlDataAdapter(comm);
            adapter.Fill(ds);


            if (comboBox1.SelectedIndex == 0)
            {
                var GiaTriLay = from GiaTri in ds.Tables[0].AsEnumerable()
                                //where GiaTri.Field<int?>("MÃ HỌNG") == (comboBox1.SelectedIndex + 1)
                                where (GiaTri.Field <DateTime>("THỜI GIAN") >= dateTimePicker1.Value) && (GiaTri.Field <DateTime>("THỜI GIAN") < dateTimePicker2.Value)
                                select GiaTri;
                dataGridView1.DataSource = null;
                dataGridView1.DataSource = GiaTriLay.AsDataView();
            }
            else if (comboBox1.SelectedIndex > 0)
            {
                var GiaTriLay = from GiaTri in ds.Tables[0].AsEnumerable()
                                where GiaTri.Field <int?>("MÃ HỌNG") == (comboBox1.SelectedIndex - 1)
                                where (GiaTri.Field <DateTime>("THỜI GIAN") >= dateTimePicker1.Value) && (GiaTri.Field <DateTime>("THỜI GIAN") < dateTimePicker2.Value)
                                select GiaTri;
                dataGridView1.DataSource = null;
                dataGridView1.DataSource = GiaTriLay.AsDataView();
            }
            else
            {
                var GiaTriLay = from GiaTri in ds.Tables[0].AsEnumerable()
                                //where GiaTri.Field<int?>("MÃ HỌNG") == (comboBox1.SelectedIndex)
                                where (GiaTri.Field <DateTime>("THỜI GIAN") >= dateTimePicker1.Value) && (GiaTri.Field <DateTime>("THỜI GIAN") < dateTimePicker2.Value)
                                select GiaTri;
                dataGridView1.DataSource = null;
                dataGridView1.DataSource = GiaTriLay.AsDataView();
            }



            conn.Dispose();
            adapter.Dispose();
            comm.Dispose();
        }
        private void btn_Xem_Click(object sender, EventArgs e)
        {
            SqlConnection  conn = new SqlConnection(connection_SQL);
            SqlCommand     comm;
            SqlDataAdapter adapter;
            DataSet        ds = new DataSet();

            if (conn.State != ConnectionState.Open)
            {
                try
                {
                    conn.Open();
                    if (conn.State == ConnectionState.Open)
                    {
                        txtSQL_Status.Text      = "KẾT NỐI SQL: TỐT";
                        txtSQL_Status.BackColor = Color.LightGreen;
                    }
                    //MessageBox.Show("Kết nối DataBase SQL thành công");
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString());
                    txtSQL_Status.Text = "KẾT NỐI SQL: LỖI";
                }
            }
            comm    = new SqlCommand("SELECT Time_tao_lenh AS 'T.Gian TẠO LỆNH', Ma_lenh AS 'MÃ LỆNH', Ma_hang AS 'MÃ HÀNG', Ma_hong AS 'MÃ HỌNG', so_ptien AS 'SỐ XE', ma_ngan AS 'MÃ NGĂN', Nhiet_do AS 'NHIỆT ĐỘ', Luong_dat AS 'LƯỢNG ĐẶT', Luong_thuc_te AS 'LƯỢNG THỰC XUẤT'  FROM BX_BangMaLenh ORDER BY Time_tao_lenh", conn);
            adapter = new SqlDataAdapter(comm);
            adapter.Fill(ds);

            //1000 THEO NGAY
            if ((checkBox_THEONGAY.Checked) && (!checkBox_THEOHONG.Checked) && (!checkBox_THEOMAHANG.Checked) && (!checkBox_THEOMALENH.Checked))
            {
                var GiaTriLay = from GiaTri in ds.Tables[0].AsEnumerable()
                                where (GiaTri.Field <DateTime>("T.Gian TẠO LỆNH") >= dateTimePicker3.Value.Date) && (GiaTri.Field <DateTime>("T.Gian TẠO LỆNH") < dateTimePicker4.Value.Date)
                                select GiaTri;

                dataGridView1.DataSource = null;
                dataGridView1.DataSource = GiaTriLay.AsDataView();

                tinh_tong_luong_thuc_xuat();
            }
            //0100 THEO HONG
            else if ((!checkBox_THEONGAY.Checked) && (checkBox_THEOHONG.Checked) && (!checkBox_THEOMAHANG.Checked) && (!checkBox_THEOMALENH.Checked))
            {
                var GiaTriLay = from GiaTri in ds.Tables[0].AsEnumerable()
                                where GiaTri.Field <int?>("MÃ HỌNG") == (comboBox2.SelectedIndex + 1)
                                select GiaTri;

                dataGridView1.DataSource = null;
                dataGridView1.DataSource = GiaTriLay.AsDataView();

                tinh_tong_luong_thuc_xuat();
            }

            //1100 THEO NGAY & THEO HONG
            else if ((checkBox_THEONGAY.Checked) & (checkBox_THEOHONG.Checked) & (!checkBox_THEOMAHANG.Checked) & (!checkBox_THEOMALENH.Checked))
            {
                var GiaTriLay = from GiaTri in ds.Tables[0].AsEnumerable()
                                where (GiaTri.Field <DateTime>("T.Gian TẠO LỆNH") >= dateTimePicker3.Value.Date) && (GiaTri.Field <DateTime>("T.Gian TẠO LỆNH") < dateTimePicker4.Value.Date)
                                where GiaTri.Field <int?>("MÃ HỌNG") == (comboBox2.SelectedIndex + 1)
                                select GiaTri;

                dataGridView1.DataSource = null;
                dataGridView1.DataSource = GiaTriLay.AsDataView();

                tinh_tong_luong_thuc_xuat();
            }

            //0010 THEO MA HANG
            else if ((!checkBox_THEONGAY.Checked) & (!checkBox_THEOHONG.Checked) & (checkBox_THEOMAHANG.Checked) & (!checkBox_THEOMALENH.Checked))
            {
                var GiaTriLay = from GiaTri in ds.Tables[0].AsEnumerable()
                                where GiaTri.Field <string>("MÃ HÀNG") == textBox3.Text
                                select GiaTri;

                dataGridView1.DataSource = null;
                dataGridView1.DataSource = GiaTriLay.AsDataView();

                tinh_tong_luong_thuc_xuat();
            }

            //1010 THEO NGAY & THEO MA HANG
            else if ((checkBox_THEONGAY.Checked) & (!checkBox_THEOHONG.Checked) & (checkBox_THEOMAHANG.Checked) & (!checkBox_THEOMALENH.Checked))
            {
                var GiaTriLay = from GiaTri in ds.Tables[0].AsEnumerable()
                                where (GiaTri.Field <DateTime>("T.Gian TẠO LỆNH") >= dateTimePicker3.Value.Date) && (GiaTri.Field <DateTime>("T.Gian TẠO LỆNH") < dateTimePicker4.Value.Date)
                                where GiaTri.Field <string>("MÃ HÀNG") == textBox3.Text
                                select GiaTri;

                dataGridView1.DataSource = null;
                dataGridView1.DataSource = GiaTriLay.AsDataView();

                tinh_tong_luong_thuc_xuat();
            }


            //0110 THEO HONG & THEO MA HANG
            else if ((!checkBox_THEONGAY.Checked) & (checkBox_THEOHONG.Checked) & (checkBox_THEOMAHANG.Checked) & (!checkBox_THEOMALENH.Checked))
            {
                var GiaTriLay = from GiaTri in ds.Tables[0].AsEnumerable()
                                where GiaTri.Field <int?>("MÃ HỌNG") == (comboBox2.SelectedIndex + 1)
                                where GiaTri.Field <string>("MÃ HÀNG") == textBox3.Text
                                select GiaTri;

                dataGridView1.DataSource = null;
                dataGridView1.DataSource = GiaTriLay.AsDataView();

                tinh_tong_luong_thuc_xuat();
            }

            //1110 THEO NGAY & THEO HONG & THEO MA HANG
            else if ((checkBox_THEONGAY.Checked) & (checkBox_THEOHONG.Checked) & (checkBox_THEOMAHANG.Checked) & (!checkBox_THEOMALENH.Checked))
            {
                var GiaTriLay = from GiaTri in ds.Tables[0].AsEnumerable()
                                where (GiaTri.Field <DateTime>("T.Gian TẠO LỆNH") >= dateTimePicker3.Value.Date) && (GiaTri.Field <DateTime>("T.Gian TẠO LỆNH") < dateTimePicker4.Value.Date)

                                where GiaTri.Field <int?>("MÃ HỌNG") == (comboBox2.SelectedIndex + 1)
                                where GiaTri.Field <string>("MÃ HÀNG") == textBox3.Text
                                select GiaTri;

                dataGridView1.DataSource = null;
                dataGridView1.DataSource = GiaTriLay.AsDataView();

                tinh_tong_luong_thuc_xuat();
            }

            //0001 THEO MA LENH
            else if ((!checkBox_THEONGAY.Checked) & (!checkBox_THEOHONG.Checked) & (!checkBox_THEOMAHANG.Checked) & (checkBox_THEOMALENH.Checked))
            {
                var GiaTriLay = from GiaTri in ds.Tables[0].AsEnumerable()
                                where GiaTri.Field <int?>("MÃ LỆNH") == int.Parse(textBox2.Text)
                                select GiaTri;

                dataGridView1.DataSource = null;
                dataGridView1.DataSource = GiaTriLay.AsDataView();

                tinh_tong_luong_thuc_xuat();
            }

            //1001 THEO NGAY & THEO MA LENH
            else if ((checkBox_THEONGAY.Checked) & (!checkBox_THEOHONG.Checked) & (!checkBox_THEOMAHANG.Checked) & (checkBox_THEOMALENH.Checked))
            {
                var GiaTriLay = from GiaTri in ds.Tables[0].AsEnumerable()
                                where (GiaTri.Field <DateTime>("T.Gian TẠO LỆNH") >= dateTimePicker3.Value.Date) && (GiaTri.Field <DateTime>("T.Gian TẠO LỆNH") < dateTimePicker4.Value.Date)
                                //where GiaTri.Field<int?>("MÃ HỌNG") == (comboBox2.SelectedIndex + 1)
                                //where GiaTri.Field<string>("MÃ HÀNG") == textBox3.Text
                                where GiaTri.Field <int?>("MÃ LỆNH") == int.Parse(textBox2.Text)
                                select GiaTri;

                dataGridView1.DataSource = null;
                dataGridView1.DataSource = GiaTriLay.AsDataView();

                tinh_tong_luong_thuc_xuat();
            }

            //0101 THEO HONG & THEO MA LENH
            else if ((!checkBox_THEONGAY.Checked) & (checkBox_THEOHONG.Checked) & (!checkBox_THEOMAHANG.Checked) & (checkBox_THEOMALENH.Checked))
            {
                var GiaTriLay = from GiaTri in ds.Tables[0].AsEnumerable()
                                //where (GiaTri.Field<DateTime>("T.Gian TẠO LỆNH") >= dateTimePicker3.Value.Date) && (GiaTri.Field<DateTime>("T.Gian TẠO LỆNH") < dateTimePicker4.Value.Date)
                                where GiaTri.Field <int?>("MÃ HỌNG") == (comboBox2.SelectedIndex + 1)
                                //where GiaTri.Field<string>("MÃ HÀNG") == textBox3.Text
                                where GiaTri.Field <int?>("MÃ LỆNH") == int.Parse(textBox2.Text)
                                select GiaTri;

                dataGridView1.DataSource = null;
                dataGridView1.DataSource = GiaTriLay.AsDataView();

                tinh_tong_luong_thuc_xuat();
            }

            //1101 THEO NGAY & THEO HONG & THEO MA LENH
            else if ((checkBox_THEONGAY.Checked) & (checkBox_THEOHONG.Checked) & (!checkBox_THEOMAHANG.Checked) & (checkBox_THEOMALENH.Checked))
            {
                var GiaTriLay = from GiaTri in ds.Tables[0].AsEnumerable()
                                where (GiaTri.Field <DateTime>("T.Gian TẠO LỆNH") >= dateTimePicker3.Value.Date) && (GiaTri.Field <DateTime>("T.Gian TẠO LỆNH") < dateTimePicker4.Value.Date)
                                where GiaTri.Field <int?>("MÃ HỌNG") == (comboBox2.SelectedIndex + 1)
                                //where GiaTri.Field<string>("MÃ HÀNG") == textBox3.Text
                                where GiaTri.Field <int?>("MÃ LỆNH") == int.Parse(textBox2.Text)
                                select GiaTri;

                dataGridView1.DataSource = null;
                dataGridView1.DataSource = GiaTriLay.AsDataView();

                tinh_tong_luong_thuc_xuat();
            }

            //0011 THEO MA HANG & THEO MA LENH
            else if ((!checkBox_THEONGAY.Checked) & (!checkBox_THEOHONG.Checked) & (checkBox_THEOMAHANG.Checked) & (checkBox_THEOMALENH.Checked))
            {
                var GiaTriLay = from GiaTri in ds.Tables[0].AsEnumerable()
                                //where (GiaTri.Field<DateTime>("T.Gian TẠO LỆNH") >= dateTimePicker3.Value.Date) && (GiaTri.Field<DateTime>("T.Gian TẠO LỆNH") < dateTimePicker4.Value.Date)
                                //where GiaTri.Field<int?>("MÃ HỌNG") == (comboBox2.SelectedIndex + 1)
                                where GiaTri.Field <string>("MÃ HÀNG") == textBox3.Text
                                where GiaTri.Field <int?>("MÃ LỆNH") == int.Parse(textBox2.Text)
                                select GiaTri;

                dataGridView1.DataSource = null;
                dataGridView1.DataSource = GiaTriLay.AsDataView();

                tinh_tong_luong_thuc_xuat();
            }

            //1011 THEO NGAY & THEO MA HANG & THEO MA LENH
            else if ((checkBox_THEONGAY.Checked) & (!checkBox_THEOHONG.Checked) & (checkBox_THEOMAHANG.Checked) & (checkBox_THEOMALENH.Checked))
            {
                var GiaTriLay = from GiaTri in ds.Tables[0].AsEnumerable()
                                where (GiaTri.Field <DateTime>("T.Gian TẠO LỆNH") >= dateTimePicker3.Value.Date) && (GiaTri.Field <DateTime>("T.Gian TẠO LỆNH") < dateTimePicker4.Value.Date)
                                //where GiaTri.Field<int?>("MÃ HỌNG") == (comboBox2.SelectedIndex + 1)
                                where GiaTri.Field <string>("MÃ HÀNG") == textBox3.Text
                                where GiaTri.Field <int?>("MÃ LỆNH") == int.Parse(textBox2.Text)
                                select GiaTri;

                dataGridView1.DataSource = null;
                dataGridView1.DataSource = GiaTriLay.AsDataView();

                tinh_tong_luong_thuc_xuat();
            }

            //0111 THEO HONG & THEO MA HANG & THEO MA LENH
            else if ((!checkBox_THEONGAY.Checked) & (checkBox_THEOHONG.Checked) & (checkBox_THEOMAHANG.Checked) & (checkBox_THEOMALENH.Checked))
            {
                var GiaTriLay = from GiaTri in ds.Tables[0].AsEnumerable()
                                //where (GiaTri.Field<DateTime>("T.Gian TẠO LỆNH") >= dateTimePicker3.Value.Date) && (GiaTri.Field<DateTime>("T.Gian TẠO LỆNH") < dateTimePicker4.Value.Date)
                                where GiaTri.Field <int?>("MÃ HỌNG") == (comboBox2.SelectedIndex + 1)
                                where GiaTri.Field <string>("MÃ HÀNG") == textBox3.Text
                                where GiaTri.Field <int?>("MÃ LỆNH") == int.Parse(textBox2.Text)
                                select GiaTri;

                dataGridView1.DataSource = null;
                dataGridView1.DataSource = GiaTriLay.AsDataView();

                tinh_tong_luong_thuc_xuat();
            }

            //1111 THEO NGAY & THEO HONG & THEO MA HANG & THEO MA LENH
            else if ((checkBox_THEONGAY.Checked) & (checkBox_THEOHONG.Checked) & (checkBox_THEOMAHANG.Checked) & (checkBox_THEOMALENH.Checked))
            {
                var GiaTriLay = from GiaTri in ds.Tables[0].AsEnumerable()
                                where (GiaTri.Field <DateTime>("T.Gian TẠO LỆNH") >= dateTimePicker3.Value.Date) && (GiaTri.Field <DateTime>("T.Gian TẠO LỆNH") < dateTimePicker4.Value.Date)
                                where GiaTri.Field <int?>("MÃ HỌNG") == (comboBox2.SelectedIndex + 1)
                                where GiaTri.Field <string>("MÃ HÀNG") == textBox3.Text
                                where GiaTri.Field <int?>("MÃ LỆNH") == int.Parse(textBox2.Text)
                                select GiaTri;
                dataGridView1.DataSource = null;
                dataGridView1.DataSource = GiaTriLay.AsDataView();

                tinh_tong_luong_thuc_xuat();
            }

            // Xem tat ca bang ma lenh
            else
            {
                var GiaTriLay = from GiaTri in ds.Tables[0].AsEnumerable()
                                select GiaTri;

                dataGridView1.DataSource = null;
                dataGridView1.DataSource = GiaTriLay.AsDataView();

                tinh_tong_luong_thuc_xuat();
            }

            foreach (DataGridViewRow row in dataGridView1.Rows)
            {
                row.HeaderCell.Value = String.Format("{000}", row.Index + 1);
            }


            conn.Dispose();
            adapter.Dispose();
            comm.Dispose();
            malenhxuattoday = dataGridView1.RowCount;
        }