private void frmDonTiep_Load(object sender, EventArgs e)
        {
            load();
            cbx_BacSiGui.DataSource = load_bs();

            cbx_BacSiGui.ValueMember     = "BacSiID";
            cbx_BacSiGui.DisplayMember   = "HoTen";
            cbx_GioiTinh.DataSource      = Util.ResetControl.getTable_forCombo(new string[] { "ID", "Name" }, new string[] { "True", "False" }, new string[] { "Nam", "Nữ" });
            cbx_GioiTinh.DisplayMember   = "ID";
            cbx_GioiTinh.ValueMember     = "Name";
            cbx_MaDoiTuong.DataSource    = DoiTuong_Info.SelectAllTable();
            cbx_MaDoiTuong.ValueMember   = "TenDoiTuong";
            cbx_MaDoiTuong.DisplayMember = "DoiTuongID";
            Util.FormHandler.SetEnterKeyForAllControlsLevel(txtDiaChi.GetType(), this.Controls);
            Util.FormHandler.SetEnterKeyForAllControlsLevel(txtNamSinh.GetType(), this.Controls);
            Util.FormHandler.SetEnterKeyForAllControlsLevel(cdt_Ngayvaovien.GetType(), this.Controls);
            Util.ResetControl.SetEnterForUltraComboUltraTextBox(new UltraCombo[] { cbx_GioiTinh, cbx_MaDoiTuong }, new TextBox[] { txtGioiTinh, txtTenDoiTuong });
            Util.ResetControl.SetSourceForGridCustomCollumns(gridDSDichVu, new string[] { "MaDichVu", "TenDichVu", "DonGia" }, new string[] { "Mã dịch vụ", "Tên dịch vụ", "Đơn giá" });
            Util.ResetControl.SetSourceForGridCustomCollumns(gridDSDichVuKe, new string[] { "MaDichVu", "TenDichVu", "SoLuong", "DonGia" }, new string[] { "Mã dịch vụ", "Tên dịch vụ", "Số lượng", "Đơn giá" });
            DataTable dataTable = DB_SQL.EXECUTE_SQL("select max(SoKham) as SoKham from LanKham");
            bool      flag      = dataTable.Rows[0]["SoKham"].ToString() != "";

            if (!flag)
            {
                txtSoKham.Text = "1";
            }
            else
            {
                int i = Convert.ToInt32(dataTable.Rows[0]["SoKham"].ToString()) + 1;
                txtSoKham.Text = i.ToString();
            }
            txtHoTenBenhNhan.Focus();
        }
Exemplo n.º 2
0
        void load()
        {
            gridDanhSach.DataSource = DB_SQL.EXECUTE_SQL(@"Select * from BacSi where TrangThai=1");

            Util.ResetControl.ReadOnly_Control(this);
            txtSearch.ReadOnly = false;
        }
        private void btn_Luu_Click(object sender, EventArgs e)
        {
            bool flag = CheckValue();

            if (flag)
            {
                BenhNhan_Info benhNhan_Info = new BenhNhan_Info(0, txtHoTenBenhNhan.Text, txtDiaChi.Text, txtSoDienThoai.Text, Convert.ToInt32(txtNamSinh.Value), Convert.ToDateTime(new DateTime(DateTime.Now.Year - Convert.ToInt32(txtNamSinh.Value), DateTime.Now.Month, DateTime.Now.Day, 1, 0, 0)), Convert.ToBoolean(cbx_GioiTinh.Text));
                benhNhan_Info.Insert();
                LanKham_Info lanKham_Info = new LanKham_Info(0, benhNhan_Info.Ma, Convert.ToInt32(cbx_BacSiGui.Value), Convert.ToInt32(cbx_MaDoiTuong.Text), txtMaTheBHYT.Text, txtChuanDoan.Text, Convert.ToDateTime(cdt_Ngayvaovien.Value), "", Convert.ToInt32(txtSoKham.Text));
                lanKham_Info.Insert();
                IEnumerator ienumerator = ((DataTable)gridDSDichVuKe.DataSource).Rows.GetEnumerator();
                foreach (DataRow dataRow in ((DataTable)gridDSDichVuKe.DataSource).Rows)
                {
                    DichVu_LanKham_Info dichVu_LanKham_Info = new DichVu_LanKham_Info(0, Convert.ToInt32(dataRow["DichVuID"].ToString()), lanKham_Info.Ma, Convert.ToInt32(dataRow["BacSiGuiID"].ToString()), Convert.ToInt32(dataRow["SoLuong"].ToString()), Convert.ToDecimal(dataRow["DonGia"].ToString()), 0, Convert.ToDateTime(cdt_Ngayvaovien.Value), DateTime.Now, 0);
                    dichVu_LanKham_Info.Insert();
                }

                TienNop_LanKham_Info tn = new TienNop_LanKham_Info(0, lanKham_Info.LanKhamID, Convert.ToDecimal(txtTongChiPhi.Value), "");
                tn.Insert();


                DataTable dataTable = DB_SQL.EXECUTE_SQL("select max(SoKham) as SoKham from LanKham");
                flag = dataTable.Rows[0]["SoKham"].ToString() != "";
                if (!flag)
                {
                    txtSoKham.Text = "1";
                }
                else
                {
                    int i = Convert.ToInt32(dataTable.Rows[0]["SoKham"].ToString()) + 1;
                    txtSoKham.Text = i.ToString();
                }
                MessageBox.Show("Cập nhật thành công!", "Thông báo", MessageBoxButtons.OK);
                txtSoKham.Focus();
                // In biên lai

                DataTable ds = dsDichVuKe, temp;
                temp = dsDichVuKe.Copy();
                temp.Clear();
                foreach (DataRow r in ds.Rows)
                {
                    if (check_as(temp, "PhongID", r["PhongID"].ToString()))
                    {
                        DataRow rt = temp.NewRow();
                        rt["PhongID"] = r["PhongID"].ToString();
                        temp.Rows.Add(rt);
                        DataView v = ds.DefaultView;
                        v.RowFilter = "TenPhong='" + r["TenPhong"].ToString() + "'";
                        DataTable ds1 = v.ToTable();
                        decimal   t   = 0;
                        foreach (DataRow k in ds1.Rows)
                        {
                            t += Convert.ToDecimal(k["SoLuong"].ToString()) * Convert.ToDecimal(k["DonGia"].ToString());
                        }

                        string[]      ParamName  = { "@NgayThu", "@HoVaTen", "@Tuoi", "@DiaChi", "@TenDoiTuong", "@SoTien", "@BangChu", "@SoKham", "@Phong" };
                        object[]      ParamValue = { Convert.ToDateTime(cdt_Ngayvaovien.Value), txtHoTenBenhNhan.Text,          txtNamSinh.Value.ToString()
                                                     ,                                               txtDiaChi.Text,                 txtTenDoiTuong.Text,t,
                                                     Util.FormHandler.txtVND(Convert.ToDecimal(t)),  lanKham_Info.SoKham.ToString(), r["TenPhong"].ToString() };
                        frmReportMain report = new frmReportMain(11, v.ToTable(), ParamName, ParamValue);
                        report.Show();
                    }
                }
                txtTongChiPhi.Value = 0;

                clear();
                load();
            }
        }