private static PsReponse UpdateStatusSyncDanhMucChiCuc(PSDanhMucChiCuc chicuc) { PsReponse res = new PsReponse(); try { ProcessDataSync cn = new ProcessDataSync(); db = cn.db; db.Connection.Open(); db.Transaction = db.Connection.BeginTransaction(); var dv = db.PSDanhMucChiCucs.FirstOrDefault(p => p.MaChiCuc == chicuc.MaChiCuc); if (dv != null) { dv.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; }
public static bool UpdChiCuc(PSDanhMucChiCuc chiCuc) { var db = new BioDAL(); return(db.UpdChiCuc(chiCuc)); }
private void gridView_ChiCuc_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_TenChiCuc)))) { e.Valid = false; view.SetColumnError(col_th_TenChiCuc, "Tên chi cục không được để trống!"); } if (e.Valid) { byte[] byteNull = ASCIIEncoding.ASCII.GetBytes(""); PSDanhMucChiCuc chiCuc = new PSDanhMucChiCuc(); if (string.IsNullOrEmpty(gridView_ChiCuc.GetRowCellValue(e.RowHandle, "RowIDChiCuc").ToString())) { chiCuc.RowIDChiCuc = 0; } else { chiCuc.RowIDChiCuc = Convert.ToInt32(gridView_ChiCuc.GetRowCellValue(e.RowHandle, "RowIDChiCuc").ToString()); } chiCuc.MaChiCuc = gridView_ChiCuc.GetRowCellValue(e.RowHandle, "MaChiCuc").ToString(); chiCuc.TenChiCuc = gridView_ChiCuc.GetRowCellValue(e.RowHandle, "TenChiCuc").ToString(); chiCuc.DiaChiChiCuc = gridView_ChiCuc.GetRowCellValue(e.RowHandle, "DiaChiChiCuc").ToString(); chiCuc.SdtChiCuc = gridView_ChiCuc.GetRowCellValue(e.RowHandle, "SdtChiCuc").ToString(); if (string.IsNullOrEmpty(gridView_ChiCuc.GetRowCellValue(e.RowHandle, "Logo").ToString())) { chiCuc.Logo = new Binary(byteNull); } else { chiCuc.Logo = (Binary)gridView_ChiCuc.GetRowCellValue(e.RowHandle, "Logo"); } if (string.IsNullOrEmpty(gridView_ChiCuc.GetRowCellValue(e.RowHandle, "HeaderReport").ToString())) { chiCuc.HeaderReport = new Binary(byteNull); } else { chiCuc.HeaderReport = (Binary)gridView_ChiCuc.GetRowCellValue(e.RowHandle, "HeaderReport"); } if (string.IsNullOrEmpty(gridView_ChiCuc.GetRowCellValue(e.RowHandle, "Stt").ToString())) { chiCuc.Stt = 0; } else { chiCuc.Stt = Convert.ToInt16(gridView_ChiCuc.GetRowCellValue(e.RowHandle, "Stt").ToString()); } if (string.IsNullOrEmpty(gridView_ChiCuc.GetRowCellValue(e.RowHandle, "isLocked").ToString())) { chiCuc.isLocked = false; } else { chiCuc.isLocked = Convert.ToBoolean(gridView_ChiCuc.GetRowCellValue(e.RowHandle, "isLocked").ToString()); } if (e.RowHandle < 0) { string codeGen = BioBLL.GetCodeChiCuc(); if (XtraMessageBox.Show("Danh mục chi cục bạn thêm có mã tự động là " + codeGen + " bạn có muốn thay đổi không?", "Bệnh viện điện tử .NET", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) != DialogResult.No) { int result = 0; do { codeGen = this.InputForm(codeGen); if (CheckCodeExist(codeGen)) { chiCuc.MaChiCuc = codeGen; result = 0; } else { result = 1; } } while (result == 1); } else { chiCuc.MaChiCuc = codeGen; } if (BioBLL.InsChiCuc(chiCuc)) { XtraMessageBox.Show("Thêm mới chi cục thành công!", "Bệnh viện điện tử .NET", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { XtraMessageBox.Show("Thêm mới chi cục thất bại!", "Bệnh viện điện tử .NET", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { if (BioBLL.UpdChiCuc(chiCuc)) { XtraMessageBox.Show("Cập nhật chi cục thành công!", "Bệnh viện điện tử .NET", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { XtraMessageBox.Show("Cập nhật chi cục thất bại!", "Bệnh viện điện tử .NET", MessageBoxButtons.OK, MessageBoxIcon.Error); } } this.gridControl_ChiCuc.DataSource = BioBLL.GetListChiCuc(); } } catch { XtraMessageBox.Show("Thao tác thất bại!", "Bệnh viện điện tử .NET", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public static PsReponse UpdateDMChiCuc(PSDanhMucChiCuc cc) { PsReponse res = new PsReponse(); res.Result = true; try { ProcessDataSync cn = new ProcessDataSync(); db = cn.db; db.Connection.Open(); db.Transaction = db.Connection.BeginTransaction(); var kyt = db.PSDanhMucChiCucs.FirstOrDefault(p => p.MaChiCuc == cc.MaChiCuc); if (kyt != null) { if (!kyt.isDongBo) { kyt.isLocked = cc.isLocked; kyt.Stt = cc.Stt; kyt.TenChiCuc = Encoding.UTF8.GetString(Encoding.Default.GetBytes( cc.TenChiCuc)); kyt.SdtChiCuc = cc.SdtChiCuc; kyt.DiaChiChiCuc = Encoding.UTF8.GetString(Encoding.Default.GetBytes(cc.DiaChiChiCuc)); kyt.MaTrungTam = cc.MaTrungTam; kyt.isXoa = cc.isXoa; try { kyt.HeaderReport = cc.HeaderReport; kyt.Logo = cc.Logo; } catch { } db.SubmitChanges(); } } else { PSDanhMucChiCuc ccnew = new PSDanhMucChiCuc(); ccnew.isLocked = cc.isLocked; ccnew.Stt = cc.Stt; ccnew.TenChiCuc = Encoding.UTF8.GetString(Encoding.Default.GetBytes(cc.TenChiCuc)); ccnew.SdtChiCuc = cc.SdtChiCuc; ccnew.DiaChiChiCuc = Encoding.UTF8.GetString(Encoding.Default.GetBytes(cc.DiaChiChiCuc)); ccnew.MaTrungTam = cc.MaTrungTam; ccnew.isXoa = cc.isXoa; ccnew.MaChiCuc = cc.MaChiCuc; try { ccnew.HeaderReport = cc.HeaderReport; ccnew.Logo = cc.Logo; } catch { } db.PSDanhMucChiCucs.InsertOnSubmit(ccnew); db.SubmitChanges(); } db.Transaction.Commit(); db.Connection.Close(); } catch (Exception ex) { db.Transaction.Rollback(); db.Connection.Close(); res.Result = false; res.StringError = ex.ToString(); } return res; }
public static PsReponse GetDanhMucChiCuc() { PsReponse res = new PsReponse(); res.Result = true; 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(linkGetDanhMucChiCuc), 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) { PSDanhMucChiCuc kt = new PSDanhMucChiCuc(); kt = cn.CovertDynamicToObjectModel(item, kt); var resup = UpdateDMChiCuc(kt); if(!resup.Result) { res.StringError += resup.StringError; res.Result = false; } } } } 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 Kỹ Thuật từ server \r\n " + ex.Message; } return res; }