예제 #1
0
        private void guna2DataGridView1_CellValueChanged(object sender, DataGridViewCellEventArgs e)
        {
            if (guna2DataGridView1.Columns[e.ColumnIndex].Name == "diemdanhvean")
            {
                string tenhinhthucan = guna2DataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString();
                string query1        = "select mahinhthucan from hinhthucan where tenhinhthucan = N'" + tenhinhthucan + "'";
                string mahinhthucan  = DataController.ExecTable(query1).Rows[0]["mahinhthucan"].ToString();

                DataGridViewRow dataRow   = guna2DataGridView1.Rows[e.RowIndex];
                string          day       = dateTimePicker1.Value.ToString("yyyy-MM-dd");
                string          mahocsinh = dataRow.Cells["mahocsinh"].Value.ToString();
                string          query2    = "select maxuatan from theodoixuatan " +
                                            "WHERE mahocsinh = " + mahocsinh + " " +
                                            "and tg = '" + day + "' ";
                string maxuatan = DataController.ExecTable(query2).Rows[0]["maxuatan"].ToString();
                string query3   = "UPDATE theodoixuatan " +
                                  "SET mahinhthucan = " + mahinhthucan + " " +
                                  "WHERE maxuatan = " + maxuatan;
                DataController.Execute(query3);
                ViewLoad();
                guna2DataGridView1.Rows[e.RowIndex].Selected = true;
            }

            if (guna2DataGridView1.Columns[e.ColumnIndex].Name == "vangmat" && guna2DataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString() == "True")
            {
                Console.WriteLine(guna2DataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString());
                DataGridViewRow dataRow   = guna2DataGridView1.Rows[e.RowIndex];
                string          mahocsinh = dataRow.Cells["mahocsinh"].Value.ToString();
                Controller.DiemDanhHocSinh.DiemDanhVang(mahocsinh);
                ViewLoad();
                guna2DataGridView1.Rows[e.RowIndex].Selected = true;
            }
            else if (guna2DataGridView1.Columns[e.ColumnIndex].Name == "vangmat" && guna2DataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString() == "False")
            {
                DataGridViewRow dataRow   = guna2DataGridView1.Rows[e.RowIndex];
                string          mahocsinh = dataRow.Cells["mahocsinh"].Value.ToString();
                Controller.DiemDanhHocSinh.DiemDanhCoMat(mahocsinh);
                ViewLoad();
                guna2DataGridView1.Rows[e.RowIndex].Selected = true;
            }
        }
예제 #2
0
        private void guna2DataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            txt_ten.Enabled          = false;
            txt_tien.Enabled         = false;
            txt_SoLuong.Enabled      = false;
            cbb_loaikhoanchi.Enabled = false;
            txt_GhiChu.Enabled       = false;
            cbb_loaikhoanchi.Enabled = false;
            cbb_type.Enabled         = false;

            if (addMode)
            {
                addMode             = false;
                btn_HuyThem.Visible = false;
                btn_Sua.Enabled     = true;
                btn_Xoa.Enabled     = true;
            }

            string    mathu = guna2DataGridView1.CurrentRow.Cells[0].Value.ToString();
            DataTable dt    = DataController.ExecTable("select * from tttienchi where matttc = " + mathu);
            DataRow   data  = dt.Rows[0];

            txt_ten.Text     = data["tentienchi"].ToString();
            txt_tien.Text    = data["thanhtien"].ToString();
            txt_SoLuong.Text = data["soluong"].ToString();
            if (!data.IsNull("manguyenlieu"))
            {
                cbb_loaikhoanchi.SelectedIndex = 0;
                cbb_type.SelectedIndex         = int.Parse(data["manguyenlieu"].ToString()) - 1;
            }
            else if (!data.IsNull("mahoclieu"))
            {
                cbb_loaikhoanchi.SelectedIndex = 1;
                cbb_type.SelectedIndex         = int.Parse(data["mahoclieu"].ToString()) - 1;
            }
            else if (!data.IsNull("mahdnk"))
            {
                cbb_loaikhoanchi.SelectedIndex = 2;
                cbb_type.SelectedIndex         = int.Parse(data["mahdnk"].ToString()) - 1;
            }
        }
