Ejemplo n.º 1
0
        private void initMain()
        {
            t.Interval = 1000; //in milliseconds
            t.Tick    += new EventHandler(this.t_Tick);
            t.Start();         //this will use t_Tick() method

            thucHienCaID = "" + DateTime.Now.Day + "" + DateTime.Now.Month + "" + DateTime.Now.Year + ((DateTime.Now.Hour < 19) ? "S" : "C");

            DBKip ntb = new DBKip();

            ntb.updateComboBoxIdOnly(cbKip);

            DBKetNoi.initializeInstance();
            DBKetNoi      dbmg = DBKetNoi.getInstance();
            SqlConnection con  = dbmg.openDatabase();

            string         sql         = "SELECT * FROM NhanVien ORDER BY MAKIP ";
            SqlDataAdapter dataadapter = new SqlDataAdapter(sql, con);
            DataSet        ds          = new DataSet();

            dataadapter.Fill(ds, "NhanVien");
            dGCaKip.DataSource = ds;
            dGCaKip.DataMember = "NhanVien";

            dbmg.closeDatabase();
        }
Ejemplo n.º 2
0
        private void updateKip(bool isNewKip)
        {
            if (txtMaKip.Text.Equals("") || txtTenKip.Text.Equals(""))
            {
                MessageBox.Show(this, "Mã, tên kíp ko hợp lệ", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            Kip kip = new Kip();

            kip.maKip  = txtMaKip.Text;
            kip.tenKip = txtTenKip.Text;

            DBKip dbKip = new DBKip();

            string ret = dbKip.addNewKip(kip, isNewKip);

            if (ret.Contains("duplicate key"))
            {
                MessageBox.Show(this, "TRUNG ID", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else if (ret.Length > 0)
            {
                MessageBox.Show(this, ret, "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            dbKip.updateGridData(dGKip);
            resetFeilds();
        }
Ejemplo n.º 3
0
        private void btnXoaKip_Click(object sender, EventArgs e)
        {
            DBKip dbKip = new DBKip();

            dbKip.removeKIP(txtMaKip.Text);
            resetFeilds();
        }
Ejemplo n.º 4
0
        void resetFeilds()
        {
            DBKip ntb = new DBKip();

            ntb.updateComboBoxIdOnly(cbKipNV);
            ntb.updateGridData(dGKip);

            DBKip dbKip = new DBKip();

            dbKip.updateGridData(dGKip);
            DBNhanVien dbnv = new DBNhanVien();

            dbnv.updateGridData(dGNhanVien);
        }