Esempio n. 1
0
        public int removeQuyTrinh(string idQt)
        {
            DataBaseManager.initializeInstance();
            DataBaseManager dbmg = DataBaseManager.getInstance();
            SqlConnection   con  = dbmg.openDatabase();
            SqlCommand      cmd  = new SqlCommand();

            cmd.Connection  = con;
            cmd.CommandType = CommandType.Text;
            cmd.CommandText = "DELETE FROM QUYTRINHBAOTRI WHERE Id = @maQTBT";
            cmd.Parameters.AddWithValue("@maQTBT", idQt);

            int ret = -1;

            try
            {
                ret = cmd.ExecuteNonQuery();
            }
            catch (Exception e)
            {
                Debug.WriteLine("The product name is " + e.Message);
            }
            dbmg.closeDatabase();
            return((ret > 0) ? ret : -1);
        }
Esempio n. 2
0
        public int addNewDevice(ThietBi thietBi, bool isUpdate)
        {
            DataBaseManager.initializeInstance();
            DataBaseManager dbmg = DataBaseManager.getInstance();
            SqlConnection   con  = dbmg.openDatabase();

            string insertNewCmd = "INSERT THIETBI (Id, Ten, NgayBatDau, NgayKetThuc, ViTri, BaoHanh, LOG, TinhTrang, MaNhom, TangSuat, Model, Seri, Hang, NgayThucHienCuoi) "
                                  + " VALUES (@Id,@Ten,@NgayBatDau,@NgayKetThuc,@ViTri,@BaoHanh,@LOG,@TinhTrang,@MaNhom, @TangSuat, @Model, @Seri, @Hang, @NgayThucHienCuoi)";
            string updateCmd = "UPDATE THIETBI SET Id = @Id, Ten = @Ten, NgayBatDau = @NgayBatDau,"
                               + " NgayKetThuc = @NgayKetThuc, ViTri = @ViTri, BaoHanh = @BaoHanh, LOG = @LOG, TinhTrang = @TinhTrang,"
                               + " MaNhom = @MaNhom, TangSuat = @TangSuat, Model = @Model, Seri = @Seri, Hang = @Hang,NgayThucHienCuoi = @NgayThucHienCuoi"
                               + " WHERE Id = @Id";

            SqlCommand cmd = new SqlCommand();

            cmd.Connection  = con;
            cmd.CommandType = CommandType.Text;
            if (!isUpdate)
            {
                cmd.CommandText = insertNewCmd;
            }
            else
            {
                cmd.CommandText = updateCmd;
            }
            cmd.Parameters.AddWithValue("@Id", thietBi.deviceID);
            cmd.Parameters.AddWithValue("@Ten", thietBi.deviceName);
            cmd.Parameters.AddWithValue("@NgayBatDau", thietBi.startDate);
            cmd.Parameters.AddWithValue("@NgayKetThuc", thietBi.endDate);
            cmd.Parameters.AddWithValue("@ViTri", thietBi.position);
            cmd.Parameters.AddWithValue("@BaoHanh", thietBi.warranty);
            cmd.Parameters.AddWithValue("@LOG", thietBi.LOG);
            cmd.Parameters.AddWithValue("@TinhTrang", thietBi.status);
            cmd.Parameters.AddWithValue("@MaNhom", thietBi.deviceIDGroup);
            cmd.Parameters.AddWithValue("@TangSuat", thietBi.tangSuat);
            cmd.Parameters.AddWithValue("@Model", thietBi.model);
            cmd.Parameters.AddWithValue("@Seri", thietBi.serial);
            cmd.Parameters.AddWithValue("@Hang", thietBi.hangsx);
            cmd.Parameters.AddWithValue("@NgayThucHienCuoi", thietBi.lanCuoi);

            int ret = -1;

            try
            {
                ret = cmd.ExecuteNonQuery();
            }
            catch (Exception e)
            {
                Debug.WriteLine("The product name is ------->   " + e.Message);
            }

            dbmg.closeDatabase();
            Debug.WriteLine("DEVICE IS REGISTERED ");

            return((ret > 0) ? ret : -1);
        }
Esempio n. 3
0
        public DataSet testReport()
        {
            DataBaseManager.initializeInstance();
            DataBaseManager dbmg = DataBaseManager.getInstance();
            SqlConnection   con  = dbmg.openDatabase();

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

            dataadapter.Fill(ds, "NhanVien");
            dbmg.closeDatabase();
            return(ds);
        }