예제 #3
0
        private void cbb_Thang_SelectedIndexChanged(object sender, EventArgs e)
        {
            string str = "select" +
                         " hoadonthang.mahoadonthang," +
                         " hocsinh.mahocsinh," +
                         " hocsinh.tenhocsinh," +
                         " hoadonthang.tonghocphi," +
                         " baocao.thang," +
                         " baocao.nam," +
                         " trangthai.tentrangthai" +
                         " from hoadonthang inner join hocsinh " +
                         "on hocsinh.mahocsinh = hoadonthang.mahocsinh " +
                         "inner join baocao " +
                         "on baocao.mabctt = hoadonthang.mabctt " +
                         "inner join trangthai " +
                         "on hoadonthang.matrangthai = trangthai.matrangthai" +
                         " where hocsinh.makhoi = " + (listBox1.SelectedIndex + 1).ToString() +
                         " and baocao.thang = " + cbb_Thang.Text +
                         " and baocao.nam = " + cbb_Nam.Text;

            guna2DataGridView1.DataSource = DataController.ExecTable(str);
        }
예제 #4
0
        private void btn_Xoa_Click(object sender, EventArgs e)
        {
            string mathu = guna2DataGridView1.CurrentRow.Cells[0].Value.ToString();

            DataController.Execute("Delete from tttienchi where matttc = " + mathu);

            guna2DataGridView1.DataSource = DataController.ExecTable("select " +
                                                                     "matttc, " +
                                                                     "tentienchi, " +
                                                                     "soluong, " +
                                                                     "thanhtien, " +
                                                                     "thoigian, " +
                                                                     "tennv " +
                                                                     "from tttienchi " +
                                                                     "inner join nhanvien on tttienchi.manv = nhanvien.manv");
            DataTable dt   = DataController.ExecTable("select * from tttienchi where matttc = " + guna2DataGridView1.CurrentRow.Cells[0].Value.ToString());
            DataRow   data = dt.Rows[0];

            txt_ten.Text     = data["tentienchi"].ToString();
            txt_tien.Text    = data["thanhtien"].ToString();
            txt_SoLuong.Text = data["soluong"].ToString();
            if (!data.IsNull("manguyenlieu"))
            {
                cbb_loaikhoanchi.SelectedIndex = 0;
                cbb_type.SelectedIndex         = int.Parse(data["manguyenlieu"].ToString()) - 1;
            }
            else if (!data.IsNull("mahoclieu"))
            {
                cbb_loaikhoanchi.SelectedIndex = 1;
                cbb_type.SelectedIndex         = int.Parse(data["mahoclieu"].ToString()) - 1;
            }
            else if (!data.IsNull("mahdnk"))
            {
                cbb_loaikhoanchi.SelectedIndex = 2;
                cbb_type.SelectedIndex         = int.Parse(data["mahdnk"].ToString()) - 1;
            }
        }
예제 #5
0
        private void button3_Click(object sender, EventArgs e)
        {
            DataController.Execute("Delete from phuthu where maphuthu =" + guna2DataGridView1.CurrentRow.Cells[0].Value.ToString());
            guna2DataGridView1.DataSource = DataController.ExecTable("select " +
                                                                     "phuthu.maphuthu," +
                                                                     "hocsinh.mahocsinh, " +
                                                                     "hocsinh.tenhocsinh, " +
                                                                     "phuthu.tenphuthu, " +
                                                                     "phuthu.thanhtien, " +
                                                                     "phuthu.maloai, " +
                                                                     "phuthu.nguoilapkhoanthu " +
                                                                     "from phuthu inner join hocsinh on " +
                                                                     "hocsinh.mahocsinh = phuthu.mahocsinh; ");

            txt_ten.Enabled  = false;
            txt_tien.Enabled = false;
            cbb_hs.Enabled   = false;
            cbb_type.Enabled = false;

            txt_ten.Text           = guna2DataGridView1.CurrentRow.Cells[2].Value.ToString();
            txt_tien.Text          = guna2DataGridView1.CurrentRow.Cells[4].Value.ToString();
            cbb_hs.SelectedIndex   = int.Parse(guna2DataGridView1.CurrentRow.Cells[1].Value.ToString()) - 1;
            cbb_type.SelectedIndex = int.Parse(guna2DataGridView1.CurrentRow.Cells[5].Value.ToString()) - 1;
        }
