Beispiel #1
0
        public DataTable KiemTraTrungTenThuoc(LOAI_BENHLY t)
        {
            string    query = "select * from LOAI_BENHLY where LBL_TEN = '" + t.Lbl_ten + "'";
            DataTable dt    = connecDB.ExecuteQuery(query);

            return(dt);
        }
        private void btnLuu_Click(object sender, EventArgs e)
        {
            LOAI_BENHLY t = LayTTLBL();

            if (dieukien)
            {
                if (daoLBL.InsertLBL(t))
                {
                    MessageBox.Show("Thêm thành công");
                    loadLBL();
                    xuLyControl(false);
                    //txtMa.Enabled = true;
                    frm.Visible = false;
                    resetText();
                }
            }
            else
            {
                if (daoLBL.UpdateLBL(t))
                {
                    MessageBox.Show("Sửa thành công");
                    loadLBL();
                    xuLyControl(false);
                    //txtMa.Enabled = true;
                    frm.Visible = false;
                    resetText();
                    //sua(true);
                }
            }
        }
        private LOAI_BENHLY LayTTLBL()
        {
            string ma  = txtMaLBL.Text;
            string ten = txtTenLBL.Text;


            LOAI_BENHLY lbl = new LOAI_BENHLY(ma, ten);

            return(lbl);
        }
Beispiel #4
0
        public bool InsertLBL(LOAI_BENHLY t)
        {
            if (KiemTraNhapLieu(t))
            {
                try
                {
                    SqlConnection conn = new SqlConnection(connecDB.connectionStr);
                    SqlCommand    cmd  = new SqlCommand("themLOAI_BENHLY", conn);
                    cmd.CommandType = CommandType.StoredProcedure;
                    //cmd.Parameters.Add("@mathuoc", SqlDbType.NVarChar, 20);
                    //cmd.Parameters["@mathuoc"].Value = mt;
                    cmd.Parameters.Add("@LBL_ID", SqlDbType.NVarChar, 10);
                    cmd.Parameters.Add("@LBL_TEN", SqlDbType.NVarChar, 20);

                    cmd.Parameters["@LBL_ID"].Value  = t.Id_lbl;
                    cmd.Parameters["@LBL_TEN"].Value = t.Lbl_ten;

                    conn.Open();
                    int result = cmd.ExecuteNonQuery();
                    conn.Close();
                    return(result > 0);


                    /*string query = string.Format("Insert DM_THUOC (THUOC_ID, LT_ID, THUOC_TEN, THUOC_HDSD, THUOC_DVT, THUOC_CONGDUNG, THUOC_GIA, THUOC_TRANGTHAI) values ('{0}', '{1}', N'{2}', N'{3}', N'{4}', N'{5}', '{6}', '{7}')",
                     *              t.Id_thuoc, t.Id_lt, t.Thuoc_ten, t.Thuoc_hdsd, t.Thuoc_dvt, t.Thuoc_congdung, t.Thuoc_gia, t.Thuoc_trangthai);
                     * int result = connecDB.ExecuteNonQuery(query);
                     * return result > 0;*/
                }
                catch
                {
                    if (KiemTraTrungTenThuoc(t).Rows.Count == 0)
                    {
                        MessageBox.Show("Thêm thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    else
                    {
                        MessageBox.Show("Thêm không thành công do tên loại bệnh lý đã tồn tại", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }

                    /*if(KiemTraTrungSDT(nv).Rows.Count == 0)
                     * {
                     *  MessageBox.Show("Thêm thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                     * }
                     * else
                     * {
                     *  MessageBox.Show("Thêm không thành công do Số điện thoại của giáo viên đã tồn tại", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                     * }*/
                }
            }
            return(false);
        }
Beispiel #5
0
        public bool KiemTraNhapLieu(LOAI_BENHLY t)
        {
            if (t.Id_lbl.Equals(""))
            {
                MessageBox.Show("Mã loại bệnh lý không được trống", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return(false);
            }
            else if (t.Lbl_ten.Equals(""))
            {
                MessageBox.Show("Tên loại bệnh lý không được trống", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return(false);
            }

            return(true);
        }
Beispiel #6
0
        public bool UpdateLBL(LOAI_BENHLY t)
        {
            if (KiemTraNhapLieu(t))
            {
                SqlConnection conn = new SqlConnection(connecDB.connectionStr);
                SqlCommand    cmd  = new SqlCommand("suaLOAI_BENHLY", conn);
                cmd.CommandType = CommandType.StoredProcedure;
                //cmd.Parameters.Add("@mathuoc", SqlDbType.NVarChar, 20);
                //cmd.Parameters["@mathuoc"].Value = mt;
                cmd.Parameters.Add("@LBL_ID", SqlDbType.NVarChar, 10);
                cmd.Parameters.Add("@LBL_TEN", SqlDbType.NVarChar, 20);

                cmd.Parameters["@LBL_ID"].Value  = t.Id_lbl;
                cmd.Parameters["@LBL_TEN"].Value = t.Lbl_ten;

                conn.Open();
                int result = cmd.ExecuteNonQuery();
                conn.Close();
                return(result > 0);
            }
            return(true);
        }