public string GetTestDB()
        {
            string Result = "";

            MainViewModel.Current.Prologue(Request);

            try
            {
                if (!string.IsNullOrEmpty(MainViewModel.Current.Connection.LastError))
                {
                    return(MainViewModel.Current.Connection.LastError);
                }
                ;
            }
            catch (Exception ex)
            {
                return("(1) " + ex.Message);
            };

            if (MainViewModel.Current.Connection.DbConnection.State != System.Data.ConnectionState.Open)
            {
                MainViewModel.Current.Connection.CheckConnection();
            }
            ;

            Result = DB_SQL.QuickQuery("SELECT @@VERSION ;");

            if (!string.IsNullOrEmpty(MainViewModel.Current.Connection.LastError))
            {
                return(MainViewModel.Current.Connection.LastError);
            }
            ;

            return(Result);
        }
示例#2
0
        void load()
        {
            gridDanhSach.DataSource = DB_SQL.EXECUTE_SQL(@"Select * from BacSi where TrangThai=1");

            Util.ResetControl.ReadOnly_Control(this);
            txtSearch.ReadOnly = false;
        }
        // - -  - -  - -  - -  - -  - -  - -  - -  - -  - -  - -  - -  - -  - -  - -

        public static void WriteLineDB(DBSQLViewModel dBSQLViewModel, AuditTrailViewModel sender, AuditTrail message)
        {
            if (dBSQLViewModel == null)
            {
                return;
            }

            try
            {
                DB_SQL.Insert(dBSQLViewModel, message);

                if (!string.IsNullOrEmpty(dBSQLViewModel.LastError))
                {
                    Debug.WriteLine("AuditTrailViewModel LastError: " + dBSQLViewModel.LastError + Environment.NewLine
                                    + "AuditTrailViewModel LastQuery: " + dBSQLViewModel.LastQuery);

                    //Log.Debug(new AuditTrail
                    //{
                    //   Message = "AuditTrailViewWriter LastError: " + dBSQLViewModel.LastError + Environment.NewLine
                    //                                       + "AuditTrailViewWriter LastQuery: " + dBSQLViewModel.LastQuery
                    //});
                }
                ;
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine("AuditTrailViewModel: " + ex.Message);

                //Log.Debug(new AuditTrail
                //{
                //   Message = "AuditTrailViewWriter: " + ex.Message
                //});
            };
        }
        // - -  - -  - -  - -  - -  - -  - -  - -  - -  - -  - -  - -  - -  - -  - -

        public static ObservableCollection <AuditTrail> LoadAuditTrail(DBSQLViewModel dBSQLViewModel, AuditTrailViewModel sender, bool Filtered = true, long MaxRecords = 500)
        {
            var AuditTrail = new List <AuditTrail>();

            string Where = GetWhere(dBSQLViewModel.DBType, sender);

            string SQL = DB_SQL.SelectAll(dBSQLViewModel.DBType, "AuditTrail", Where, MaxRecords);

            if (dBSQLViewModel != null)
            {
                try
                {
                    AuditTrail = DB_SQL.Query <AuditTrail>(dBSQLViewModel, SQL);

                    if (AuditTrail == null)
                    {
                        AuditTrail = new List <AuditTrail>();
                    }
                    ;
                }
                catch (Exception ex)
                {
                    Debug.WriteLine(ex.Message);
                };
            }
            ;

            return(new ObservableCollection <AuditTrail>(AuditTrail));
        }
        // - -  - -  - -  - -  - -  - -  - -  - -  - -  - -  - -  - -  - -  - -  - -

        public static long BeginWriteDB(DBSQLViewModel dBSQLViewModel, AuditTrailViewModel sender, AuditTrail message)
        {
            long Result = -1;

            try
            {
                Result = DB_SQL.InsertGetPK(dBSQLViewModel, message);
                if (!string.IsNullOrEmpty(dBSQLViewModel.LastError))
                {
                    Debug.WriteLine("AuditTrailViewWriter LastError: " + dBSQLViewModel.LastError + Environment.NewLine
                                    + "AuditTrailViewWriter LastQuery: " + dBSQLViewModel.LastQuery);

                    Log.Write(new AuditTrail
                    {
                        Message = "AuditTrailViewWriter LastError: " + dBSQLViewModel.LastError + Environment.NewLine
                                  + "AuditTrailViewWriter LastQuery: " + dBSQLViewModel.LastQuery
                    });
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine("AuditTrailViewWriter: " + ex.Message);

                Log.Write(new AuditTrail
                {
                    Message = "AuditTrailViewWriter: " + ex.Message
                });
            };

            return(Result);
        }
        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();
        }
        public IDB DoConfig()
        {
            DB_SQL Config = null;

            if (String.IsNullOrEmpty(StrServer))
            {
                SetError(this.txt_Server, "服务器不能为空");

                return(Config);
            }

            if (String.IsNullOrEmpty(StrUser))
            {
                SetError(txt_User, "用户名不能为空");
                return(Config);
            }

            if (String.IsNullOrEmpty(StrPassword))
            {
                SetError(txt_Pwd, "密码不能为空");
                return(Config);
            }

            if (String.IsNullOrEmpty(StrDataBase))
            {
                SetError(txt_DataBase, "数据库不能为空");
                return(Config);
            }


            DB_SQL tmp = new DB_SQL()
            {
                Server   = StrServer,
                DataBase = StrDataBase,
                UserID   = StrUser,
                Password = StrPassword,
                Port     = txt_Port.Text
            };

            try
            {
                var fac = System.Data.Common.DbProviderFactories.GetFactory(tmp.ProviderName);

                using (var conn = fac.CreateConnection())
                {
                    conn.ConnectionString = tmp.GetConnectionStr();
                    conn.Open();
                    conn.Close();
                    Config = tmp;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
            return(Config);
        }
        public DataTable GetDataBaseList()
        {
            if (String.IsNullOrEmpty(StrServer))
            {
                SetError(this.txt_Server, "服务器不能为空");
                return(null);
            }

            if (String.IsNullOrEmpty(StrUser))
            {
                SetError(this.txt_User, "用户名不能为空");
                return(null);
            }

            if (String.IsNullOrEmpty(StrPassword))
            {
                SetError(this.txt_Pwd, "密码不能为空");
                return(null);
            }

            DataTable dt = new DataTable();

            DB_SQL tmp = new DB_SQL()
            {
                Server   = StrServer,
                Port     = txt_Port.Text,
                DataBase = "master",
                UserID   = StrUser,
                Password = StrPassword
            };
            string        ConnectionStr = tmp.GetConnectionStr();
            SqlConnection conn          = new SqlConnection(ConnectionStr);

            try
            {
                conn.Open();
                //string str = "SELECT name FROM  sys.sysdatabases WHERE dbid>6";
                string         str  = "SELECT name FROM  sys.sysdatabases";
                SqlCommand     cmd  = new SqlCommand(str, conn);
                SqlDataAdapter sdap = new SqlDataAdapter();
                sdap.SelectCommand = cmd;

                sdap.Fill(dt);
                conn.Close();
            }
            catch (Exception ex)
            {
                if (conn.State == ConnectionState.Open)
                {
                    conn.Close();
                }
                MessageBox.Show(ex.ToString());
                dt = null;
            }
            return(dt);
        }
示例#9
0
        public bool Delete()
        {
            object[] arrvalue = new object[2] {
                "@LanKhamID", _LanKhamID
            };
            object output1 = null;
            bool   k       = DB_SQL.EXECUTE_PROCE("LanKham_Delete", arrvalue);

            return(k);
        }
示例#10
0
        public bool Delete()
        {
            object[] arrvalue = new object[2] {
                "@DoiTuongID", _DoiTuongID
            };
            object output1 = null;
            bool   k       = DB_SQL.EXECUTE_PROCE("DoiTuong_Delete", arrvalue);

            return(k);
        }
        public bool Delete()
        {
            object[] arrvalue = new object[2] {
                "@BenhNhanID", _BenhNhanID
            };
            object output1 = null;
            bool   k       = DB_SQL.EXECUTE_PROCE("BenhNhan_Delete", arrvalue);

            return(k);
        }
示例#12
0
        public bool Update()
        {
            object[] arrvalue = new object[4] {
                "@DoiTuongID", _DoiTuongID,
                "@TenDoiTuong", _TenDoiTuong
            };
            bool k = DB_SQL.EXECUTE_PROCE("DoiTuong_Update", arrvalue);

            return(k);
        }
        public bool DoiMatKhau()
        {
            object[] arrvalue = new object[4] {
                "@BacSiID", _BacSiID,
                "@MatKhau", _MatKhau
            };

            bool k = DB_SQL.EXECUTE_PROCE("BacSi_DoiMatKhau", arrvalue);

            return(k);
        }
示例#14
0
        public bool Update()
        {
            object[] arrvalue = new object[6] {
                "@PhongID", _PhongID,
                "@TenPhong", _TenPhong,
                "@DiaChi", _DiaChi
            };
            bool k = DB_SQL.EXECUTE_PROCE("Phong_Update", arrvalue);

            return(k);
        }
示例#15
0
        public bool Update()
        {
            object[] arrvalue = new object[8] {
                "@TienNop_LanKhamID", _TienNop_LanKhamID,
                "@LanKhamID", _LanKhamID,
                "@ThucThu", _ThucThu,
                "@LyDoThu", _LyDoThu
            };
            bool k = DB_SQL.EXECUTE_PROCE("TienNop_LanKham_Update", arrvalue);

            return(k);
        }
示例#16
0
        public bool Insert()
        {
            object[] arrvalue = new object[4] {
                "@DoiTuongID", _DoiTuongID,
                "@TenDoiTuong", _TenDoiTuong
            };
            object output1 = null;
            bool   k       = DB_SQL.EXECUTE_PROCNONE2("DoiTuong_Insert", "@DoiTuongID", System.Data.SqlDbType.Int, ref output1, arrvalue);

            DoiTuongID = Convert.ToInt32(output1);
            return(k);
        }
示例#17
0
        public bool Insert()
        {
            object[] arrvalue = new object[6] {
                "@LanKhamID", _LanKhamID,
                "@ThucThu", _ThucThu,
                "@LyDoThu", _LyDoThu
            };
            object output1 = null;
            bool   k       = DB_SQL.EXECUTE_PROCNONE2("TienNop_LanKham_Insert", "@TienNop_LanKhamID", System.Data.SqlDbType.Int, ref output1, arrvalue);

            TienNop_LanKhamID = Convert.ToInt32(output1);
            return(k);
        }
示例#18
0
        public bool Update()
        {
            object[] arrvalue = new object[12] {
                "@DichVuID", _DichVuID,
                "@MaDichVu", _MaDichVu,
                "@TenDichVu", _TenDichVu,
                "@DonViTinh", _DonViTinh,
                "@DonGia", _DonGia,
                "@PhongID", _PhongID
            };
            bool k = DB_SQL.EXECUTE_PROCE("DichVu_Update", arrvalue);

            return(k);
        }
        public bool Update()
        {
            object[] arrvalue = new object[14] {
                "@BenhNhanID", _BenhNhanID,
                "@HoTen", _HoTen,
                "@DiaChi", _DiaChi,
                "@DienThoai", _DienThoai,
                "@Tuoi", _Tuoi,
                "@NgaySinh", _NgaySinh,
                "@GioiTinh", _GioiTinh
            };
            bool k = DB_SQL.EXECUTE_PROCE("BenhNhan_Update", arrvalue);

            return(k);
        }
示例#20
0
        public bool Insert()
        {
            object[] arrvalue = new object[10] {
                "@MaDichVu", _MaDichVu,
                "@TenDichVu", _TenDichVu,
                "@DonViTinh", _DonViTinh,
                "@DonGia", _DonGia,
                "@PhongID", _PhongID
            };
            object output1 = null;
            bool   k       = DB_SQL.EXECUTE_PROCNONE2("DichVu_Insert", "@DichVuID", System.Data.SqlDbType.Int, ref output1, arrvalue);

            DichVuID = Convert.ToInt32(output1);
            return(k);
        }
        public bool Insert()
        {
            object[] arrvalue = new object[] {
                "@HoTen", _HoTen,
                "@DiaChi", _DiaChi,
                "@DienThoai", _DienThoai,
                "@Tuoi", _Tuoi,
                "@NgaySinh", _NgaySinh,
                "@GioiTinh", _GioiTinh,
                "@MaBV", ConfigurationSettings.AppSettings["MaBV"]
            };
            object output1 = null;
            bool   k       = DB_SQL.EXECUTE_PROCNONE2("BenhNhan_Insert", "@Ma", System.Data.SqlDbType.NVarChar, ref output1, arrvalue);

            Ma = Convert.ToString(output1);
            return(k);
        }
        public string GetConfig([FromHeader] string authorization)
        {
            MainViewModel.Current.Prologue(Request);

            if (!string.IsNullOrEmpty(authorization) && MainViewModel.Current.CheckAuthorization(authorization))
            {
                MainViewModel.Current.TestUnitaires = false;

                TStrings config = DB_SQL.QuickQueryList("select DBList.Param as Name, DBList.Value from DBList where DBList.List='Config'");

                return(config.Text);
            }
            else
            {
                return(null);
            };
        }
示例#23
0
        public bool Update()
        {
            object[] arrvalue = new object[18] {
                "@LanKhamID", _LanKhamID,
                "@MaBenhNhan", _MaBenhNhan,
                "@BacSiGuiID", _BacSiGuiID,
                "@DoiTuongID", _DoiTuongID,
                "@SoBH", _SoBH,
                "@ChuanDoan", _ChuanDoan,
                "@NgayKham", _NgayKham,
                "@GioKham", _GioKham,
                "@SoKham", _SoKham
            };
            bool k = DB_SQL.EXECUTE_PROCE("LanKham_Update", arrvalue);

            return(k);
        }
示例#24
0
        public bool Update()
        {
            object[] arrvalue = new object[18] {
                "@BacSiID", _BacSiID,
                "@HoTen", _HoTen,
                "@NgaySinh", _NgaySinh,
                "@GioiTinh", _GioiTinh,
                "@DienThoai", _DienThoai,
                "@DiaChi", _DiaChi,

                "@QuyenHan", _QuyenHan,
                "@TrangThai", _TrangThai,
                "@GhiChu", _GhiChu
            };
            bool k = DB_SQL.EXECUTE_PROCE("BacSi_Update2", arrvalue);

            return(k);
        }
示例#25
0
        public bool Update()
        {
            object[] arrvalue = new object[20] {
                "@DichVu_LanKhamID", _DichVu_LanKhamID,
                "@DichVuID", _DichVuID,
                "@MaLanKham", _MaLanKham,
                "@BacSiGuiID", _BacSiGuiID,
                "@SoLuong", _SoLuong,
                "@DonGia", _DonGia,
                "@SoLuongHuy", _SoLuongHuy,
                "@NgayKe", _NgayKe,
                "@NgayThucHien", _NgayThucHien,
                "@TrangThai", _TrangThai
            };
            bool k = DB_SQL.EXECUTE_PROCE("DichVu_LanKham_Update", arrvalue);

            return(k);
        }
示例#26
0
        public bool Insert()
        {
            object[] arrvalue = new object[16] {
                "@HoTen", _HoTen,
                "@NgaySinh", _NgaySinh,
                "@GioiTinh", _GioiTinh,
                "@DienThoai", _DienThoai,
                "@DiaChi", _DiaChi,

                "@QuyenHan", _QuyenHan,
                "@TrangThai", _TrangThai,
                "@GhiChu", _GhiChu
            };
            object output1 = null;
            bool   k       = DB_SQL.EXECUTE_PROCNONE2("BacSi_Insert2", "@BacSiID", System.Data.SqlDbType.Int, ref output1, arrvalue);

            BacSiID = Convert.ToInt32(output1);
            return(k);
        }
示例#27
0
        public bool Insert()
        {
            object[] arrvalue = new object[] {
                "@MaBenhNhan", _MaBenhNhan,
                "@BacSiGuiID", _BacSiGuiID,
                "@DoiTuongID", _DoiTuongID,
                "@SoBH", _SoBH,
                "@ChuanDoan", _ChuanDoan,
                "@NgayKham", _NgayKham,
                "@GioKham", _GioKham,
                "@SoKham", _SoKham,
                "@MaBV", ConfigurationSettings.AppSettings["MaBV"]
            };
            object output1 = null;
            bool   k       = DB_SQL.EXECUTE_PROCNONE2("LanKham_Insert", "@Ma", System.Data.SqlDbType.NVarChar, ref output1, arrvalue);

            Ma = Convert.ToString(output1);
            return(k);
        }
        public void Init_AT_SQLServer2()
        {
            string server   = "SQL6005.site4now.net";
            string db       = "DB_A44F11_StockAPPro2dev";
            string user     = "******";
            string password = "******";

            DBSQLViewModel AuditTrailConnection = null;

            AuditTrailConnection = new DBSQLViewModel(new SQLServerEngine());
            string AT_ConnectionString = DB_SQL.GenConnectionString(DBType.SQLServer, server, db, user, password);

            AuditTrailConnection.Open(AT_ConnectionString, true);

            AuditTrailViewModel.Current.Init(new DBAndFileAuditTrailWriter(AuditTrailConnection, string.Format(@"{0}", AuditTrailFileName)));
            // AuditTrailViewModel.Current.MaxLines = 5;
            //AuditTrailViewModel.Current.Clean(); // prend en compte uniquement nombre ligne

            Assert.AreEqual(true, AuditTrailConnection.CheckConnection());
        }
        public void Init_AT_PG()
        {
            string server   = "postgresql-zpf.alwaysdata.net";
            string db       = "zpf_postgresql";
            string user     = "******";
            string password = "******";

            DBSQLViewModel AuditTrailConnection = null;

            AuditTrailConnection = new DBSQLViewModel(new PostgreSQLEngine());
            string AT_ConnectionString = DB_SQL.GenConnectionString(DBType.PostgreSQL, server, db, user, password);

            AuditTrailConnection.Open(AT_ConnectionString, true);

            AuditTrailViewModel.Current.Init(new DBAndFileAuditTrailWriter(AuditTrailConnection, string.Format(@"{0}", AuditTrailFileName)));
            AuditTrailViewModel.Current.MaxLines = 5;
            AuditTrailViewModel.Current.Clean(); // prend en compte uniquement nombre ligne

            Assert.AreEqual(true, AuditTrailConnection.CheckConnection());
        }
示例#30
0
        public bool Insert()
        {
            object[] arrvalue = new object[] {
                "@DichVuID", _DichVuID,
                "@MaLanKham", _MaLanKham,
                "@BacSiGuiID", _BacSiGuiID,
                "@SoLuong", _SoLuong,
                "@DonGia", _DonGia,
                "@SoLuongHuy", _SoLuongHuy,
                "@NgayKe", _NgayKe,
                "@NgayThucHien", _NgayThucHien,
                "@TrangThai", _TrangThai,
                "@MaBV", ConfigurationSettings.AppSettings["MaBV"]
            };
            object output1 = null;
            bool   k       = DB_SQL.EXECUTE_PROCNONE2("DichVu_LanKham_Insert", "@Ma", System.Data.SqlDbType.NVarChar, ref output1, arrvalue);

            Ma = Convert.ToString(output1);
            return(k);
        }