Esempio n. 4
0
        internal void updateGridData(DataGridView dataGirdQuyTrinh)
        {
            DataBaseManager.initializeInstance();
            DataBaseManager dbmg = DataBaseManager.getInstance();
            SqlConnection   con  = dbmg.openDatabase();

            string         sql         = "SELECT * FROM QuyTrinhBaoTri";
            SqlDataAdapter dataadapter = new SqlDataAdapter(sql, con);
            DataSet        ds          = new DataSet();

            dataadapter.Fill(ds, "QuyTrinhBT");
            dataGirdQuyTrinh.DataSource = ds;
            dataGirdQuyTrinh.DataMember = "QuyTrinhBT";

            dbmg.closeDatabase();
        }
Esempio n. 5
0
        public void updateGridData(DataGridView dataGrid)
        {
            DataBaseManager.initializeInstance();
            DataBaseManager dbmg = DataBaseManager.getInstance();
            SqlConnection   con  = dbmg.openDatabase();

            string         sql         = "SELECT * FROM ThietBi";
            SqlDataAdapter dataadapter = new SqlDataAdapter(sql, con);
            DataSet        ds          = new DataSet();

            dataadapter.Fill(ds, "ThietBi");
            dataGrid.DataSource = ds;
            dataGrid.DataMember = "ThietBi";

            dbmg.closeDatabase();
        }
Esempio n. 6
0
        public int addnewQuyTrinh(QuyTrinhBT quytrinh, bool isUpdate)
        {
            DataBaseManager.initializeInstance();
            DataBaseManager dbmg = DataBaseManager.getInstance();
            SqlConnection   con  = dbmg.openDatabase();

            string insertNewCmd = "INSERT QUYTRINHBAOTRI (Id, TenQuyTrinh, NguoiVietQuyTrinh, NoiDungQT) "
                                  + " VALUES (@Id,@TenQuyTrinh,@NguoiVietQuyTrinh,@NoiDungQT)";
            string updateCmd = "UPDATE QUYTRINHBAOTRI SET Id = @Id, TenQuyTrinh = @TenQuyTrinh, NguoiVietQuyTrinh = @NguoiVietQuyTrinh,"
                               + " NoiDungQT = @NoiDungQT";


            SqlCommand cmd = new SqlCommand();

            cmd.Connection  = con;
            cmd.CommandType = CommandType.Text;
            if (!isUpdate)
            {
                cmd.CommandText = insertNewCmd;
            }
            else
            {
                cmd.CommandText = updateCmd;
            }
            //cmd.CommandText = "INSERT QUYTRINHBAOTRI (Id, TenQuyTrinh) VALUES (@maQTBT,@tenQTBT,@tennguoiviet)";
            cmd.Parameters.AddWithValue("@ID", quytrinh.maQTBT);
            cmd.Parameters.AddWithValue("@TenQuyTrinh", quytrinh.tenQTBT);
            cmd.Parameters.AddWithValue("@NguoiVietQuyTrinh", quytrinh.tennguoiviet);
            cmd.Parameters.AddWithValue("@NoiDungQT", quytrinh.noidungQT);

            int ret = -1;

            try
            {
                ret = cmd.ExecuteNonQuery();
            }
            catch (Exception e)
            {
                Debug.WriteLine("The product name is " + e.Message);
            }

            dbmg.closeDatabase();

            return((ret > 0) ? ret : -1);
        }
Esempio n. 7
0
        public int addNewDeviceGroup(NhomThietBi nhomThietBi, bool isNewNhom)
        {
            DataBaseManager.initializeInstance();
            DataBaseManager dbmg = DataBaseManager.getInstance();
            SqlConnection   con  = dbmg.openDatabase();

            string newNhomCMD = "INSERT NHOMTB (Id, Ten, He) "
                                + " VALUES (@Id,@Ten,@He)";
            string updateNhomCMD = "UPDATE NHOMTB SET Id = @Id, Ten = @Ten, He = @He WHERE Id = @Id";

            SqlCommand cmd = new SqlCommand();

            cmd.Connection  = con;
            cmd.CommandType = CommandType.Text;

            if (isNewNhom)
            {
                cmd.CommandText = newNhomCMD;
            }
            else
            {
                cmd.CommandText = updateNhomCMD;
            }

            cmd.Parameters.AddWithValue("@Id", nhomThietBi.groupID);
            cmd.Parameters.AddWithValue("@Ten", nhomThietBi.groupName);
            cmd.Parameters.AddWithValue("@He", nhomThietBi.groupSection);

            int ret = -1;

            try
            {
                ret = cmd.ExecuteNonQuery();
            }
            catch (Exception e)
            {
                Debug.WriteLine("The product name is " + e.Message);
            }

            dbmg.closeDatabase();

            Debug.WriteLine("DEVICE IS REGISTERED " + ret);

            return((ret > 0) ? ret : -1);
        }
