Exemplo n.º 1
0
        /// <summary>
        /// Thực hiện thao tác lưu dữ liệu
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnLuu_Click(object sender, EventArgs e)
        {
            cBenhPKDO ds     = Getthongtinbenh();
            string    mabenh = XuLyMaBenh();

            if (Checkdauvao(ds) == true)
            {
                if (Add && BUS.cBenhBUS.CheckBenh(ds.MABENH) == true && Update == false)
                {
                    XtraMessageBox.Show("Mã bệnh đã tồn tại: " + txtMabenh.Text + "!!",
                                        "Hỏi", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    Enablediting(true);
                }
                else
                {
                    if (Add && BUS.cBenhBUS.CheckBenh(ds.MABENH) == false && Update == false)
                    {
                        BUS.cBenhBUS.InsertBenh(mabenh, ds.MANHOMBENH1, ds.TENBENHTA, ds.TENBENHTV, ds.MOTA1, ds.NGAYTAO1, ds.TRANGTHAI1);
                        ucBenh_Load(sender, e);
                        XtraMessageBox.Show("Lưu thành công", "", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }

                if (Update)
                {
                    BUS.cBenhBUS.UpdateBenh(ds.MABENH, ds.TENBENHTA, ds.TENBENHTV, ds.MOTA1, ds.NGAYTAO1, ds.TRANGTHAI1);
                    ucBenh_Load(sender, e);
                    XtraMessageBox.Show("Lưu thành công", "", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
        }
Exemplo n.º 2
0
 /// <summary>
 /// Kiểm tra đầu vào
 /// </summary>
 /// <param name="ds"></param>
 /// <returns></returns>
 private static bool Checkdauvao(cBenhPKDO ds)
 {
     if (ds.MANHOMBENH1.Equals(""))
     {
         XtraMessageBox.Show("Vui lòng chọn nhóm bệnh!");
         return(false);
     }
     if (ds.TENBENHTV.Equals(""))
     {
         XtraMessageBox.Show("Vui lòng nhập lại tên bệnh tiếng việt!");
         return(false);
     }
     return(true);
 }
Exemplo n.º 3
0
        /// <summary>
        /// Hàm lấy thông tin bệnh
        /// </summary>
        /// <returns></returns>
        public cBenhPKDO Getthongtinbenh()
        {
            cBenhPKDO ds = new cBenhPKDO();

            //String[] n = txtTenbenhTV.Text.Split(' ');
            //string sTenTV= "";
            //for (int i = 0; i < n.Length; i++)
            //{
            //    n[i] = n[i].Trim();
            //    if (n[i] != "")
            //    {
            //        sTenTV = sTenTV + " " + n[i];
            //    }
            //}
            ds.TENBENHTV = txtTenbenhTV.Text;
            //String[] n1 = txtTenbenhTA.Text.Split(' ');
            //string sTenTA = "";
            //for (int i = 0; i < n.Length; i++)
            //{
            //    n1[i] = n1[i].Trim();
            //    if (n1[i] != "")
            //    {
            //        sTenTA = sTenTA + " " + n[i];
            //    }
            //}
            ds.TENBENHTA   = txtTenbenhTA.Text;
            ds.MABENH      = txtMabenh.Text;
            ds.MANHOMBENH1 = cmbNhombenh.EditValue.ToString();
            ds.MOTA1       = txtMota.Text;
            ds.NGAYTAO1    = DateTime.Today;
            if (chkTrangThai.Checked == true)
            {
                ds.TRANGTHAI1 = true;
            }
            else
            {
                ds.TRANGTHAI1 = false;
            }
            return(ds);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Lay danh sach benh tu entities
        /// </summary>
        /// <returns></returns>
        public static List <cBenhPKDO> Getdsbenh()
        {
            List <cBenhPKDO> dsbenh = new List <cBenhPKDO>();

            using (DB_HMS_Entities ds = new DB_HMS_Entities())
            {
                var query = from ads in ds.tbBENHs
                            select ads;
                foreach (var row in query)
                {
                    cBenhPKDO dss = new cBenhPKDO();
                    dss.MABENH      = row.MABENH;
                    dss.MANHOMBENH1 = row.MANHOMBENH;
                    dss.MOTA1       = row.MOTA;
                    dss.TENBENHTA   = row.TENBENHTA;
                    dss.TENBENHTV   = row.TENBENHTV;
                    dss.NGAYTAO1    = row.NGAYTAO.Value;
                    dss.TRANGTHAI1  = row.TRANGTHAI;
                    dsbenh.Add(dss);
                }
                return(dsbenh);
            }
        }