Beispiel #1
0
        public MainForm()
        {
            InitializeComponent();
            DataController.Execute("exec khoitao");
            random = new Random();
            Region = System.Drawing.Region.FromHrgn(CreateRoundRectRgn(0, 0, Width, Height, 20, 20));
            btnCloseChildForm.Visible = false;

            this.Text       = string.Empty;
            this.ControlBox = false;

            labelName.Text = LoginUser.UserData()["tennv"].ToString();
            labelRole.Text = LoginUser.UserData()["tenchucvu"].ToString();


            string phanquyen = LoginUser.UserData()["machucvu"].ToString();

            if (phanquyen == "1")
            {
                btnBaoCaoThongKe.Visible = false;
                btnQuanLyChi.Visible     = false;
                btnCaiDatThamSo.Visible  = false;
                btnQuanLyHeThong.Visible = false;
                btnQuanLyHocSinh.Visible = false;
                btnQuanLyThu.Visible     = false;
            }

            if (phanquyen == "2")
            {
                btnQuanLyVeAn.Visible = false;
                button2.Visible       = false;
            }

            if (phanquyen == "3")
            {
                btnBaoCaoThongKe.Visible = false;
                btnQuanLyChi.Visible     = false;
                btnCaiDatThamSo.Visible  = false;
                btnQuanLyHeThong.Visible = false;
                btnQuanLyHocSinh.Visible = false;
                btnQuanLyThu.Visible     = false;
                button2.Visible          = false;
                btnQuanLyVeAn.Visible    = false;
            }
            else
            {
                foreach (Control btns in this.Controls)
                {
                    if (btns.GetType() == typeof(Button))
                    {
                        Button btn = (Button)btns;
                        btn.Visible = false;
                    }
                }
            }
        }
Beispiel #2
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;
            }
        }
Beispiel #3
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;
            }
        }
Beispiel #4
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;
        }
Beispiel #5
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; ");
                }
            }
        }
Beispiel #6
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;
                }
            }
        }
Beispiel #7
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;
                    }
                }
            }
        }