Esempio n. 8
0
        public string addNewStaf(NhanVien nv, bool isNewNhanVien)
        {
            DataBaseManager.initializeInstance();
            DataBaseManager dbmg = DataBaseManager.getInstance();
            SqlConnection   con  = dbmg.openDatabase();

            string newNhanVien = "INSERT NHANVIEN (Id, Ten) "
                                 + " VALUES (@maNV,@tenNV)";
            string updateNhanVien = "UPDATE NHANVIEN SET Id = @maNV, Ten = @tenNV WHERE Id = @maNV";

            SqlCommand cmd = new SqlCommand();

            cmd.Connection  = con;
            cmd.CommandType = CommandType.Text;

            if (isNewNhanVien)
            {
                cmd.CommandText = newNhanVien;
            }
            else
            {
                cmd.CommandText = updateNhanVien;
            }

            cmd.Parameters.AddWithValue("@maNv", nv.maNv);
            cmd.Parameters.AddWithValue("@tenNv", nv.tenNv);

            //int ret = -1;
            string ret = "";

            try
            {
                cmd.ExecuteNonQuery();
            }
            catch (Exception e)
            {
                Debug.WriteLine("The product name is " + e.Message);
                ret = e.Message;
            }

            dbmg.closeDatabase();
            return(ret);
            //return (ret > 0) ? ret : -1;
        }
Esempio n. 9
0
        public void loadThietBiDenHanBaoTri(DataGridView dataGrid)
        {
            DataBaseManager.initializeInstance();
            DataBaseManager dbmg = DataBaseManager.getInstance();
            SqlConnection   con  = dbmg.openDatabase();

            //Debug.WriteLine("The --------->   " + String.Format("{0:yyyy-MM-dd}", DateTime.Now));

            string sql = "SELECT * FROM ThietBi Where DATEADD(day,TangSuat,NgayThucHienCuoi) < '" + String.Format("{0:yyyy-MM-dd}", DateTime.Now) + "'";

            SqlDataAdapter dataadapter = new SqlDataAdapter(sql, con);
            DataSet        ds          = new DataSet();

            dataadapter.Fill(ds, "ThietBi");
            dataGrid.DataSource = ds;
            dataGrid.DataMember = "ThietBi";

            dbmg.closeDatabase();
        }
Esempio n. 10
0
        public void updateComboBoxTenOnly(ComboBox cb)
        {
            DataBaseManager.initializeInstance();
            DataBaseManager dbmg = DataBaseManager.getInstance();
            SqlConnection   con  = dbmg.openDatabase();

            string        sql       = "SELECT * FROM QUYTRINHBAOTRI";
            SqlCommand    sqlCmd    = new SqlCommand(sql, con);
            SqlDataReader sqlReader = sqlCmd.ExecuteReader();

            while (sqlReader.Read())
            {
                cb.Items.Add(sqlReader["ID"].ToString());
            }

            sqlReader.Close();

            dbmg.closeDatabase();
        }
Esempio n. 11
0
        public int addNewShift(Ca ca)
        {
            DataBaseManager.initializeInstance();
            DataBaseManager dbmg = DataBaseManager.getInstance();
            SqlConnection   con  = dbmg.openDatabase();


            SqlCommand cmd = new SqlCommand();

            cmd.Connection  = con;
            cmd.CommandType = CommandType.Text;
            cmd.CommandText = "INSERT CA (MaCa, TenCa) VALUES (@maCa,@tenCa)";
            cmd.Parameters.AddWithValue("@maCa", ca.maCa);
            cmd.Parameters.AddWithValue("@tenCa", ca.tenCa);

            int ret = cmd.ExecuteNonQuery();

            dbmg.closeDatabase();

            return((ret > 0) ? ret : -1);
        }