示例#1
0
        public static PsReponse UpdateDMGoiDichVuTheoDonVi(PSDanhMucGoiDichVuTheoDonVi cl)
        {
            PsReponse res = new PsReponse();

            try
            {
                ProcessDataSync cn = new ProcessDataSync();
                db = cn.db;
                db.Connection.Open();
                db.Transaction = db.Connection.BeginTransaction();

                var kyt = db.PSDanhMucGoiDichVuTheoDonVis.FirstOrDefault(p => p.IDGoiDichVuChung == cl.IDGoiDichVuChung && p.MaDVCS == cl.MaDVCS);
                if (kyt != null)
                {
                    if (kyt.isDongBo != false)
                    {
                        kyt.TenGoiDichVuTrungTam = Encoding.UTF8.GetString(Encoding.Default.GetBytes(cl.TenGoiDichVuTrungTam));
                        kyt.DonGia    = cl.DonGia;
                        kyt.ChietKhau = cl.ChietKhau;
                        kyt.isDongBo  = true;
                        db.SubmitChanges();
                    }
                }
                else
                {
                    if (kyt.isDongBo != false)
                    {
                        PSDanhMucGoiDichVuTheoDonVi kyth = new PSDanhMucGoiDichVuTheoDonVi();
                        kyth.ChietKhau            = cl.ChietKhau;
                        kyth.DonGia               = cl.DonGia;
                        kyth.MaDVCS               = cl.MaDVCS;
                        kyth.IDGoiDichVuChung     = cl.IDGoiDichVuChung;
                        kyth.TenGoiDichVuTrungTam = Encoding.UTF8.GetString(Encoding.Default.GetBytes(cl.TenGoiDichVuTrungTam));
                        db.PSDanhMucGoiDichVuTheoDonVis.InsertOnSubmit(kyth);
                        kyt.isDongBo = true;

                        db.SubmitChanges();
                    }
                }


                db.Transaction.Commit();
                db.Connection.Close();
                res.Result = true;
            }
            catch (Exception ex)
            {
                db.Transaction.Rollback();
                db.Connection.Close();
                res.Result      = false;
                res.StringError = ex.ToString();
            }
            return(res);
        }
