Beispiel #1
0
        public void insert(ClassDTO value)
        {
            string cmd = "INSERT INTO LOP VALUES (@ClassID, @ClassName, @StaffID)";
            SqlCmd = new SqlCommand(cmd, SqlCon);

            SqlParameter ClassID = new SqlParameter("@ClassID", SqlDbType.VarChar, 20, "MALOP");
            ClassID.IsNullable = false;
            ClassID.Direction = ParameterDirection.Input;
            ClassID.Value = value.ClassID;
            SqlCmd.Parameters.Add(ClassID);

            SqlParameter ClassName = new SqlParameter("@ClassName", SqlDbType.NVarChar, 100, "TENLOP");
            ClassName.IsNullable = false;
            ClassName.Direction = ParameterDirection.Input;
            ClassName.Value = value.ClassName;
            SqlCmd.Parameters.Add(ClassName);

            SqlParameter StaffID = new SqlParameter("@StaffID", SqlDbType.VarChar, 20, "MANV");
            StaffID.IsNullable = false;
            StaffID.Direction = ParameterDirection.Input;
            StaffID.Value = value.StaffID;
            SqlCmd.Parameters.Add(StaffID);

            this.executeNonQuery();
        }
Beispiel #2
0
        public override object convertOneRowIntoADTO(DataTable dt, int i, int type = 0)
        {
            ClassDTO obj = new ClassDTO();

            obj.ClassID = dt.Rows[i]["MALOP"].ToString();
            obj.ClassName = dt.Rows[i]["TENLOP"].ToString();
            obj.StaffID = dt.Rows[i]["MANV"].ToString();

            return obj;
        }
Beispiel #3
0
        public ClassDTO[] selectAll()
        {
            string cmd = "SELECT * FROM LOP";
            SqlCmd = new SqlCommand(cmd, SqlCon);

            ArrayList list = this.executeQueryArrayList(0);

            int n = list.Count;
            ClassDTO[] result = new ClassDTO[n];

            for (int i = 0; i < n; i++)
                result[i] = (ClassDTO)list[i];

            return result;
        }
Beispiel #4
0
 public void updateClass(ClassDTO value)
 {
     classdao.update(value);
 }
Beispiel #5
0
 public void insertClass(ClassDTO value)
 {
     classdao.insert(value);
 }
Beispiel #6
0
        private void button_Commit1_Click(object sender, EventArgs e)
        {
            ClassDTO classdto = new ClassDTO();
            classdto.ClassID = textBox_ClassID1.Text;
            classdto.ClassName = textBox_ClassName1.Text;
            classdto.StaffID = textBox_StaffID1.Text;

            try
            {
                if (flag_class == 1)
                {
                    classbll.insertClass(classdto);
                }
                else if (flag_class == 2)
                {
                    classbll.updateClass(classdto);
                }

                loadClass();

                flag_class = 0;

                textBox_ClassID1.Enabled = false;
                textBox_ClassName1.Enabled = false;
                textBox_StaffID1.Enabled = false;

                textBox_ClassID1.Text = "";
                textBox_ClassName1.Text = "";
                textBox_StaffID1.Text = "";
            }
            catch (System.Exception ex)
            {
                MessageBox.Show(ex.Message, "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Beispiel #7
0
        public ClassDTO[] selectByStaff(string id)
        {
            string cmd = "SELECT* FROM LOP WHERE MANV = @StaffID";
            SqlCmd = new SqlCommand(cmd, SqlCon);

            SqlParameter staffid = new SqlParameter("@StaffID", SqlDbType.VarChar, 20, "MANV");
            staffid.IsNullable = false;
            staffid.Direction = ParameterDirection.Input;
            staffid.Value = id;
            SqlCmd.Parameters.Add(staffid);

            ArrayList list = this.executeQueryArrayList(0);

            int n = list.Count;
            ClassDTO[] result = new ClassDTO[n];

            for (int i = 0; i < n; i++)
                result[i] = (ClassDTO)list[i];

            return result;
        }
Beispiel #8
0
        public void update(ClassDTO value)
        {
            string cmd = "UPDATE LOP SET TENLOP = @ClassName, MANV = @StaffID WHERE MALOP = @ClassID";
            SqlCmd = new SqlCommand(cmd, SqlCon);

            SqlParameter ClassID = new SqlParameter("@ClassID", SqlDbType.VarChar, 20, "MALOP");
            ClassID.IsNullable = false;
            ClassID.Direction = ParameterDirection.Input;
            ClassID.Value = value.ClassID;
            SqlCmd.Parameters.Add(ClassID);

            SqlParameter ClassName = new SqlParameter("@ClassName", SqlDbType.NVarChar, 100, "TENLOP");
            ClassName.IsNullable = false;
            ClassName.Direction = ParameterDirection.Input;
            ClassName.Value = value.ClassName;
            SqlCmd.Parameters.Add(ClassName);

            SqlParameter StaffID = new SqlParameter("@StaffID", SqlDbType.VarChar, 20, "MANV");
            StaffID.IsNullable = false;
            StaffID.Direction = ParameterDirection.Input;
            StaffID.Value = value.StaffID;
            SqlCmd.Parameters.Add(StaffID);

            this.executeNonQuery();
        }