Esempio n. 1
0
        private void txtSearch_TextChanged(object sender, EventArgs e)
        {
            string sn = " N'%" + txtSearch.Text + "%' ";

            sql = "Select StaffID,StaffName From tbStaff Where StaffName Like " + sn + "Order By StaffName";
            op.BindListBox(LstStaff, sql, "StaffName", "StaffID");
            if (LstStaff.Items.Count == 0)
            {
                op.ClearControls(txtID, txtName, cboGender, txtAddress, cboPosition, txtSalary, cboStopWork);
                txtPhone.Clear(); txtHiredDate.Value = DateTime.Today;
                fp          = Path.GetDirectoryName(Application.ExecutablePath);
                fp          = fp + "/Photo/Staff.jpg";
                binpic      = System.IO.File.ReadAllBytes(fp);
                ms          = new MemoryStream(binpic);
                Photo.Image = Image.FromStream(ms);
            }
            else
            {
                LstStaff.SetSelected(0, true);
                string id = LstStaff.SelectedValue.ToString();
                sql = "Select *From tbStaff Where StaffID=" + id;
                op.DisplayInformation(sql, txtID, txtName, cboGender, txtBirtDate, txtPhone,
                                      txtAddress, cboPosition, txtSalary, txtHiredDate, cboStopWork);
                double sal = Double.Parse(txtSalary.Text);
                txtSalary.Text = String.Format("{0:C}", sal);
                status         = "Old"; btnSave.Enabled = true;
                ShowPhoto(id);
            }
        }
Esempio n. 2
0
        private void FormStaff_Load(object sender, EventArgs e)
        {
            op.SetConnection("D8JZPCQ2", "dbStock");
            //string sql = "Insert into tbCustomer(CusName,CusPhone,CusAddress)" +
            //    "Values ('Kim Thida','(095)993-488','Phnom penh')";
            //op.RunSql(sql);
            string sql = "Select Distinct StaffPosition from tbStaff";

            op.PutDataIntoComboBox(sql, cboPosition);
            sql = "select StaffID,StaffName from tbStaff order by StaffName";
            op.BindListBox(LstStaff, sql, "StaffName", "StaffID");
            btnNew.Focus(); btnSave.Enabled = false; this.KeyPreview = true;
            if (LstStaff.Items.Count > 0)
            {
                LstStaff.SetSelected(0, true);
                string id = LstStaff.SelectedValue.ToString();
                sql = "select *from tbStaff where StaffID=" + id;
                op.DisplayInformation(sql, txtID, txtName, cboGender, txtBirtDate, txtPhone,
                                      txtAddress, cboPosition, txtSalary, txtHiredDate, cboStopWork);
                double sal = Double.Parse(txtSalary.Text);
                txtSalary.Text = String.Format("{0:C}", sal);
                status         = "Old"; btnSave.Enabled = true;
                ShowPhoto(id);
            }
        }
Esempio n. 3
0
        void DisplayStaff()
        {
            //create an instance of the staff collection
            clsStaffCollection Staff = new clsStaffCollection();

            //set the source to the list of staff in the collection
            LstStaff.DataSource = Staff.StaffList;
            //get the primary key
            LstStaff.DataValueField = "StaffNo";
            //set the data field to display
            LstStaff.DataTextField = "FirstName";
            //bind data to the list
            LstStaff.DataBind();
        }