示例#2
0
 private void gridView_GoiDVDonvi_ValidateRow(object sender, DevExpress.XtraGrid.Views.Base.ValidateRowEventArgs e)
 {
     try
     {
         GridView view     = sender as GridView;
         int      rowfocus = e.RowHandle;
         if (string.IsNullOrEmpty(Convert.ToString(view.GetRowCellValue(rowfocus, col_th_TenGoiDichVuTrungTam))))
         {
             e.Valid = false;
             view.SetColumnError(col_th_TenGoiDichVuTrungTam, "Tên gói không được để trống!");
         }
         if (string.IsNullOrEmpty(Convert.ToString(view.GetRowCellValue(rowfocus, col_th_IDGoiDichVuChung))))
         {
             e.Valid = false;
             view.SetColumnError(col_th_IDGoiDichVuChung, "Hãy chọn gói dịch vụ chung!");
         }
         if (string.IsNullOrEmpty(Convert.ToString(view.GetRowCellValue(rowfocus, col_th_MaDVCS))))
         {
             e.Valid = false;
             view.SetColumnError(col_th_MaDVCS, "Hãy chọn đơn vị cơ sở!");
         }
         if (e.Valid)
         {
             PSDanhMucGoiDichVuTheoDonVi goiDVCoSo = new PSDanhMucGoiDichVuTheoDonVi();
             if (string.IsNullOrEmpty(gridView_GoiDVDonvi.GetRowCellValue(e.RowHandle, "RowIDGoiDichVuTrungTam").ToString()))
             {
                 goiDVCoSo.RowIDGoiDichVuTrungTam = 0;
             }
             else
             {
                 goiDVCoSo.RowIDGoiDichVuTrungTam = Convert.ToInt32(gridView_GoiDVDonvi.GetRowCellValue(e.RowHandle, "RowIDGoiDichVuTrungTam").ToString());
             }
             goiDVCoSo.TenGoiDichVuChung = gridView_GoiDVDonvi.GetRowCellValue(e.RowHandle, "TenGoiDichVuChung").ToString();
             goiDVCoSo.IDGoiDichVuChung  = gridView_GoiDVDonvi.GetRowCellValue(e.RowHandle, "IDGoiDichVuChung").ToString();
             goiDVCoSo.MaDVCS            = gridView_GoiDVDonvi.GetRowCellValue(e.RowHandle, "MaDVCS").ToString();
             if (string.IsNullOrEmpty(gridView_GoiDVDonvi.GetRowCellValue(e.RowHandle, "ChietKhau").ToString()))
             {
                 goiDVCoSo.ChietKhau = 0;
             }
             else
             {
                 goiDVCoSo.ChietKhau = Convert.ToDouble(gridView_GoiDVDonvi.GetRowCellValue(e.RowHandle, "ChietKhau").ToString());
             }
             if (string.IsNullOrEmpty(gridView_GoiDVDonvi.GetRowCellValue(e.RowHandle, "DonGia").ToString()))
             {
                 goiDVCoSo.DonGia = 0;
             }
             else
             {
                 goiDVCoSo.DonGia = Convert.ToDecimal(gridView_GoiDVDonvi.GetRowCellValue(e.RowHandle, "DonGia").ToString());
             }
             if (e.RowHandle < 0)
             {
                 if (!BioBLL.CheckExistGoiTheoDonVi(goiDVCoSo.IDGoiDichVuChung, goiDVCoSo.MaDVCS))
                 {
                     XtraMessageBox.Show("Đã tồn tại gói theo đơn vị!", "Bệnh viện điện tử .NET", MessageBoxButtons.OK, MessageBoxIcon.Error);
                     this.gridControl_GoiDVDonvi.DataSource = BioBLL.GetListGoiDichVuCoSo();
                     return;
                 }
                 if (BioBLL.InsGoiDichVuCoSo(goiDVCoSo))
                 {
                     XtraMessageBox.Show("Thêm mới gói dịch vụ theo đơn vị cơ sở thành công!", "Bệnh viện điện tử .NET", MessageBoxButtons.OK, MessageBoxIcon.Information);
                 }
                 else
                 {
                     XtraMessageBox.Show("Thêm mới gói dịch vụ theo đơn vị cơ sở thất bại!", "Bệnh viện điện tử .NET", MessageBoxButtons.OK, MessageBoxIcon.Error);
                 }
             }
             else
             {
                 PSDanhMucGoiDichVuTheoDonVi goiDVCoSoOld = BioBLL.GetGoiDichVuCoSoById(Convert.ToInt32(goiDVCoSo.RowIDGoiDichVuTrungTam));
                 if (goiDVCoSoOld.IDGoiDichVuChung != goiDVCoSo.IDGoiDichVuChung || goiDVCoSoOld.MaDVCS != goiDVCoSo.MaDVCS)
                 {
                     if (!BioBLL.CheckExistGoiTheoDonVi(goiDVCoSo.IDGoiDichVuChung, goiDVCoSo.MaDVCS))
                     {
                         XtraMessageBox.Show("Đã tồn tại gói theo đơn vị!", "Bệnh viện điện tử .NET", MessageBoxButtons.OK, MessageBoxIcon.Error);
                         this.gridControl_GoiDVDonvi.DataSource = BioBLL.GetListGoiDichVuCoSo();
                         return;
                     }
                 }
                 if (BioBLL.UpdGoiDichVuCoSo(goiDVCoSo))
                 {
                     XtraMessageBox.Show("Cập nhật gói dịch vụ theo đơn vị cơ sở thành công!", "Bệnh viện điện tử .NET", MessageBoxButtons.OK, MessageBoxIcon.Information);
                 }
                 else
                 {
                     XtraMessageBox.Show("Cập nhật gói dịch vụ theo đơn vị cơ sở thất bại!", "Bệnh viện điện tử .NET", MessageBoxButtons.OK, MessageBoxIcon.Error);
                 }
             }
             this.gridControl_GoiDVDonvi.DataSource = BioBLL.GetListGoiDichVuCoSo();
         }
     }
     catch
     {
     }
 }