예제 #6
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (!addMode)
            {
                addMode = true;

                txt_ten.Enabled  = true;
                txt_tien.Enabled = true;
                cbb_hs.Enabled   = true;
                cbb_type.Enabled = true;

                txt_tien.Clear();
                txt_ten.Clear();
                cbb_hs.SelectedIndex   = -1;
                cbb_type.SelectedIndex = -1;
                btn_HuyThem.Visible    = true;
            }
            else
            {
                if (string.IsNullOrWhiteSpace(txt_ten.Text))
                {
                    MessageBox.Show("Chưa nhập tên phụ thu", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                else if (string.IsNullOrWhiteSpace(txt_tien.Text))
                {
                    MessageBox.Show("Chưa nhập thành tiền tiền", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                else if (cbb_hs.SelectedIndex == -1)
                {
                    MessageBox.Show("Chưa chọn học sinh", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                else if (cbb_type.SelectedIndex == -1)
                {
                    MessageBox.Show("Chưa nhập loại phụ thu", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                else
                {
                    string mhs    = (cbb_hs.SelectedIndex + 1).ToString();
                    string maloai = (cbb_type.SelectedIndex + 1).ToString();
                    DataController.Execute("insertphuthu N'" +
                                           txt_ten.Text + "' ," +
                                           txt_tien.Text + ", N'" +
                                           LoginUser.UserData()["tennv"] + "', " +
                                           maloai + ", " +
                                           mhs);

                    txt_ten.Enabled  = false;
                    txt_tien.Enabled = false;
                    cbb_hs.Enabled   = false;
                    cbb_type.Enabled = false;

                    txt_ten.Text           = guna2DataGridView1.CurrentRow.Cells[2].Value.ToString();
                    txt_tien.Text          = guna2DataGridView1.CurrentRow.Cells[4].Value.ToString();
                    cbb_hs.SelectedIndex   = int.Parse(guna2DataGridView1.CurrentRow.Cells[1].Value.ToString()) - 1;
                    cbb_type.SelectedIndex = int.Parse(guna2DataGridView1.CurrentRow.Cells[5].Value.ToString()) - 1;

                    guna2DataGridView1.DataSource = DataController.ExecTable("select " +
                                                                             "phuthu.maphuthu," +
                                                                             "hocsinh.mahocsinh, " +
                                                                             "hocsinh.tenhocsinh, " +
                                                                             "phuthu.tenphuthu, " +
                                                                             "phuthu.thanhtien, " +
                                                                             "phuthu.maloai, " +
                                                                             "phuthu.nguoilapkhoanthu " +
                                                                             "from phuthu inner join hocsinh on " +
                                                                             "hocsinh.mahocsinh = phuthu.mahocsinh; ");
                }
            }
        }
예제 #7
0
        private void button2_Click(object sender, EventArgs e)
        {
            if (!editMode)
            {
                editMode = true;

                txt_ten.Enabled  = true;
                txt_tien.Enabled = true;
                cbb_type.Enabled = true;
            }
            else
            {
                if (string.IsNullOrWhiteSpace(txt_ten.Text))
                {
                    MessageBox.Show("Chưa nhập tên phụ thu", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                else if (string.IsNullOrWhiteSpace(txt_tien.Text))
                {
                    MessageBox.Show("Chưa nhập thành tiền tiền", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                else if (cbb_hs.SelectedIndex == -1)
                {
                    MessageBox.Show("Chưa chọn học sinh", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                else if (cbb_type.SelectedIndex == -1)
                {
                    MessageBox.Show("Chưa nhập loại phụ thu", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                else
                {
                    string mhs    = (cbb_hs.SelectedIndex + 1).ToString();
                    string maloai = (cbb_type.SelectedIndex + 1).ToString();
                    DataController.Execute("update phuthu set " +
                                           "tenphuthu = N'" + txt_ten.Text + "'" +
                                           ", thanhtien = " + txt_tien.Text +
                                           ", maloai = " + (cbb_type.SelectedIndex + 1) +
                                           " where maphuthu = " + guna2DataGridView1.CurrentRow.Cells[0].Value.ToString());

                    guna2DataGridView1.DataSource = DataController.ExecTable("select " +
                                                                             "phuthu.maphuthu," +
                                                                             "hocsinh.mahocsinh, " +
                                                                             "hocsinh.tenhocsinh, " +
                                                                             "phuthu.tenphuthu, " +
                                                                             "phuthu.thanhtien, " +
                                                                             "phuthu.maloai, " +
                                                                             "phuthu.nguoilapkhoanthu " +
                                                                             "from phuthu inner join hocsinh on " +
                                                                             "hocsinh.mahocsinh = phuthu.mahocsinh; ");

                    txt_ten.Enabled  = false;
                    txt_tien.Enabled = false;
                    cbb_hs.Enabled   = false;
                    cbb_type.Enabled = false;

                    txt_ten.Text           = guna2DataGridView1.CurrentRow.Cells[2].Value.ToString();
                    txt_tien.Text          = guna2DataGridView1.CurrentRow.Cells[4].Value.ToString();
                    cbb_hs.SelectedIndex   = int.Parse(guna2DataGridView1.CurrentRow.Cells[1].Value.ToString()) - 1;
                    cbb_type.SelectedIndex = int.Parse(guna2DataGridView1.CurrentRow.Cells[5].Value.ToString()) - 1;

                    editMode = false;
                }
            }
        }
예제 #8
0
 public static DataRow UserData()
 {
     return(DataController.ExecTable("select * from nhanvien, chucvu where nhanvien.machucvu = chucvu.machucvu and manv = " + manv.ToString()).Rows[0]);
 }
예제 #9
0
 private void FormBaoCaoThongKeNK_Load(object sender, EventArgs e)
 {
     guna2DataGridView1.DataSource = DataController.ExecTable("select mahdnk, tenhdnk, chiphidukien, ghichu from hoatdongngoaikhoa");
 }
예제 #10
0
 private void FormBaoCaoThongKeKho_Load(object sender, EventArgs e)
 {
     guna2DataGridView1.DataSource = DataController.ExecTable("select * from nguyenlieu");
     guna2DataGridView2.DataSource = DataController.ExecTable("select * from hoclieu");
 }
예제 #11
0
        private void btn_Sua_Click(object sender, EventArgs e)
        {
            if (!editMode)
            {
                editMode            = true;
                txt_ten.Enabled     = true;
                txt_tien.Enabled    = true;
                txt_SoLuong.Enabled = true;
            }
            else
            {
                if (string.IsNullOrWhiteSpace(txt_ten.Text))
                {
                    MessageBox.Show("Chưa nhập tên khoản chi", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                else if (string.IsNullOrWhiteSpace(txt_tien.Text))
                {
                    MessageBox.Show("Chưa nhập số tiền", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                else if (string.IsNullOrWhiteSpace(txt_SoLuong.Text))
                {
                    MessageBox.Show("Chưa nhập số lượng", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                else if (cbb_loaikhoanchi.SelectedIndex == -1)
                {
                    MessageBox.Show("Chưa chọn loại khoản chi", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                else if (cbb_type.SelectedIndex == -1)
                {
                    MessageBox.Show("Chưa nhập mã khoản chi", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                else
                {
                    string mathu1     = guna2DataGridView1.CurrentRow.Cells[0].Value.ToString();
                    string loai       = (cbb_loaikhoanchi.SelectedIndex + 1).ToString();
                    string magiaovien = LoginUser.UserData()["manv"].ToString();

                    DataController.Execute("update tttienchi set " +
                                           "soluong = " + txt_SoLuong.Text +
                                           ", thanhtien = " + txt_tien.Text +
                                           ", tentienchi = N'" + txt_ten.Text + "'" +
                                           "where matttc = " + mathu1);

                    guna2DataGridView1.DataSource = DataController.ExecTable("select " +
                                                                             "matttc, " +
                                                                             "tentienchi, " +
                                                                             "soluong, " +
                                                                             "thanhtien, " +
                                                                             "thoigian, " +
                                                                             "tennv " +
                                                                             "from tttienchi " +
                                                                             "inner join nhanvien on tttienchi.manv = nhanvien.manv");


                    editMode            = false;
                    btn_Sua.Enabled     = true;
                    btn_Xoa.Enabled     = true;
                    btn_HuyThem.Visible = false;

                    txt_ten.Enabled          = false;
                    txt_tien.Enabled         = false;
                    txt_SoLuong.Enabled      = false;
                    cbb_loaikhoanchi.Enabled = false;
                    txt_GhiChu.Enabled       = false;
                    cbb_loaikhoanchi.Enabled = false;
                    cbb_type.Enabled         = false;


                    DataTable dt   = DataController.ExecTable("select * from tttienchi where matttc = " + mathu1);
                    DataRow   data = dt.Rows[0];

                    txt_ten.Text     = data["tentienchi"].ToString();
                    txt_tien.Text    = data["thanhtien"].ToString();
                    txt_SoLuong.Text = data["soluong"].ToString();
                    if (!data.IsNull("manguyenlieu"))
                    {
                        cbb_loaikhoanchi.SelectedIndex = 0;
                        cbb_type.SelectedIndex         = int.Parse(data["manguyenlieu"].ToString()) - 1;
                    }
                    else if (!data.IsNull("mahoclieu"))
                    {
                        cbb_loaikhoanchi.SelectedIndex = 1;
                        cbb_type.SelectedIndex         = int.Parse(data["mahoclieu"].ToString()) - 1;
                    }
                    else if (!data.IsNull("mahdnk"))
                    {
                        cbb_loaikhoanchi.SelectedIndex = 2;
                        cbb_type.SelectedIndex         = int.Parse(data["mahdnk"].ToString()) - 1;
                    }
                }
            }
        }