private void FillParameters(MySqlCommand cmd, ConsultInfoVO item, string std_id)
        {
            MySqlParameter param1 = new MySqlParameter("consult_date", MySqlDbType.DateTime);

            param1.Value = item.date;
            cmd.Parameters.Add(param1);

            MySqlParameter param2 = new MySqlParameter("consult_details", MySqlDbType.VarChar, 1000);

            param2.Value = item.details;
            cmd.Parameters.Add(param2);

            MySqlParameter param3 = new MySqlParameter("others", MySqlDbType.VarChar, 500);

            param3.Value = item.others;
            cmd.Parameters.Add(param3);


            MySqlParameter param4 = new MySqlParameter("std_id", MySqlDbType.VarChar, 10);

            param4.Value = std_id;
            cmd.Parameters.Add(param4);

            MySqlParameter param5 = new MySqlParameter("consult_id", MySqlDbType.Int32, 11);

            param5.Value = item.consult_id;
            cmd.Parameters.Add(param5);
        }
        public void Insert(ConsultInfoVO item, string std_id)
        {
            string       sql = "INSERT INTO Consult(std_id, consult_date, consult_details, others) VALUES(@std_id, @consult_date, @consult_details, @others) ";
            MySqlCommand cmd = new MySqlCommand(sql, conn);

            FillParameters(cmd, item, std_id);
            cmd.ExecuteNonQuery();
        }
        public void Delete(ConsultInfoVO item, string std_id)
        {
            string sql = "DELETE FROM Consult WHERE consult_id=@consult_id";

            MySqlCommand cmd = new MySqlCommand(sql, conn);

            FillParameters(cmd, item, std_id);
            cmd.ExecuteNonQuery();
        }
        public void Update(ConsultInfoVO item, string std_id)
        {
            string sql = "UPDATE Consult Set consult_date=@consult_date, consult_details=@consult_details, others=@others WHERE consult_id=@consult_id AND std_id=@std_id";

            MySqlCommand cmd = new MySqlCommand(sql, conn);

            FillParameters(cmd, item, std_id);
            cmd.ExecuteNonQuery();
        }
Exemple #5
0
        private ConsultInfoVO SetConsultInfoVo1(DataRow dr)
        {
            ConsultInfoVO item = new ConsultInfoVO();

            item.date    = Convert.ToDateTime(dr["consult_date"]);
            item.details = dr["consult_details"].ToString();
            item.others  = dr["others"].ToString();
            return(item);
        }
Exemple #6
0
        private ConsultInfoVO SetDelConsultInfoVo(DataRow dr)
        {
            ConsultInfoVO item = new ConsultInfoVO();

            item.consult_id = Convert.ToInt32(dr["consult_id", DataRowVersion.Original]);
            item.date       = Convert.ToDateTime(dr["consult_date", DataRowVersion.Original]);
            item.details    = dr["consult_details", DataRowVersion.Original].ToString();
            item.others     = dr["others", DataRowVersion.Original].ToString();
            return(item);
        }
Exemple #7
0
        private void ToolStripButton1_Click(object sender, EventArgs e)
        {
            ConsultInfoService service = new ConsultInfoService();

            try
            {
                DataRow[] insRows = dt.Select(null, null, DataViewRowState.Added);
                foreach (DataRow dr in insRows)
                {
                    ConsultInfoVO item = SetConsultInfoVo1(dr);
                    service.Insert(item, lblStudentID.Text);
                }
                DataRow[] upsRows = dt.Select(null, null, DataViewRowState.ModifiedCurrent);

                foreach (DataRow dr in upsRows)
                {
                    ConsultInfoVO item = SetConsultInfoVo(dr);
                    service.Update(item, lblStudentID.Text);
                }

                DataRow[] delRows = dt.Select(null, null, DataViewRowState.Deleted);

                foreach (DataRow dr in delRows)
                {
                    ConsultInfoVO item = SetDelConsultInfoVo(dr);
                    service.Delete(item, lblStudentID.Text);
                }

                MaterialMessageBox.Show("저장완료", "확인", MessageBoxButtons.OK);
            }
            catch (InvalidCastException)
            {
                MaterialMessageBox.Show("항목을 입력해주세요", "경고", MessageBoxButtons.OK);
            }
            catch (Exception err2)
            {
                MaterialMessageBox.Show(err2.Message, "경고", MessageBoxButtons.OK);
            }
            finally
            {
                service.Dispose();
            }
        }
Exemple #8
0
 public void Delete(ConsultInfoVO item, string std_id)
 {
     ConsultInfoDAC DAC = new ConsultInfoDAC(conn);
     DAC.Delete(item, std_id);
 }
Exemple #9
0
 public void Insert(ConsultInfoVO item,string std_id)
 {
     ConsultInfoDAC DAC = new ConsultInfoDAC(conn);
     DAC.Insert(item,std_id);
 }