示例#3
0
        public static bool UpdGoiDichVuCoSo(PSDanhMucGoiDichVuTheoDonVi goiDichVuCoSo)
        {
            var db = new BioDAL();

            return(db.UpdGoiDichVuCoSo(goiDichVuCoSo));
        }
示例#4
0
        private void gridView_DonViCoSo_ValidateRow(object sender, DevExpress.XtraGrid.Views.Base.ValidateRowEventArgs e)
        {
            try
            {
                GridView view     = sender as GridView;
                int      rowfocus = e.RowHandle;
                if (string.IsNullOrEmpty(Convert.ToString(view.GetRowCellValue(rowfocus, col_th_TenDVCS))))
                {
                    e.Valid = false;
                    view.SetColumnError(col_th_TenDVCS, "Tên đơn vị cơ sở không được để trống!");
                }
                if (string.IsNullOrEmpty(Convert.ToString(view.GetRowCellValue(rowfocus, col_th_MaChiCuc))))
                {
                    e.Valid = false;
                    view.SetColumnError(col_th_MaChiCuc, "Chi cục không được để trống!");
                }
                if (e.Valid)
                {
                    byte[]             byteNull = ASCIIEncoding.ASCII.GetBytes("");
                    PSDanhMucDonViCoSo donVi    = new PSDanhMucDonViCoSo();
                    if (string.IsNullOrEmpty(gridView_DonViCoSo.GetRowCellValue(e.RowHandle, "RowIDDVCS").ToString()))
                    {
                        donVi.RowIDDVCS = 0;
                    }
                    else
                    {
                        donVi.RowIDDVCS = Convert.ToInt16(gridView_DonViCoSo.GetRowCellValue(e.RowHandle, "RowIDDVCS").ToString());
                    }
                    donVi.MaDVCS     = gridView_DonViCoSo.GetRowCellValue(e.RowHandle, "MaDVCS").ToString();
                    donVi.TenDVCS    = gridView_DonViCoSo.GetRowCellValue(e.RowHandle, "TenDVCS").ToString();
                    donVi.DiaChiDVCS = gridView_DonViCoSo.GetRowCellValue(e.RowHandle, "DiaChiDVCS").ToString();
                    donVi.SDTCS      = gridView_DonViCoSo.GetRowCellValue(e.RowHandle, "SDTCS").ToString();
                    if (string.IsNullOrEmpty(gridView_DonViCoSo.GetRowCellValue(e.RowHandle, "Logo").ToString()))
                    {
                        donVi.Logo = new Binary(byteNull);
                    }
                    else
                    {
                        donVi.Logo = (Binary)gridView_DonViCoSo.GetRowCellValue(e.RowHandle, "Logo");
                    }
                    if (string.IsNullOrEmpty(gridView_DonViCoSo.GetRowCellValue(e.RowHandle, "HeaderReport").ToString()))
                    {
                        donVi.HeaderReport = new Binary(byteNull);
                    }
                    else
                    {
                        donVi.HeaderReport = (Binary)gridView_DonViCoSo.GetRowCellValue(e.RowHandle, "HeaderReport");
                    }
                    if (string.IsNullOrEmpty(gridView_DonViCoSo.GetRowCellValue(e.RowHandle, "Stt").ToString()))
                    {
                        donVi.Stt = 0;
                    }
                    else
                    {
                        donVi.Stt = Convert.ToInt16(gridView_DonViCoSo.GetRowCellValue(e.RowHandle, "Stt").ToString());
                    }
                    if (string.IsNullOrEmpty(gridView_DonViCoSo.GetRowCellValue(e.RowHandle, "isLocked").ToString()))
                    {
                        donVi.isLocked = false;
                    }
                    else
                    {
                        donVi.isLocked = Convert.ToBoolean(gridView_DonViCoSo.GetRowCellValue(e.RowHandle, "isLocked").ToString());
                    }

                    donVi.MaChiCuc = gridView_DonViCoSo.GetRowCellValue(e.RowHandle, "MaChiCuc").ToString();
                    if (string.IsNullOrEmpty(gridView_DonViCoSo.GetRowCellValue(e.RowHandle, "KieuTraKetQua").ToString()))
                    {
                        donVi.KieuTraKetQua = 1;
                    }
                    else
                    {
                        donVi.KieuTraKetQua = int.Parse(gridView_DonViCoSo.GetRowCellValue(e.RowHandle, "KieuTraKetQua").ToString());
                    }
                    donVi.TenBacSiDaiDien = gridView_DonViCoSo.GetRowCellValue(e.RowHandle, "TenBacSiDaiDien").ToString();
                    donVi.isDongBo        = false;
                    if (e.RowHandle < 0)
                    {
                        string codeGen = BioBLL.GetCodeDonViCoSo(donVi.MaChiCuc);
                        this.codeGenOld = codeGen.ToString();
                        if (XtraMessageBox.Show("Danh mục đơn vị cs bạn thêm có mã tự động là " + codeGen + " bạn có muốn thay đổi không?", "BioNet - Chương trình sàng lọc sơ sinh", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) != DialogResult.No)
                        {
                            int result = 0;
                            do
                            {
                                codeGen = this.InputForm(codeGen);
                                if (CheckCodeExist(codeGen))
                                {
                                    donVi.MaDVCS = codeGen;
                                    result       = 0;
                                }
                                else
                                {
                                    result  = 1;
                                    codeGen = this.codeGenOld;
                                }
                            } while (result == 1);
                        }
                        else
                        {
                            donVi.MaDVCS = codeGen;
                        }
                        if (BioBLL.InsDonViCS(donVi))
                        {
                            XtraMessageBox.Show("Thêm mới đơn vị cơ sở thành công!", "BioNet - Chương trình sàng lọc sơ sinh", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            if (XtraMessageBox.Show("Hệ thống tự động thêm dịch vụ vào đơn vị này. \nBạn có muốn thực hiện tác vụ này không?", "BioNet - Chương trình sàng lọc sơ sinh", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) != DialogResult.No)
                            {
                                List <PSDanhMucGoiDichVuChung>     lstGoiDV        = BioBLL.GetListGoiDichVuChung();
                                List <PSDanhMucGoiDichVuTheoDonVi> lstGoiTT        = new List <PSDanhMucGoiDichVuTheoDonVi>();
                                List <PSChiTietGoiDichVuChung>     lstChiTietGoiGV = BioBLL.GetListChiTietGoiDichVuChung();
                                foreach (var dv in lstGoiDV)
                                {
                                    PSDanhMucGoiDichVuTheoDonVi tt = new PSDanhMucGoiDichVuTheoDonVi();
                                    tt.IDGoiDichVuChung     = dv.IDGoiDichVuChung;
                                    tt.MaDVCS               = donVi.MaDVCS;
                                    tt.TenGoiDichVuTrungTam = dv.TenGoiDichVuChung;
                                    tt.DonGia               = dv.DonGia ?? 0;
                                    tt.ChietKhau            = dv.ChietKhau ?? 0;
                                    tt.isXoa    = false;
                                    tt.isDongBo = false;
                                    lstGoiTT.Add(tt);
                                }
                                if (!BioBLL.InsMultiGoiDichVuCoSo(lstGoiTT))
                                {
                                    XtraMessageBox.Show("Tự động thêm dịch vụ vào đơn vị thất bại!", "BioNet - Chương trình sàng lọc sơ sinh", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                }
                            }
                        }
                        else
                        {
                            XtraMessageBox.Show("Thêm mới đơn vị cơ sở thất bại!", "BioNet - Chương trình sàng lọc sơ sinh", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }
                    else
                    {
                        PSDanhMucDonViCoSo dvOld = BioBLL.GetDonViCoSoById(donVi.RowIDDVCS);
                        if (BioBLL.UpdDonViCS(donVi))
                        {
                            PSDanhMucDonViCoSo dvNew = BioBLL.GetDonViCoSoById(donVi.RowIDDVCS);
                            if (dvOld.MaChiCuc != donVi.MaChiCuc)
                            {
                                XtraMessageBox.Show("Thay đổi mã đơn vị " + donVi.MaDVCS + " thành " + dvNew.MaDVCS + " thành công!", "BioNet - Chương trình sàng lọc sơ sinh", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            }
                            XtraMessageBox.Show("Cập nhật đơn vị cơ sở thành công!", "BioNet - Chương trình sàng lọc sơ sinh", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                        else
                        {
                            XtraMessageBox.Show("Cập nhật đơn vị cơ sở thất bại!", "BioNet - Chương trình sàng lọc sơ sinh", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }
                    this.gridControl_DonViCoSo.DataSource = BioBLL.GetListDonViCoSo();
                }
            }
            catch { XtraMessageBox.Show("Thao tác thất bại!", "BioNet - Chương trình sàng lọc sơ sinh", MessageBoxButtons.OK, MessageBoxIcon.Error); }
        }
示例#5
0
        public static PsReponse GetDMGoiDichVuTheoDonVi()
        {
            PsReponse res = new PsReponse();

            try
            {
                ProcessDataSync cn = new ProcessDataSync();
                db = cn.db;
                var account = db.PSAccount_Syncs.FirstOrDefault();
                if (account != null)
                {
                    string token = cn.GetToken(account.userName, account.passWord);
                    if (!string.IsNullOrEmpty(token))
                    {
                        var result = cn.GetRespone(cn.CreateLink(linkDanhMucGoiDichVuTheoDonVi), token);
                        if (result.Result)
                        {
                            string json = result.ValueResult;
                            JavaScriptSerializer      jss  = new JavaScriptSerializer();
                            ObjectModel.RootObjectAPI Repo = jss.Deserialize <ObjectModel.RootObjectAPI>(json);
                            if (Repo != null)
                            {
                                if (Repo.TotalCount > 0)
                                {
                                    foreach (var item in Repo.Items)
                                    {
                                        PSDanhMucGoiDichVuTheoDonVi ct = new PSDanhMucGoiDichVuTheoDonVi();
                                        ct = cn.CovertDynamicToObjectModel(item, ct);
                                        UpdateDMGoiDichVuTheoDonVi(ct);
                                    }
                                    res.Result = true;
                                }
                            }
                            else
                            {
                                res.Result      = false;
                                res.StringError = result.ErorrResult;
                            }
                        }
                        else
                        {
                            res.Result      = false;
                            res.StringError = result.ErorrResult;
                        }
                    }
                    else
                    {
                        res.Result      = false;
                        res.StringError = "Kiểm tra lại kết nối mạng hoặc tài khoản đồng bộ!";
                    }
                }
                else
                {
                    res.Result      = false;
                    res.StringError = "Chưa có  tài khoản đồng bộ!";
                }
            }
            catch (Exception ex)
            {
                res.Result      = false;
                res.StringError = DateTime.Now.ToString() + "Lỗi khi get dữ liệu Danh Mục Gói Dịch Vụ Chung từ server \r\n " + ex.Message;
            }
            return(res);
        }