private void AddEditTeacherFrm_Load(object sender, EventArgs e)
        {
            // Init database
            _db = ((MainFrm)Parent)._db;

            // For branch combobox
            _db.SQLCommand = "SELECT * FROM teacher_branch";
            _db.Query();
            while (_db.Result.Read())
            {
                cmbBrch.Items.Add((string)_db.Result.GetValue(1));
                _lstBrch.Add(new Branch { BranchID = (string)_db.Result.GetValue(0), BranchName = (string)_db.Result.GetValue(1) });
            }

            // For Edit mode
            if (EditMode == true)
            {
                _db.SQLCommand = "SELECT * FROM teacher WHERE tech_id='" + TechID + "'";
                _db.Query();
                if (_db.Result.HasRows)
                {
                    _db.Result.Read();
                    txtName.Text = (string)_db.Result.GetValue(1);
                    cmbBrch.Text = LookupBranchName((string)_db.Result.GetValue(2));
                    txtUsername.Text = (string)_db.Result.GetValue(3);
                    txtPassword.Text = (string)_db.Result.GetValue(4);
                    cmbQuestion.Text = (string)_db.Result.GetValue(7);
                    txtAnswer.Text = (string)_db.Result.GetValue(8);
                }
            }
        }
        private void TeacherPopUp_Load(object sender, EventArgs e)
        {
            // Init database
            _db = ((MainFrm)Parent)._db;

            // Setup datagrid columns
            dgv.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
            dgv.AllowUserToAddRows = false;
            dgv.AllowUserToDeleteRows = false;
            dgv.MultiSelect = false;
            dgv.ReadOnly = true;
            dgv.ColumnCount = 3;
            dgv.Columns[0].HeaderText = "รหัส";
            dgv.Columns[0].Visible = false;
            dgv.Columns[1].HeaderText = "ชื่อ-นามสกุล";
            dgv.Columns[1].Width = 125;
            dgv.Columns[2].HeaderText = "คณะ";
            dgv.Columns[2].Width = 200;

            // Load data
            _db.SQLCommand = _sqlShowAll;
            _db.Query();
            while (_db.Result.Read())
            {
                if (_db.Result["tech_name"].ToString() == "admin")
                {
                    continue;
                }
                dgv.Rows.Add(_db.Result["tech_id"], _db.Result["tech_name"], _db.Result["tech_brch_name"]);
            }
        }
 private void ForgetPasswordFrm_Load(object sender, EventArgs e)
 {
     _db = ((LoginFrm)Parent)._db;
     _db.SQLCommand = "SELECT tech_question, tech_answer, tech_password FROM teacher WHERE tech_username='******'";
     _db.Query();
     _db.Result.Read();
     txtQuestion.Text = (string)_db.Result.GetValue(0);
     _answer = (string)_db.Result.GetValue(1);
     _password = (string)_db.Result.GetValue(2);
 }
        private void UserSettingFrm_Load(object sender, EventArgs e)
        {
            _db = ((MainFrm)Parent)._db;
            _db.SQLCommand = "SELECT * FROM teacher WHERE tech_id='" + TechID + "'";
            _db.Query();
            _db.Result.Read();

            txtName.Text = (string)_db.Result.GetValue(1);
            txtUsername.Text = (string)_db.Result.GetValue(3);
            txtPassword.Text = (string)_db.Result.GetValue(4);
            cmbQuestion.Text = (string)_db.Result.GetValue(7);
            txtAnswer.Text = (string)_db.Result.GetValue(8);
        }
 private void AddEditSubjectFrm_Load(object sender, EventArgs e)
 {
     _db = ((MainFrm)Parent)._db;
     if (EditMode == true)
     {
         _db.SQLCommand = "SELECT * FROM subject WHERE sub_id='" + SubjectID + "'";
         _db.Query();
         if (_db.Result.HasRows)
         {
             _db.Result.Read();
             txtSubID.Text = (string)_db.Result.GetValue(1);
             txtSubName.Text = (string)_db.Result.GetValue(2);
         }
     }
 }
        private void CheckinDateFrm_Load(object sender, EventArgs e)
        {
            // Init database
            _db = ((MainFrm)Parent)._db;

            // Setup datagrid columns
            dgv.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
            dgv.AllowUserToAddRows = false;
            dgv.AllowUserToDeleteRows = false;
            dgv.MultiSelect = false;
            dgv.ReadOnly = true;
            dgv.ColumnCount = 1;
            dgv.Columns[0].HeaderText = "วันที่เช็คชื่อ";
            dgv.Columns[0].Width = 240;

            LoadDGV();
        }
        private void AddEditStudentFrm_Load(object sender, EventArgs e)
        {
            // Init Database
            _db = ((MainFrm)Parent)._db;

            // Init FP engine
            _fpEngine = new AxZKFPEngX();
            _fpEngine.BeginInit();
            _fpEngine.OnEnroll += new IZKFPEngXEvents_OnEnrollEventHandler(_fpEngine_OnEnroll);
            _fpEngine.OnImageReceived += new IZKFPEngXEvents_OnImageReceivedEventHandler(_fpEngine_OnImageReceived);
            this.Controls.Add(_fpEngine);

            if (_fpEngine.InitEngine() != 0)
            {
                MessageBox.Show("ไม่สามารถติดต่อเครื่องสแกนลายนิ้วมือได้", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                _fpDeviceConnect = false;
            }
            else
            {
                _fpDeviceConnect = true;
            }

            // For Edit mode
            if (EditMode == true)
            {
                _db.SQLCommand = "SELECT * FROM student WHERE std_id='" + StudentID + "'";
                _db.Query();
                if (_db.Result.HasRows)
                {
                    _db.Result.Read();
                    txtStdID.Text = (string)_db.Result.GetValue(0);
                    txtStdName.Text = (string)_db.Result.GetValue(1);
                    txtStdMajor.Text = (string)_db.Result.GetValue(2);
                    if (_db.Result.GetValue(3) == null)
                    {
                        txtFinger.Text = "";
                    }
                    else
                    {
                        txtFinger.Text = (string)_db.Result.GetValue(3);
                    }
                }
            }
        }
        private void AddEcitRegistrationFrm_Load(object sender, EventArgs e)
        {
            // Init database
            _db = ((MainFrm)Parent)._db;

            // For branch combobox
            _db.SQLCommand = "SELECT * FROM subject";
            _db.Query();
            while (_db.Result.Read())
            {
                cmbSubName.Items.Add((string)_db.Result.GetValue(2));
                _lstSubject.Add(new Subject { ID = (int)_db.Result.GetValue(0), SubjectID = (string)_db.Result.GetValue(1), SubjectName = (string)_db.Result.GetValue(2) });
            }

            // For Edit mode
            if (EditMode == true)
            {
                // Diable object
                txtStdID.Enabled = false;
                cmbYear.Enabled = false;

                // Retrieve data
                _db.SQLCommand = "SELECT * FROM registration WHERE reg_id='" + RegID + "'";
                _db.Query();
                if (_db.Result.HasRows)
                {
                    _db.Result.Read();
                    txtSubID.Text = LookupSubjectIDByID((int)_db.Result.GetValue(1));
                    cmbSubName.Text = LookupSubjectNameByID((int)_db.Result.GetValue(1));
                    txtStdID.Text = (string)_db.Result.GetValue(2);
                    cmbYear.Text = (string)_db.Result.GetValue(3);

                    // For student name
                    _db.SQLCommand = "SELECT std_name FROM student WHERE std_id='" + txtStdID.Text + "'";
                    _db.Query();
                    _db.Result.Read();
                    txtStdName.Text = (string)_db.Result.GetValue(0);
                }
            }
        }
Esempio n. 9
0
 public BE_BankMaster DeleteBankMaster(BE_BankMaster _BeBankMaster)
 {
     _database = new MySQLDatabase(connectionString);
     return(new DA_Bank(_database).deleteBankMaster(_BeBankMaster));
 }
Esempio n. 10
0
 public List <BE_Company> GetClients()
 {
     _database = new MySQLDatabase(connectionString);
     return(new DA_Company(_database).GetCompanyByTypeId(1));
 }
Esempio n. 11
0
 public List <BE_Company> GetCompanyGeneral(BECompanyFilter _bECompanyFilter)
 {
     _database = new MySQLDatabase(connectionString);
     return(new DA_Company(_database).GetCompanyGeneral(_bECompanyFilter));
 }
        private void TeachingFrm_Load(object sender, EventArgs e)
        {
            this.KeyPreview = true;

            _db = ((MainFrm)this.MdiParent)._db;

            // Setup datagrid columns
            dgv.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
            dgv.AllowUserToAddRows = false;
            dgv.AllowUserToDeleteRows = false;
            dgv.MultiSelect = false;
            dgv.ReadOnly = true;
            dgv.ColumnCount = 9;
            dgv.Columns[0].HeaderText = "รหัสวิชา";
            dgv.Columns[0].Width = 70;
            dgv.Columns[1].HeaderText = "ชื่อวิชา";
            dgv.Columns[1].Width = 250;
            dgv.Columns[2].HeaderText = "ทฤษฏี";
            dgv.Columns[2].Width = 50;
            dgv.Columns[3].HeaderText = "ปฏิบัติ";
            dgv.Columns[3].Width = 50;
            dgv.Columns[4].HeaderText = "ชื่ออาจารย์";
            dgv.Columns[4].Width = 170;
            dgv.Columns[5].HeaderText = "ปีการศึกษา";
            dgv.Columns[5].Width = 90;
            dgv.Columns[6].HeaderText = "รหัสอาจารย์";
            dgv.Columns[6].Visible = false;
            dgv.Columns[7].HeaderText = "ภาค";
            dgv.Columns[8].HeaderText = "ไอดีการสอน";
            dgv.Columns[8].Visible = false;

            LoadTeachingToDGV(_sqlShowAll);
        }
Esempio n. 13
0
 //private void listBox_DoubleClick(object sender, EventArgs e)
 //{
 //    if (!string.IsNullOrEmpty(listBox.SelectedItem as string))
 //    {
 //        DialogResult = DialogResult.OK;
 //        this.Close();
 //    }
 //}
 private void btnOK_Click(object sender, EventArgs e)
 {
     if (!(txtFileName.Text.Equals(String.Empty)))
     {
         MySQLDatabase mySQLDatabase = new MySQLDatabase();
         mySQLDatabase.SetDataSourceFilePath(this.txtFileName.Text);
         this.DialogResult = DialogResult.OK;
         this.Close();
     }
     else
     {
         MessageBox.Show("Please choose a server.");
     }
 }
Esempio n. 14
0
 public BE_BankAccount GetBankAccountById(int bankAccountId)
 {
     _database = new MySQLDatabase(connectionString);
     return(new DA_Bank(_database).getBankAccountById(bankAccountId));
 }
        private void LoadRegisterToDGV(string sqlCmd)
        {
            AddColumnForStudentDGV();
            // Clear DGV
            dgvStudent.Rows.Clear();
            // Query all teacher.
            _db.SQLCommand = sqlCmd;
            _db.Query();

            if (_db.Result.HasRows == false)
            {
                //MessageBox.Show("ไม่มีรายการที่ต้องการแสดง", "", MessageBoxButtons.OK, MessageBoxIcon.Information);
                //return;
            }

            // Insert rows to DGV
            int order = 0;
            while (_db.Result.Read())
            {
                order++;
                if ((string)_db.Result.GetValue(2) != "")
                {
                    dgvStudent.Rows.Add(
                        order.ToString(),
                        _db.Result["std_id"],
                        _db.Result["std_name"],
                        "scaned",
                        _db.Result["reg_id"],
                        LoadImage("finger2.png")
                        );
                }
                else
                {
                    dgvStudent.Rows.Add(
                        order.ToString(),
                        _db.Result["std_id"],
                        _db.Result["std_name"],
                        "noscan",
                        _db.Result["reg_id"],
                        LoadImage("nofinger2.png")
                        );
                }
            }

            int tech_id = (int)dgvSubject.CurrentRow.Cells["TechID"].Value;

            // Load others groups
            _db.SQLCommand = "SELECT * FROM checkin_date WHERE tech_id='" + tech_id + "' ORDER BY date";
            _db.Query();
            if (_db.Result.HasRows == true)
            {
                while (_db.Result.Read() == true)
                {
                    // Image column
                    DataGridViewImageColumn imgCol = new DataGridViewImageColumn();
                    imgCol.HeaderText = _db.Result["date"] as string;
                    imgCol.Width = 70;
                    int idx = dgvStudent.Columns.Add(imgCol);

                    // Status column
                    DataGridViewTextBoxColumn statusCol = new DataGridViewTextBoxColumn();
                    statusCol.HeaderText = _db.Result["date"] as string;
                    statusCol.Width = 70;
                    statusCol.Visible = false; // Status column
                    int idxStatus = dgvStudent.Columns.Add(statusCol);

                    MySQLDatabase localDB = new MySQLDatabase();
                    localDB.DBUser = _db.DBUser;
                    localDB.DBPassword = _db.DBPassword;
                    localDB.DBServer = _db.DBServer;
                    localDB.DBName = _db.DBName;
                    localDB.Connect();

                    foreach (DataGridViewRow item in dgvStudent.Rows)
                    {
                        string regID = Convert.ToString(item.Cells[4].Value); // TechID
                        string hisDate = imgCol.HeaderText;

                        // Must use a new db connection.
                        localDB.SQLCommand = "SELECT * FROM checkin WHERE date='" + hisDate + "' AND reg_id='" + regID + "'";
                        localDB.Query();

                        if (localDB.Result.HasRows == true)
                        {
                            localDB.Result.Read();
                            if (localDB.Result["status"] as string == "normal")
                            {
                                item.Cells[idx].Value = LoadImage("normal.png");
                                item.Cells[idxStatus].Value = "normal";
                            }
                            else if (localDB.Result["status"] as string == "absence")
                            {
                                item.Cells[idx].Value = LoadImage("absence.png");
                                item.Cells[idxStatus].Value = "absence";
                            }
                            else
                            {
                                item.Cells[idx].Value = LoadImage("late.png");
                                item.Cells[idxStatus].Value = "late";
                            }
                        }
                        else
                        {
                            item.Cells[idx].Value = LoadImage("uncheck.png");
                            item.Cells[idxStatus].Value = "uncheck";
                        }
                    }
                    localDB.Close();
                }
            }
        }
Esempio n. 16
0
 public DA_CostCenter(MySQLDatabase database)
 {
     _database = database;
 }
Esempio n. 17
0
 public DA_FeedingTime(MySQLDatabase database)
 {
     _database = database;
 }
        private bool Check80OfCheckin(string tech_id, string reg_id)
        {
            // Get Checkin Count.
            MySQLDatabase db = new MySQLDatabase();
            db.DBServer = _db.DBServer;
            db.DBUser = _db.DBUser;
            db.DBPassword = _db.DBPassword;
            db.DBName = _db.DBName;
            db.Connect();

            // Calculate checkin's score, the fomular is (15/10) = (20/x)
            double checkinScore = 0;   // This will calculate later.

            // Get a number of checkin's dates
            int countChkDate = 0;
            db.SQLCommand = "SELECT COUNT(date) FROM checkin_date WHERE tech_id='" + tech_id + "'";
            db.Query();
            if (db.Result.Read())
            {
                countChkDate = Convert.ToInt16(db.Result.GetValue(0));
            }
            else
            {
                countChkDate = 0;
            }

            // Get a number of checkins.
            int countChk = 0;
            db.SQLCommand = "SELECT COUNT(reg_id) FROM checkin WHERE reg_id='" + reg_id + "'";
            db.Query();
            if (db.Result.Read())
            {
                countChk = Convert.ToInt16(db.Result.GetValue(0));
            }
            else
            {
                countChk = 0;
            }

            db.Close();

            // Calculate
            int countNeedCheckin = (80 * countChkDate) / 100;
            if (countChk >= countNeedCheckin)
            {
                return false;
            }

            return true;
        }
Esempio n. 19
0
        public VE_Invoice CreateInvoiceGeneral(VE_Invoice _VeInvoice)
        {
            string invoiceId;

            _database = new MySQLDatabase(connectionString);

            var companysSystem = (new BL_Company()
            {
                connectionString = connectionString
            }).GetCompanyGeneral(new BECompanyFilter()
            {
                companyCode = _VeInvoice.companyCode
            });

            BE_Company _companySystem = null;

            if (companysSystem.Count > 0)
            {
                _companySystem = companysSystem[0];
            }
            else
            {
                throw new Exception("codigo Invalido");
            }

            if ((_VeInvoice.invoiceType.Equals(BE_Invoice.ORDER) || _VeInvoice.invoiceType.Equals(BE_Invoice.PURCHASEORDER)) && _companySystem.companyType.Equals("3")) // del sistema
            {
                var companysEmisor = (new BL_Company()
                {
                    connectionString = connectionString
                }).GetCompanyGeneral(new BECompanyFilter()
                {
                    companyRUC = _VeInvoice.customerRuc
                });
                BE_Company _companyEmisor = null;
                if (companysEmisor.Count > 0)
                {
                    _companyEmisor = companysEmisor[0];
                }
                else
                {
                    throw new Exception("codigo Invalido");
                }
                _VeInvoice.companyCode  = _companyEmisor.companyCode;
                _VeInvoice.customerRuc  = _companySystem.companyRUC;
                _VeInvoice.customerName = _companySystem.companyName;
            }


            invoiceId = new DA_Invoice(_database).createInvoice(_VeInvoice).invoiceId;

            foreach (VE_InvoiceDetail _veInvoiceDetail in _VeInvoice.invoiceDetail)
            {
                _veInvoiceDetail.invoiceId = int.Parse(invoiceId);
                new DA_Invoice(_database).createInvoiceDetail(_veInvoiceDetail);
            }



            return(_VeInvoice);
        }
 private void LoginFrm_Load(object sender, EventArgs e)
 {
     _db = ((MainFrm)this.MdiParent)._db;
     LoginOK = false;
 }
Esempio n. 21
0
        private void btnGenOPD_Click(object sender, EventArgs e)
        {
            try
            {
                txtVNOPD.Text = "";
                cmbVSDateOPD.Items.Clear();
                m_map.Clear();

                if (m_db != null && m_db.IsConnect())
                {
                    // Get HN from ipt table.
                    m_db.SQLCommand = "SELECT * FROM ovst WHERE hn='" + txtHNOPD.Text + "' ORDER BY vstdate DESC, vsttime DESC;";
                    if (m_db.Query() == false)
                    {
                        MessageBox.Show("There is no data for hn = " + txtHNOPD.Text + ". Please check.");
                        m_db.Result.Close();

                        // Clear
                        chkBlankOPD.Enabled = false;
                        dgViewOPD.Rows.Clear();
                        cmbVSDateOPD.Text = "";
                        pictureBoxOPD.Image = null;

                        return;
                    }

                    // Fill data in combo box
                    MySQLDatabase db = new MySQLDatabase();
                    db.DBServer = m_server;
                    db.DBUser = m_username;
                    db.DBPassword = m_password;
                    db.DBName = m_dbName;
                    db.Connect();
                    db.SQLCommand = "USE " + m_dbName + ";";
                    db.Query();
                    db.Result.Close();

                    string vstdate = null;
                    string vsttime = null;
                    string time = null;
                    string vn = null;
                    string hn = null;
                    string fname = null;
                    string lname = null;

                    while (m_db.Result.Read())
                    {
                        // Retrieve ovst's information
                        vn = (string)m_db.Result["vn"];
                        hn = (string)m_db.Result["hn"];
                        vstdate = ((DateTime)m_db.Result["vstdate"]).ToString("dd-MM-yyyy");
                        vsttime = (m_db.Result["vsttime"]).ToString();

                        // Retrieve patient's information
                        db.SQLCommand = "SELECT * FROM patient WHERE hn='" + hn + "';";
                        db.Query();
                        db.Result.Read();
                        fname = (string)db.Result["fname"];
                        lname = (string)db.Result["lname"];
                        db.Result.Close();

                        // Build timestamp
                        time = vstdate + "  " + vsttime;

                        // Add item to combo box
                        cmbVSDateOPD.Items.Add(time);

                        // Add to map
                        m_map.Add(time, new OVST { vn = vn, hn = hn, fname = fname, lname = lname });
                    }
                    cmbVSDateOPD.SelectedIndex = 0;
                    m_db.Result.Close();
                    db.Close();

                    // Disable checkbox if no item to be printed.
                    if (m_map.Count == 0)
                    {
                        chkBlankOPD.Enabled = false;
                    }
                    else
                    {
                        chkBlankOPD.Enabled = true;
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Esempio n. 22
0
        private void Form1_Load(object sender, EventArgs e)
        {
            this.FormClosed +=new FormClosedEventHandler(mainFrm_FormClosed);

            // Init controls
            txtHN.Enabled = false;
            txtFirstName.Enabled = false;
            txtLastName.Enabled = false;
            pictureBox.SizeMode = PictureBoxSizeMode.AutoSize;

            txtVNOPD.Enabled = false;

            // Init datagrid view.
            dgView.AllowUserToAddRows = false;
            dgView.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
            dgView.MultiSelect = false;
            dgView.ColumnCount = 1;
            dgView.Columns[0].HeaderText = "Barcode Label";
            dgView.Columns[0].Width = 250;

            dgViewOPD.AllowUserToAddRows = false;
            dgViewOPD.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
            dgViewOPD.MultiSelect = false;
            dgViewOPD.SelectionChanged += new EventHandler(dgViewOPD_SelectionChanged);
            dgViewOPD.CellContentClick += new DataGridViewCellEventHandler(dgViewOPD_CellContentClick);

            m_dgvColor = dgViewOPD.BackgroundColor;

            DataGridViewCheckBoxColumn chkCol = new DataGridViewCheckBoxColumn();
            chkCol.HeaderText = "";
            chkCol.Width = 30;
            dgViewOPD.Columns.Insert(0, chkCol);

            DataGridViewTextBoxColumn txtCol = new DataGridViewTextBoxColumn();
            txtCol.HeaderText = "Barcode Label";
            txtCol.Width = 250;
            dgViewOPD.Columns.Insert(1, txtCol);

            DataGridViewTextBoxColumn txtCol2 = new DataGridViewTextBoxColumn();
            txtCol2.HeaderText = "Hidden";
            txtCol2.Width = 50;
            txtCol2.Visible = false;
            dgViewOPD.Columns.Insert(2, txtCol2);

            // Init controls
            cmbVSDateOPD.SelectedIndexChanged += new EventHandler(cmbVSDateOPD_SelectedIndexChanged);
            chkBlankOPD.CheckedChanged += new EventHandler(chkBlankOPD_CheckedChanged);
            chkBlankOPD.Enabled = false;

            // Load config
            LoadFromXML();

            // Load previous data before closing form.
            if (File.Exists("savedata.txt") == true)
            {
                StreamReader sr = new StreamReader("savedata.txt");
                string line = sr.ReadLine();
                if (line != null)
                {
                    txtAN.Text = line.Substring(3);
                }
                line = sr.ReadLine();
                if (line != null)
                {
                    txtHNOPD.Text = line.Substring(3);
                }
                if (txtAN.Text != "")
                {
                    m_AN = Convert.ToInt32(txtAN.Text);
                }
                if (txtHNOPD.Text != "")
                {
                    m_HNOPD = Convert.ToInt32(txtHNOPD.Text);
                }
                sr.Close();
            }

            // Load history printing.
            ReloadHistory();

            if (tabControl.SelectedTab.Name == "tabPageIPD")
            {
                txtAN.Select();
            }
            else
            {
                txtHNOPD.Select();
            }

            try
            {
                // Init database
                m_db = new MySQLDatabase();
                m_db.DBServer = m_server;
                m_db.DBUser = m_username;
                m_db.DBPassword = m_password;
                m_db.DBName = m_dbName;
                m_db.Connect();
                m_db.SQLCommand = "USE " + m_dbName + ";";
                m_db.Query();
                m_db.Result.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Esempio n. 23
0
 public VE_BankAccount updateBalanceBankAccountByInvoice(int invoiceId, Int64 bankAccount)
 {
     _database = new MySQLDatabase(connectionString);
     return(new DA_Bank(_database).updateBalanceBankAccountByInvoice(invoiceId, bankAccount));
 }
Esempio n. 24
0
 public List <BE_Parameter> GetParameter(int idParameter)
 {
     _database = new MySQLDatabase(connectionString);
     return(new DA_Parameter(_database).GetParameter(idParameter));
 }
Esempio n. 25
0
 public List <VE_Invoice> GetBankAdjusmentHistory(int bankAccountId)
 {
     _database = new MySQLDatabase(connectionString);
     return(new DA_Bank(_database).GetBankAdjusmentHistory(bankAccountId));
 }
Esempio n. 26
0
 public BE_Parameter UpdateParameter(BE_Parameter bE_Parameter)
 {
     _database = new MySQLDatabase(connectionString);
     return(new DA_Parameter(_database).UpdateParameter(bE_Parameter));
 }
Esempio n. 27
0
 public VE_BankAccount UpdateBankAccount(VE_BankAccount _VeBankAccount)
 {
     _database = new MySQLDatabase(connectionString);
     return(new DA_Bank(_database).updateBankAccount(_VeBankAccount));
 }
Esempio n. 28
0
 public List <BE_ParameterDetail> GetParameterDetailById(int idParameterDetail)
 {
     _database = new MySQLDatabase(connectionString);
     return(new DA_Parameter(_database).GetParameterDetail(0, idParameterDetail));
 }
 private bool IsForce80Checkin(string tech_id)
 {
     MySQLDatabase db = new MySQLDatabase();
     db.DBServer = _db.DBServer;
     db.DBUser = _db.DBUser;
     db.DBPassword = _db.DBPassword;
     db.DBName = _db.DBName;
     db.Connect();
     db.SQLCommand = "SELECT force_f_checkin FROM score_rating";
     db.Query();
     bool ret = false;
     if (db.Result.Read())
     {
         if ((int)db.Result["force_f_checkin"] == 1)
         {
             ret = true;
         }
     }
     db.Close();
     return ret;
 }
Esempio n. 30
0
 public BE_ParameterDetail UpdateParameterDetail(BE_ParameterDetail bE_ParameterDetail)
 {
     _database = new MySQLDatabase(connectionString);
     return(new DA_Parameter(_database).UpdateParameterDetail(bE_ParameterDetail));
 }
        private string GetGradeFromScore(double score)
        {
            MySQLDatabase db = new MySQLDatabase();
            db.DBServer = _db.DBServer;
            db.DBUser = _db.DBUser;
            db.DBPassword = _db.DBPassword;
            db.DBName = _db.DBName;
            db.Connect();

            string grade = "";
            _db.SQLCommand = "SELECT a, bp, b, cp, c, dp, d, f, score_type FROM score_rating WHERE tech_id='" + dgvSubject.CurrentRow.Cells["TechID"].Value + "'";
            _db.Query();
            if (_db.Result.Read())
            {
                if (score >= Convert.ToInt16(_db.Result["a"]))
                {
                    grade = "A";
                }
                else if (score >= Convert.ToInt16(_db.Result["bp"]))
                {
                    grade = "B+";
                }
                else if (score >= Convert.ToInt16(_db.Result["b"]))
                {
                    grade = "B";
                }
                else if (score >= Convert.ToInt16(_db.Result["cp"]))
                {
                    grade = "C+";
                }
                else if (score >= Convert.ToInt16(_db.Result["c"]))
                {
                    grade = "C";
                }
                else if (score >= Convert.ToInt16(_db.Result["dp"]))
                {
                    grade = "D+";
                }
                else if (score >= Convert.ToInt16(_db.Result["f"]))
                {
                    if (_db.Result["score_type"].ToString() == "grade")
                    {
                        if (score >= Convert.ToInt16(_db.Result["d"]))
                        {
                            grade = "D";
                        }
                        else
                        {
                            grade = "F";
                        }
                    }
                    else
                    {
                        grade = "D";
                    }
                }
                else
                {
                    grade = "F";
                }
            }
            else
            {
                grade = "F";
            }
            db.Close();
            return grade;
        }
Esempio n. 32
0
 public int DeleteParameterDetail(int idParameterDetail)
 {
     _database = new MySQLDatabase(connectionString);
     return(new DA_Parameter(_database).DeleteParameterDetail(idParameterDetail));
 }
Esempio n. 33
0
 public BE_Company DeleteCompany(BE_Company _BeCompany)
 {
     _database = new MySQLDatabase(connectionString);
     return(new DA_Company(_database).DeleteCompany(_BeCompany));
 }
 private void ImportDataFrm_Load(object sender, EventArgs e)
 {
     // Setup database
     _db = ((MainFrm)this.MdiParent)._db;
     // Setup DGV
     dgv.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
     dgv.AllowUserToAddRows = false;
     dgv.AllowUserToDeleteRows = false;
     dgv.MultiSelect = false;
     dgv.ReadOnly = true;
     dgv.ColumnCount = 4;
     dgv.Columns[0].HeaderText = "ลำดับ";
     dgv.Columns[0].Width = 30;
     dgv.Columns[1].HeaderText = "รหัสนิสิต";
     dgv.Columns[2].HeaderText = "ชื่อ-นามสกุล";
     dgv.Columns[2].Width = 460;
     dgv.Columns[3].HeaderText = "สาขา";
 }
Esempio n. 35
0
 public List <BE_Company> GetSystemClients(string companyCode)
 {
     _database = new MySQLDatabase(connectionString);
     return(new DA_Company(_database).GetCompanyByTypeId(3));
 }
Esempio n. 36
0
 private List <BE_FeedingTime> GetFeedingTimeGeneral(BE_FeedingTime bE_FeedingTime)
 {
     _database = new MySQLDatabase(connectionString);
     return(new DA_FeedingTime(_database).GetFeedingTimeGeneral(bE_FeedingTime));
 }
Esempio n. 37
0
 public List <BE_CompanyType> GetCompanyType()
 {
     _database = new MySQLDatabase(connectionString);
     return(new DA_Company(_database).GetCompanyType());
 }
        private void SubjectFrm_Load(object sender, EventArgs e)
        {
            this.KeyPreview = true;

            _db = ((MainFrm)this.MdiParent)._db;

            // Setup datagrid columns
            dgv.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
            dgv.AllowUserToAddRows = false;
            dgv.AllowUserToDeleteRows = false;
            dgv.MultiSelect = false;
            dgv.ReadOnly = true;
            dgv.ColumnCount = 4;
            dgv.Columns[0].HeaderText = "รหัสวิชา";
            dgv.Columns[1].HeaderText = "ชื่อวิชา";
            dgv.Columns[1].Width = 400;
            dgv.Columns[2].HeaderText = "ทฤษฏี";
            dgv.Columns[3].HeaderText = "ปฏิบัติ";

            LoadSubjectToDGV("SELECT * FROM subject");
        }
Esempio n. 39
0
 public VE_BankAccount UpdateBalanceBankAccount(int paymentAuthId)
 {
     _database = new MySQLDatabase(connectionString);
     return(new DA_Bank(_database).updateBalanceBankAccount(paymentAuthId));
 }
Esempio n. 40
0
        protected void LoadGvCtAss()
        {
            MySQLDatabase data = new MySQLDatabase();
            var countCtAss = data.QueryValue("countCtAssByTCID",
                new Dictionary<string, object>
                {
                    {"@tcid", ddlSelectCourse.SelectedValue }
                }, true);
            if (countCtAss.ToString() == "0")
            {
                divp.Visible = true;
                divgv.Visible = false;
            }
            else
            {
                divp.Visible = false;
                divgv.Visible = true;
               
                var markIdSId = data.Query("GetCtAssMSIdSidByTCId",
                    new Dictionary<string, object>
                    {
                        {"@tcid", ddlSelectCourse.SelectedValue }
                    }, true);
                if (markIdSId != null)
                {
                    var rep = (List<Dictionary<string, string>>)null;
                    foreach (var list in markIdSId)
                    {
                        foreach (var dic in list)
                        {
                            if (dic.Key == "id")
                            {
                                if (rep == null)
                                {
                                    rep = data.Query("GetSidSnameMarksByMarkIdSid",
                                    new Dictionary<string, object>
                                    {
                                    {"@mrid", Convert.ToInt32(dic.Value)}
                                    }, true);
                                }
                                else
                                {
                                    var rep2 = data.Query("GetSidSnameMarksByMarkIdSid",
                                    new Dictionary<string, object>
                                    {
                                    {"@mrid", Convert.ToInt32(dic.Value)}
                                    }, true);
                                    rep.AddRange(rep2);
                                }
                            }
                        }
                    }
                    var rep3 = rep.Select(a => new
                    {
                        ID = a["id"],
                        Studentid = a["studentId"],
                        Name = a["FirstName"] + " " + a["LastName"],
                        ClassTestName = a["name"] + "(" + a["sectionPercentage"] + ")",
                        marks = a["mark"]
                    }).ToList();

                    DataTable sourceTable = new DataTable();
                    sourceTable = ToDataTable(rep3);


                    List<string> CTs = sourceTable.AsEnumerable().Select(x => x.Field<string>("ClassTestName")).Distinct().ToList();
                    DataTable pivotTable = new DataTable();
                    pivotTable.Columns.Add("StudentID", typeof(string));
                    pivotTable.Columns.Add("Name", typeof(string));
                    foreach (string ct in CTs)
                    {
                        pivotTable.Columns.Add(ct, typeof(string));
                    }

                    var students = sourceTable.AsEnumerable()
                        .GroupBy(x => new
                        {
                            Studentid = x.Field<string>("Studentid"),
                            Name = x.Field<string>("Name")
                        }).ToList();

                    foreach (var student in students)
                    {
                        DataRow newRow = pivotTable.Rows.Add();
                        newRow["Studentid"] = student.Key.Studentid;
                        newRow["Name"] = student.Key.Name;
                        foreach (DataRow row in student)
                        {
                            if (row.Field<string>("marks") == null)
                                newRow[row.Field<string>("ClassTestName")] = "0";
                            else
                            {
                                var a = row.Field<string>("marks"); 
                                newRow[row.Field<string>("ClassTestName")] = a;
                            }
                        }

                    }

                    gvCtAss.DataSource = pivotTable;
                    gvCtAss.DataBind();
                }
            }
        }
Esempio n. 41
0
 public VE_BankAccount updateBalanceBankAccountByPayment(int paymentId, Int64 bankAccount)
 {
     _database = new MySQLDatabase(connectionString);
     return(new DA_Bank(_database).updateBalanceBankAccountByPayment(paymentId, bankAccount));
 }
 private void AssignTeacherToSubjectFrm_Load(object sender, EventArgs e)
 {
     _db = ((MainFrm)Parent)._db;
     InitDGV();
     LoadSubjectToDGV("SELECT s.id, s.sub_id, s.sub_title, s.sub_lec, s.sub_lab, t.year, t.term FROM subject s JOIN teaching t ON s.id = t.sub_id");
 }
Esempio n. 43
0
 public List <VE_Bank> GetCompanyBankBalance(string companyCode)
 {
     _database = new MySQLDatabase(connectionString);
     return(new DA_Bank(_database).getCompanyBankBalance(companyCode));
 }
        protected void LoadGvAttendance()
        {
            MySQLDatabase data = new MySQLDatabase();
            // checking this TCID has any default settings
            var isdefault = data.QueryValue("CountAttendanceSectionIdByTcidAsDefault",
                                            new Dictionary <string, object>
            {
                { "@tcid", ddlSelectCourse.SelectedValue }
            }, true);
            var atTable = data.Query("GetAttendanceSecListByTCID",
                                     new Dictionary <string, object>
            {
                { "@tcid", ddlSelectCourse.SelectedValue }
            }, true);

            if (atTable.Count != 0)
            {
                LoadDefaultGridview();
            }
            else if (isdefault.ToString() == "0")
            {
                var teacherid = data.QueryValue("GetTeacherIdByUserId",
                                                new Dictionary <string, object>
                {
                    { "@uid", User.Identity.GetUserId() }
                }, true);
                if (teacherid == null)
                {
                    DataTable table = CreatDefault();
                    foreach (DataRow row in table.Rows)
                    {
                        data.Execute("AddAttendanceSection",
                                     new Dictionary <string, object>
                        {
                            { "@start", row.Field <int>(0) },
                            { "@end", row.Field <int>(1) },
                            { "@mark", row.Field <int>(2) },
                            { "@tcid", ddlSelectCourse.SelectedValue },
                            { "@default", 0 }
                        }, true);
                    }
                    LoadDefaultGridview();
                }
                else
                {
                    var teacherCourses = data.Query("GetTCIDByTID",
                                                    new Dictionary <string, object>
                    {
                        { "@tid", Convert.ToInt32(teacherid.ToString()) }
                    }, true);
                    bool a = false;
                    foreach (var list in teacherCourses)
                    {
                        foreach (var dic in list)
                        {
                            var istcid = data.QueryValue("CountAttendanceSectionIdByTcid",
                                                         new Dictionary <string, object>
                            {
                                { "@tcid", Convert.ToInt32(dic.Value) }
                            }, true);
                            if (istcid.ToString() != "0")
                            {
                                var atTables = data.Query("GetAttendanceSecListByTCID",
                                                          new Dictionary <string, object>
                                {
                                    { "@tcid", Convert.ToInt32(dic.Value) }
                                }, true);
                                foreach (var c in atTables)
                                {
                                    int s = 0;
                                    int e = 0;
                                    int m = 0;
                                    foreach (var b in c)
                                    {
                                        if (b.Key == "start")
                                        {
                                            s = Convert.ToInt32(b.Value);
                                        }
                                        if (b.Key == "end")
                                        {
                                            e = Convert.ToInt32(b.Value);
                                        }
                                        if (b.Key == "mark")
                                        {
                                            m = Convert.ToInt32(b.Value);
                                        }
                                    }
                                    data.Execute("AddAttendanceSection",
                                                 new Dictionary <string, object>
                                    {
                                        { "@start", s },
                                        { "@end", e },
                                        { "@mark", m },
                                        { "@tcid", ddlSelectCourse.SelectedValue },
                                        { "@default", 0 }
                                    }, true);
                                }
                                a = true;
                                break;
                            }
                        }
                        if (a == true)
                        {
                            break;
                        }
                    }
                    if (a == false)
                    {
                        LoadDefaultGridview();
                    }
                }
            }
        }
Esempio n. 45
0
 public List <VE_Bank> GetBankAccountByPaymentAuthId(int bankAccountId)
 {
     _database = new MySQLDatabase(connectionString);
     return(new DA_Bank(_database).getBankAccountByAuthId(bankAccountId));
 }
        private void ScanFingerStdFrm_Load(object sender, EventArgs e)
        {
            // Init Database
            _db = ((TeachingViewFrm)Parent)._db;

            // Init FP engine
            _fpEngine = new AxZKFPEngX();
            _fpEngine.BeginInit();
            _fpEngine.OnEnroll += new IZKFPEngXEvents_OnEnrollEventHandler(_fpEngine_OnEnroll);
            _fpEngine.OnImageReceived += new IZKFPEngXEvents_OnImageReceivedEventHandler(_fpEngine_OnImageReceived);
            this.Controls.Add(_fpEngine);

            if (_fpEngine.InitEngine() != 0)
            {
                MessageBox.Show("ไม่สามารถติดต่อเครื่องสแกนลายนิ้วมือได้", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                if (AutoScanMode == false)
                {
                    this.Close();
                }
                else
                {
                    _fpEngine.EndInit();
                    _fpEngine.EndEngine();
                    StopAutoScan = true;
                    btnCancel.Enabled = false;
                }
            }

            _fpEngine.BeginEnroll();
            txtFPStatus.Text = "วางนิ้ว 3 ครั้ง";
            txtFPNo.Text = _cntFPEnroll.ToString();

            _timer.Enabled = false;
            _timer.Interval = 3000;
            _timer.Tick += new EventHandler(_timer_Tick);

            txtStdID.Text = StdID;
            txtStdName.Text = StdName;

            if (AutoScanMode == false)
            {
                btnStop.Visible = false;
                btnCancel.Visible = false;
            }
        }
Esempio n. 47
0
 public VE_Bank UpdateBank(VE_Bank _VeBank)
 {
     _database = new MySQLDatabase(connectionString);
     return(new DA_Bank(_database).updateBank(_VeBank));
 }
Esempio n. 48
0
        protected void gvAttendence_dataBound()
        {
            MySQLDatabase data      = new MySQLDatabase();
            var           markIdSId = data.Query("GetAttendanceMSIdSidByTCId",
                                                 new Dictionary <string, object>
            {
                { "@tcid", ddlSelectCourse.SelectedValue }
            }, true);

            if (markIdSId != null)
            {
                var rep = (List <Dictionary <string, string> >)null;
                foreach (var list in markIdSId)
                {
                    foreach (var dic in list)
                    {
                        if (dic.Key == "id")
                        {
                            if (rep == null)
                            {
                                rep = data.Query("GetSidSnameDatePresentByMarkIdSid",
                                                 new Dictionary <string, object>
                                {
                                    { "@mrid", Convert.ToInt32(dic.Value) }
                                }, true);
                            }
                            else
                            {
                                var rep2 = data.Query("GetSidSnameDatePresentByMarkIdSid",
                                                      new Dictionary <string, object>
                                {
                                    { "@mrid", Convert.ToInt32(dic.Value) }
                                }, true);
                                rep.AddRange(rep2);
                            }
                        }
                    }
                }
                var rep3 = rep.Select(a => new
                {
                    ID        = a["id"],
                    Studentid = a["studentId"],
                    Name      = a["FirstName"] + " " + a["LastName"],
                    Date      = Convert.ToDateTime(a["dateColumn"]).ToString("dd-MM"),
                    Present   = a["present"]
                }).ToList();

                DataTable sourceTable = new DataTable();
                sourceTable = ToDataTable(rep3);


                List <string> dates      = sourceTable.AsEnumerable().Select(x => x.Field <string>("Date")).Distinct().ToList();
                DataTable     pivotTable = new DataTable();
                pivotTable.Columns.Add("StudentID", typeof(string));
                pivotTable.Columns.Add("Name", typeof(string));
                foreach (string date in dates)
                {
                    pivotTable.Columns.Add(date, typeof(string));
                }

                var students = sourceTable.AsEnumerable()
                               .GroupBy(x => new
                {
                    Studentid = x.Field <string>("Studentid"),
                    Name      = x.Field <string>("Name")
                }).ToList();

                foreach (var student in students)
                {
                    DataRow newRow = pivotTable.Rows.Add();
                    newRow["Studentid"] = student.Key.Studentid;
                    newRow["Name"]      = student.Key.Name;
                    foreach (DataRow row in student)
                    {
                        if (row.Field <string>("Present") == "True")
                        {
                            newRow[row.Field <string>("Date")] = "P";
                        }
                        else
                        {
                            newRow[row.Field <string>("Date")] = "A";
                        }
                    }
                }

                gvAttendence.DataSource = pivotTable;
                gvAttendence.DataBind();
            }
        }
        private void RegistationFrm_Load(object sender, EventArgs e)
        {
            this.KeyPreview = true;

            _db = ((MainFrm)this.MdiParent)._db;

            // Setup datagrid columns
            dgv.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
            dgv.AllowUserToAddRows = false;
            dgv.AllowUserToDeleteRows = false;
            dgv.MultiSelect = false;
            dgv.ReadOnly = true;
            dgv.ColumnCount = 8;
            dgv.Columns[0].HeaderText = "รหัส";
            dgv.Columns[0].Visible = false;
            dgv.Columns[1].HeaderText = "รหัสวิชา";
            dgv.Columns[1].Width = 70;
            dgv.Columns[2].HeaderText = "ชื่อวิชา";
            dgv.Columns[2].Width = 180;
            dgv.Columns[3].HeaderText = "ทฤษฏี";
            dgv.Columns[3].Width = 50;
            dgv.Columns[4].HeaderText = "ปฏิบัติ";
            dgv.Columns[4].Width = 50;
            dgv.Columns[5].HeaderText = "รหัสนิสิต";
            dgv.Columns[5].Width = 90;
            dgv.Columns[6].HeaderText = "ชื่อนิสิต";
            dgv.Columns[6].Width = 200;
            dgv.Columns[7].HeaderText = "ปีการศึกษา";
            dgv.Columns[7].Width = 90;

            LoadRegisterToDGV(_sqlShowAll);
        }
        private void TeachingViewFrm_Load(object sender, EventArgs e)
        {
            this.KeyPreview = true;

            _db = ((MainFrm)this.MdiParent)._db;

            // Setup datagrid columns
            AddColumnForStudentDGV();

            // Setup datagrid columns
            dgvSubject.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
            dgvSubject.AllowUserToAddRows = false;
            dgvSubject.AllowUserToDeleteRows = false;
            dgvSubject.MultiSelect = false;
            dgvSubject.ReadOnly = true;
            dgvSubject.ColumnCount = 8;
            dgvSubject.Columns[0].HeaderText = "ไอดีวิชา";
            dgvSubject.Columns[0].Name = "ID";
            dgvSubject.Columns[0].Visible = false;
            dgvSubject.Columns[1].HeaderText = "รหัสวิชา";
            dgvSubject.Columns[1].Width = 100;
            dgvSubject.Columns[1].Name = "SubID";
            dgvSubject.Columns[2].HeaderText = "ชื่อวิชา";
            dgvSubject.Columns[2].Width = 250;
            dgvSubject.Columns[2].Name = "SubTitle";
            dgvSubject.Columns[3].HeaderText = "หมู่บรรยาย";
            dgvSubject.Columns[3].Width = 85;
            dgvSubject.Columns[3].Name = "SubLec";
            dgvSubject.Columns[4].HeaderText = "หมู่ปฏิบัติ";
            dgvSubject.Columns[4].Width =85;
            dgvSubject.Columns[4].Name = "SubLab";
            dgvSubject.Columns[5].HeaderText = "ปีการศึกษา";
            dgvSubject.Columns[5].Width = 90;
            dgvSubject.Columns[5].Name = "SubYear";
            dgvSubject.Columns[6].HeaderText = "ภาคศึกษา";
            dgvSubject.Columns[6].Width = 100;
            dgvSubject.Columns[6].Name = "SubTerm";
            dgvSubject.Columns[7].HeaderText = "ไอดีสอน";
            dgvSubject.Columns[7].Width = 100;
            dgvSubject.Columns[7].Name = "TechID";
            dgvSubject.Columns[7].Visible = false;

            string sql = _sqlShowAllSubject + " WHERE t.tech_id='" + TechID + "'";
            LoadSubjectToDGV(sql);

            // Setup score datagrid
            dgvScore.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
            dgvScore.AllowUserToAddRows = false;
            dgvScore.AllowUserToDeleteRows = false;
            dgvScore.MultiSelect = true;
            //dgvScore.ReadOnly = true;
            dgvScore.EditMode = DataGridViewEditMode.EditOnEnter;
            dgvScore.ColumnCount = 15;
            dgvScore.Columns[0].HeaderText = "ลำดับ";
            dgvScore.Columns[0].Width = 35;
            dgvScore.Columns[0].ReadOnly = true;
            dgvScore.Columns[1].HeaderText = "รหัสนิสิต";
            dgvScore.Columns[1].Name = "StdID";
            dgvScore.Columns[1].Width = 90;
            dgvScore.Columns[1].ReadOnly = true;
            dgvScore.Columns[1].Frozen = true;
            dgvScore.Columns[2].HeaderText = "ชื่อนิสิต";
            dgvScore.Columns[2].Width = 150;
            dgvScore.Columns[2].ReadOnly = true;
            dgvScore.Columns[2].Frozen = true;
            dgvScore.Columns[3].HeaderText = "เกรด";
            dgvScore.Columns[3].Width = 50;
            dgvScore.Columns[3].ReadOnly = true;
            dgvScore.Columns[3].Frozen = true;
            dgvScore.Columns[4].HeaderText = "รวม";
            dgvScore.Columns[4].Width = 50;
            dgvScore.Columns[4].ReadOnly = true;
            dgvScore.Columns[4].Frozen = true;
            dgvScore.Columns[5].HeaderText = "กลางภาค";
            dgvScore.Columns[5].Width = 50;
            dgvScore.Columns[6].HeaderText = "ปลายภาค";
            dgvScore.Columns[6].Width = 50;
            dgvScore.Columns[7].HeaderText = "เข้าเรียน";
            dgvScore.Columns[7].Width = 50;
            dgvScore.Columns[7].ReadOnly = true;
            dgvScore.Columns[8].HeaderText = "เก็บ 1";
            dgvScore.Columns[8].Width = 50;
            dgvScore.Columns[9].HeaderText = "เก็บ 2";
            dgvScore.Columns[9].Width = 50;
            dgvScore.Columns[10].HeaderText = "เก็บ 3";
            dgvScore.Columns[10].Width = 50;
            dgvScore.Columns[11].HeaderText = "เก็บ 4";
            dgvScore.Columns[11].Width = 50;
            dgvScore.Columns[12].HeaderText = "เก็บ 5";
            dgvScore.Columns[12].Width = 50;
            dgvScore.Columns[13].HeaderText = "รหัสลงทะเบียน";
            dgvScore.Columns[13].Width = 50;
            dgvScore.Columns[13].Name = "RegID";
            dgvScore.Columns[13].Visible = false;
            dgvScore.Columns[14].HeaderText = "ปฏิบัติ";
            dgvScore.Columns[14].Width = 50;
            dgvScore.Columns[14].Name = "ScoreLab";

            UpdateScoreTitle();

            _allowUdateRow = true;
            dgvSubject_SelectionChanged(null, null);
            BuildContextualMenu();
        }
        private void ScoreRateFrm_Load(object sender, EventArgs e)
        {
            // Init database
            _db = ((MainFrm)Parent)._db;

            // Load current score setting
            _db.SQLCommand = "SELECT * FROM score_rating WHERE tech_id='" + TeachingID + "'";
            _db.Query();
            // If the subject has been already set score rating
            if (_db.Result.Read() == true)
            {
                txtA.Text = _db.Result["a"].ToString();
                txtBP.Text = _db.Result["bp"].ToString();
                txtB.Text = _db.Result["b"].ToString();
                txtCP.Text = _db.Result["cp"].ToString();
                txtC.Text = _db.Result["c"].ToString();
                txtDP.Text = _db.Result["dp"].ToString();
                txtD.Text = _db.Result["d"].ToString();
                txtF.Text = _db.Result["f"].ToString();
                txtMid.Text = _db.Result["mid"].ToString();
                txtFinal.Text = _db.Result["final"].ToString();
                txtCheckin.Text = _db.Result["checkin"].ToString();
                txtScore1.Text = _db.Result["score1"].ToString();
                txtScore2.Text = _db.Result["score2"].ToString();
                txtScore3.Text = _db.Result["score3"].ToString();
                txtScore4.Text = _db.Result["score4"].ToString();
                txtScore5.Text = _db.Result["score5"].ToString();
                txtScore1Title.Text = _db.Result["score1_title"].ToString();
                txtScore2Title.Text = _db.Result["score2_title"].ToString();
                txtScore3Title.Text = _db.Result["score3_title"].ToString();
                txtScore4Title.Text = _db.Result["score4_title"].ToString();
                txtScore5Title.Text = _db.Result["score5_title"].ToString();
                txtScoreLab.Text = _db.Result["score_lab"].ToString();

                if ((int)_db.Result["force_f_checkin"] == 0)
                {
                    chkForce.Checked = false;
                }
                else
                {
                    chkForce.Checked = true;
                }

                if (LabMode == true)
                {
                    txtScoreLab.Text = _db.Result["score_lab"].ToString();
                }

                if (_db.Result["score_type"].ToString() == "grade")
                {
                    cmbType.SelectedIndex = 1;
                }
                else
                {
                    cmbType.SelectedIndex = 0;
                }

                _reallyCalcuate = false;
                btnCalc_Click(null, null);
            }
            else
            {
                cmbType.SelectedIndex = 1;
            }

            if (LabMode == true)
            {
                txtScoreLab.Visible = false;
                labScoreLab.Visible = false;
                labStar.Visible = false;
            }

            _ready = true;  // To prevent crash we this flag.
        }
 public MySQLConnectionAdapter(MySQLDatabase sql)
 {
     connection = MySQLConnector.GetConnection(sql);
 }
        private double GetLabScore(string stdID)
        {
            double labScore = 0.0;

            MySQLDatabase localDB = new MySQLDatabase();
            localDB.DBServer = _db.DBServer;
            localDB.DBName = _db.DBName;
            localDB.DBUser = _db.DBUser;
            localDB.DBPassword = _db.DBPassword;
            localDB.Connect();

            // Get Lab Subject of Lec Subject
            localDB.SQLCommand = "SELECT * FROM subject WHERE sub_lec='" + dgvSubject.CurrentRow.Cells["SubLec"].Value as string + "' AND sub_lab<>''";
            localDB.Query();

            while (localDB.Result.Read())
            {
                // STD + Lab + Year Sub ID, look up in registration
                MySQLDatabase regDB = new MySQLDatabase();
                regDB.DBServer = _db.DBServer;
                regDB.DBName = _db.DBName;
                regDB.DBUser = _db.DBUser;
                regDB.DBPassword = _db.DBPassword;
                regDB.Connect();
                regDB.SQLCommand = "SELECT * FROM registration WHERE sub_id='" + (int)localDB.Result["id"] + "' AND std_id='" + stdID + "' AND year='" + dgvSubject.CurrentRow.Cells["SubYear"].Value + "'";
                regDB.Query();
                while (regDB.Result.Read())
                {
                    // REGID look up in score
                    int regid = (int)regDB.Result["reg_id"];
                    MySQLDatabase scoreDB = new MySQLDatabase();
                    scoreDB.DBServer = _db.DBServer;
                    scoreDB.DBName = _db.DBName;
                    scoreDB.DBUser = _db.DBUser;
                    scoreDB.DBPassword = _db.DBPassword;
                    scoreDB.Connect();
                    scoreDB.SQLCommand = "SELECT * FROM score WHERE reg_id='" + regid + "'";
                    scoreDB.Query();

                    // A = Sum all score
                    double all_score = 0;
                    if (scoreDB.Result.Read())
                    {
                        all_score = (int)scoreDB.Result["mid"] + (int)scoreDB.Result["final"] + (int)scoreDB.Result["score1"] +
                                    (int)scoreDB.Result["score2"] + (int)scoreDB.Result["score3"] + (int)scoreDB.Result["score4"] +
                                    (int)scoreDB.Result["score5"];

                        // TechID + SubID + Year, look up in teaching
                        MySQLDatabase techingDB = new MySQLDatabase();
                        techingDB.DBServer = _db.DBServer;
                        techingDB.DBName = _db.DBName;
                        techingDB.DBUser = _db.DBUser;
                        techingDB.DBPassword = _db.DBPassword;
                        techingDB.Connect();

                        techingDB.SQLCommand = "SELECT * FROM teaching WHERE tech_id='" + TechID + "' AND sub_id='" + localDB.Result["id"].ToString() + "' AND year='" + dgvSubject.CurrentRow.Cells["SubYear"].Value + "'";
                        techingDB.Query();
                        techingDB.Result.Read();

                        all_score += GetCheckinScore(techingDB.Result["id"].ToString(), regid.ToString());

                        techingDB.Close();
                    }

                    // B = Get Lab's score from score_rating
                    scoreDB.SQLCommand = "SELECT * FROM score_rating WHERE tech_id='" + dgvSubject.CurrentRow.Cells["TechID"].Value + "'";
                    scoreDB.Query();

                    double scoreLab = 0;
                    if (scoreDB.Result.Read())
                    {
                        scoreLab = (int)scoreDB.Result["score_lab"];
                    }

                    // Real score = (A * B)/100
                    labScore = (all_score * scoreLab) / 100;

                    scoreDB.Close();
                }
                regDB.Close();
            }
            localDB.Close();
            return labScore;
        }
Esempio n. 54
0
        private void _buttonOpenDatabase_Click(object sender, RoutedEventArgs e)
        {
            OpenControls.Wpf.Serialisation.RegistryItemSerialiser        registryItemSerialiser = new OpenControls.Wpf.Serialisation.RegistryItemSerialiser(_keyPath);
            OpenControls.Wpf.DatabaseDialogs.Model.DatabaseConfiguration databaseConfiguration  = new OpenControls.Wpf.DatabaseDialogs.Model.DatabaseConfiguration(registryItemSerialiser);
            if (registryItemSerialiser.OpenKey())
            {
                databaseConfiguration.Load();
            }

            OpenControls.Wpf.DatabaseDialogs.ViewModel.OpenDatabaseViewModel openDatabaseViewModel = new OpenControls.Wpf.DatabaseDialogs.ViewModel.OpenDatabaseViewModel(databaseConfiguration);
            OpenControls.Wpf.DatabaseDialogs.View.OpenDatabaseView           openDatabaseView      =
                new OpenControls.Wpf.DatabaseDialogs.View.OpenDatabaseView(new OpenControls.Wpf.DatabaseDialogs.Model.Encryption());
            openDatabaseView.DataContext = openDatabaseViewModel;
            if (openDatabaseView.ShowDialog() != true)
            {
                return;
            }
            if (!registryItemSerialiser.IsOpen)
            {
                registryItemSerialiser.CreateKey();
            }
            databaseConfiguration.Save();
            registryItemSerialiser.Close();

            try
            {
                if (openDatabaseViewModel.SelectedDatabaseProvider == OpenControls.Wpf.DatabaseDialogs.Model.DatabaseProvider.SQLite)
                {
                    SQLiteDatabase.OpenDatabase(this, openDatabaseViewModel.SQLite_Filename);
                    IDatabaseHost.IConfigurationStore = new DBStore.SQLiteConfigurationStore(IDatabaseHost.Database);
                    IDatabaseHost.ISpeciesStore       = new DBStore.SQLiteSpeciesStore(IDatabaseHost.Database);
                    IDatabaseHost.IImagePathsStore    = new DBStore.SQLiteImagePathsStore(IDatabaseHost.Database);
                    IDatabaseHost.IImageStore         = new DBStore.SQLiteImageStore(IDatabaseHost.Database);
                }
                else if (openDatabaseViewModel.SelectedDatabaseProvider == OpenControls.Wpf.DatabaseDialogs.Model.DatabaseProvider.MicrosoftSQLServer)
                {
                    string server =
                        (openDatabaseViewModel.SqlServerInstances.Count > 0) ?
                        openDatabaseViewModel.SqlServerInstances[openDatabaseViewModel.SelectedSqlServerInstance] :
                        null;
                    SQLServerDatabase.OpenDatabase(
                        this,
                        openDatabaseViewModel.SQLServer_UseLocalServer,
                        server,
                        openDatabaseViewModel.SQLServer_IPAddress,
                        openDatabaseViewModel.SQLServer_Port,
                        openDatabaseViewModel.SQLServer_UseWindowsAuthentication,
                        openDatabaseViewModel.SQLServer_UserName,
                        openDatabaseViewModel.SQLServer_Password,
                        openDatabaseViewModel.SQLServer_DatabaseName);
                    IDatabaseHost.IConfigurationStore = new DBStore.SQLServerConfigurationStore(IDatabaseHost.Database);
                    IDatabaseHost.ISpeciesStore       = new DBStore.SQLServerSpeciesStore(IDatabaseHost.Database);
                    IDatabaseHost.IImagePathsStore    = new DBStore.SQLServerImagePathsStore(IDatabaseHost.Database);
                    IDatabaseHost.IImageStore         = new DBStore.SQLServerImageStore(IDatabaseHost.Database);
                }
                else if (openDatabaseViewModel.SelectedDatabaseProvider == OpenControls.Wpf.DatabaseDialogs.Model.DatabaseProvider.PostGreSQL)
                {
                    PostgreSQLDatabase.OpenDatabase(this, openDatabaseViewModel.PostgreSQL_IPAddress, openDatabaseViewModel.PostgreSQL_Port, openDatabaseViewModel.PostgreSQL_UseWindowsAuthentication, openDatabaseViewModel.PostgreSQL_UserName, openDatabaseViewModel.PostgreSQL_Password, openDatabaseViewModel.PostgreSQL_DatabaseName);
                    IDatabaseHost.IConfigurationStore = new DBStore.PostgreSQLConfigurationStore(IDatabaseHost.Database);
                    IDatabaseHost.ISpeciesStore       = new DBStore.PostgreSQLSpeciesStore(IDatabaseHost.Database);
                    IDatabaseHost.IImagePathsStore    = new DBStore.PostgreSQLImagePathsStore(IDatabaseHost.Database);
                    IDatabaseHost.IImageStore         = new DBStore.PostgreSQLImageStore(IDatabaseHost.Database);
                }
                else if (openDatabaseViewModel.SelectedDatabaseProvider == OpenControls.Wpf.DatabaseDialogs.Model.DatabaseProvider.MySQL)
                {
                    MySQLDatabase.OpenDatabase(this, openDatabaseViewModel.MySQL_IPAddress, openDatabaseViewModel.MySQL_Port, openDatabaseViewModel.MySQL_UseWindowsAuthentication, openDatabaseViewModel.MySQL_UserName, openDatabaseViewModel.MySQL_Password, openDatabaseViewModel.MySQL_DatabaseName);
                    IDatabaseHost.IConfigurationStore = new DBStore.MySQLConfigurationStore(IDatabaseHost.Database);
                    IDatabaseHost.ISpeciesStore       = new DBStore.MySQLSpeciesStore(IDatabaseHost.Database);
                    IDatabaseHost.IImagePathsStore    = new DBStore.MySQLImagePathsStore(IDatabaseHost.Database);
                    IDatabaseHost.IImageStore         = new DBStore.MySQLImageStore(IDatabaseHost.Database);
                }
                else
                {
                    throw new Exception("Unsupported database type");
                }
            }
            catch (Exception exception)
            {
                System.Windows.Forms.MessageBox.Show(exception.Message);
                return;
            }

            ShowSpeciesListView(IDatabaseHost.Database);
        }
Esempio n. 55
0
        protected void LoadAccountDetail()
        {
            var data   = new MySQLDatabase();
            var uid    = User.Identity.GetUserId();
            var detail = data.Query("GetMemberDetailByUid",
                                    new Dictionary <string, object>
            {
                { "@uid", uid }
            }, true);

            foreach (var a1 in detail)
            {
                foreach (var a2 in a1)
                {
                    if (a2.Key == "UserName")
                    {
                        txtUserName.Text = a2.Value;
                    }
                    else if (a2.Key == "firstname")
                    {
                        txtFirstName.Text = a2.Value;
                    }
                    else if (a2.Key == "lastname")
                    {
                        txtLastName.Text = a2.Value;
                    }
                    else if (a2.Key == "father_name")
                    {
                        txtFatherName.Text = a2.Value;
                    }
                    else if (a2.Key == "mother_name")
                    {
                        txtMotherName.Text = a2.Value;
                    }
                    else if (a2.Key == "Email")
                    {
                        txtEmail.Text = a2.Value;
                    }
                    else if (a2.Key == "PhoneNumber")
                    {
                        txtPhoneNumber.Text = a2.Value;
                    }
                    else if (a2.Key == "sex")
                    {
                        txtGender.Text = a2.Value;
                    }
                    else if (a2.Key == "current_address")
                    {
                        txtCurrentAddress.Text = a2.Value;
                    }
                    else if (a2.Key == "parmanent_address")
                    {
                        txtParmanetAddress.Text = a2.Value;
                    }
                    else if (a2.Key == "date_of_birth")
                    {
                        txtBirthDay.Text = Convert.ToDateTime(a2.Value).ToString("yyyy-MM-dd");
                    }
                    else if (a2.Key == "education")
                    {
                        txtEducation.Text = a2.Value;
                    }
                    else if (a2.Key == "blood_group")
                    {
                        txtBloodGroup.Text = a2.Value;
                    }
                    else if (a2.Key == "member_number")
                    {
                        txtMemberId.Text = a2.Value;
                    }
                    else if (a2.Key == "occupation")
                    {
                        txtOccupation.Text = a2.Value;
                    }
                    else if (a2.Key == "date_registered")
                    {
                        txtDateRegistered.Text = Convert.ToDateTime(a2.Value).ToString("yyyy-MM-dd");
                    }
                    else if (a2.Key == "type")
                    {
                        txtMembertype.Text = a2.Value;
                    }
                }
            }
        }
        private double GetCheckinScore(string tech_id, string reg_id)
        {
            MySQLDatabase db = new MySQLDatabase();
            db.DBServer = _db.DBServer;
            db.DBUser = _db.DBUser;
            db.DBPassword = _db.DBPassword;
            db.DBName = _db.DBName;
            db.Connect();

            // Calculate checkin's score, the fomular is (15/10) = (20/x)
            double checkinScore = 0;   // This will calculate later.

            // Get a number of checkin's dates
            int countChkDate = 0;
            db.SQLCommand = "SELECT COUNT(date) FROM checkin_date WHERE tech_id='" + tech_id + "'";
            db.Query();
            if (db.Result.Read())
            {
                countChkDate = Convert.ToInt16(db.Result.GetValue(0));
            }
            else
            {
                countChkDate = 0;
            }

            // Get setting checkin score
            double settingChkinScore = 0;
            db.SQLCommand = "SELECT checkin FROM score_rating WHERE tech_id='" + tech_id + "'";
            db.Query();
            if (db.Result.Read())
            {
                settingChkinScore = Convert.ToInt16(db.Result["checkin"]);
            }
            else
            {
                settingChkinScore = 0;
            }

            // Get a number of checkin
            double countChkNormal = 0;
            db.SQLCommand = "SELECT COUNT(reg_id) FROM checkin WHERE reg_id='" + reg_id + "' AND status IN ('normal', 'absence')";
            db.Query();
            if (db.Result.Read())
            {
                countChkNormal = Convert.ToInt16(db.Result.GetValue(0));
            }
            else
            {
                countChkNormal = 0;
            }

            double countChkLate = 0;
            db.SQLCommand = "SELECT COUNT(reg_id) FROM checkin WHERE reg_id='" + reg_id + "' AND status='late'";
            db.Query();
            if (db.Result.Read())
            {
                countChkLate = Convert.ToInt16(db.Result.GetValue(0)) * 0.5;
            }
            else
            {
                countChkNormal = 0;
            }

            db.Close();

            // Then calculate the score
            if (countChkDate != 0)
            {
                checkinScore = (settingChkinScore * (countChkNormal + countChkLate)) / countChkDate;
            }
            return checkinScore;
        }