/// <summary> /// Trả về 0 nếu dữ liệu hợp lệ và chuẩn bị dữ liệu không thành công. /// Trả về 1 nếu dữ liệu hợp lệ và chuẩn bị dữ liệu thành công. /// </summary> /// <param name="objThongTinChung"></param> /// <param name="obj"></param> /// <param name="responseMessage"></param> /// <returns></returns> public int KiemTraVaChuanBiDuLieu(ref THONG_TIN_CHUNG objThongTinChung, ref PHAM_VI objPhamVi, ref ApplicationConstant.QuanTriHeThongResponseMessage responseMessage) { //Khai báo và khởi tạo biến responseMessage = ApplicationConstant.QuanTriHeThongResponseMessage.M_ResponseMessage_QuanTriHeThong_KhongThanhCong; /* #region Lấy lại thông tin và kiểm tra tồn tại * if (objPhamVi.MA_PVI_LOAI.Equals(BusinessConstant.LOAI_PHAM_VI.DON_VI.layGiaTri())) * { * foreach (string item in objPhamVi.MA_PVI) * { * if (!item.IsNullOrEmptyOrSpace()) * { * DM_DON_VI objDonVi = new DS_DM_DON_VI().getDonViByMaDonVi(item); * if (objDonVi.IsNullOrEmpty()) * { * responseMessage = ApplicationConstant.QuanTriHeThongResponseMessage.M_ResponseMessage_QuanTriHeThong_NguoiDung_KhongTonTai; * return 0; * } * else * objPhamVi.ID_PVI[objPhamVi.MA_PVI.IndexOf(item)] = objDonVi.ID; * } * } * } #endregion */ return(1); }
public ApplicationConstant.ResponseStatus PhanQuyenPhamVi(DatabaseConstant.Action action, ref THONG_TIN_CHUNG objThongTinChung, ref List <BS_ResponseDetail> lstResponseDetail, ref PHAM_VI objPhamVi, ref ApplicationConstant.QuanTriHeThongResponseMessage responseMessage) { ApplicationConstant.ResponseStatus responseStatus = new ApplicationConstant.ResponseStatus(); BS_ResponseDetail responseDetail = new BS_ResponseDetail(); switch (action) { case DatabaseConstant.Action.XOA: //Xóa responseStatus = new BS_QuanTriHeThong_Action().PhamVi_Xoa(ref objThongTinChung, ref objPhamVi, ref responseMessage, ref responseDetail); break; case DatabaseConstant.Action.LUU: //Thêm responseStatus = new BS_QuanTriHeThong_Action().PhamVi_Luu(ref objThongTinChung, ref objPhamVi, ref responseMessage, ref responseDetail); break; case DatabaseConstant.Action.LAY_LAI: //Sua responseStatus = new BS_QuanTriHeThong_Action().PhamVi_LayDuLieu(ref objThongTinChung, ref objPhamVi, ref responseMessage, ref responseDetail); break; default: responseStatus = ApplicationConstant.ResponseStatus.KHONG_THANH_CONG; responseMessage = ApplicationConstant.QuanTriHeThongResponseMessage.M_ResponseMessage_QuanTriHeThong_KhongThanhCong; break; } lstResponseDetail.Add(responseDetail); return(responseStatus); }
public ApplicationConstant.ResponseStatus LayDuLieu( ref PHAM_VI objPhamVi, ref ApplicationConstant.QuanTriHeThongResponseMessage responseMessage, ref BS_ResponseDetail bsRetDetail ) { try { DS_HT_PHAM_VI dsPhamVi = new DS_HT_PHAM_VI(); List <HT_PHAM_VI> lstPhamVi = new List <HT_PHAM_VI>(); if (objPhamVi.MA_PVI_LOAI.Equals(BusinessConstant.LOAI_PHAM_VI.DON_VI.layGiaTri())) { lstPhamVi = dsPhamVi.GetPhamViDonVi_ByDoiTuong(objPhamVi.MA_DTUONG_LOAI, objPhamVi.MA_DTUONG); } if (objPhamVi.MA_PVI_LOAI.Equals(BusinessConstant.LOAI_PHAM_VI.DIA_LY.layGiaTri())) { lstPhamVi = dsPhamVi.GetPhamViDiaLy_ByDoiTuong(objPhamVi.MA_DTUONG_LOAI, objPhamVi.MA_DTUONG); } objPhamVi.ID_PVI = new List <int>(); objPhamVi.MA_PVI = new List <string>(); objPhamVi.PHAN_LOAI = new List <string>(); foreach (HT_PHAM_VI item in lstPhamVi) { objPhamVi.ID_PVI.Add(item.ID_PVI.Value); objPhamVi.MA_PVI.Add(item.MA_PVI); objPhamVi.PHAN_LOAI.Add(item.PHAN_LOAI); } responseMessage = ApplicationConstant.QuanTriHeThongResponseMessage.M_ResponseMessage_QuanTriHeThong_ThanhCong; return(ApplicationConstant.ResponseStatus.THANH_CONG); } catch (Exception ex) { responseMessage = ApplicationConstant.QuanTriHeThongResponseMessage.M_ResponseMessage_QuanTriHeThong_KhongThanhCong; bsRetDetail.Result = ApplicationConstant.OperationStatus.Failed.layNgonNgu(); bsRetDetail.Detail = responseMessage.layGiaTri(); LLogging.WriteLog(ex.TargetSite.Name, LLogging.LogType.ERR, ex); return(ApplicationConstant.ResponseStatus.KHONG_THANH_CONG); } }
/// <summary> /// Lấy dữ liệu /// </summary> /// <param name="obj"></param> /// <param name="responseMessage"></param> /// <returns></returns> public ApplicationConstant.ResponseStatus PhamVi_LayDuLieu(ref THONG_TIN_CHUNG objThongTinChung, ref PHAM_VI obj, ref ApplicationConstant.QuanTriHeThongResponseMessage responseMessage, ref BS_ResponseDetail bsRetDetail) { ApplicationConstant.NghiepVuResponseMessage responseMessageNV = ApplicationConstant.NghiepVuResponseMessage.M_ResponseMessage_DungChung_ThanhCong; //Kiểm tra hợp lệ hệ thống if (new BS_DungChung_Detail().KiemTraHopLeHeThong(ref responseMessageNV) != 0) { return(ApplicationConstant.ResponseStatus.KHONG_THANH_CONG); } //Xử lý nghiệp vụ return(new BS_PhamVi_Detail().LayDuLieu(ref obj, ref responseMessage, ref bsRetDetail)); }
public ApplicationConstant.ResponseStatus Luu( ref PHAM_VI objPhamVi, ref ApplicationConstant.QuanTriHeThongResponseMessage responseMessage, ref BS_ResponseDetail bsRetDetail ) { bool kq = true; try { DS_HT_PHAM_VI dsPhamVi = new DS_HT_PHAM_VI(); using (TransactionScope trans = new TransactionScope()) { // Xóa các dữ liệu phân quyền bị xóa List <HT_PHAM_VI> lstPhamVi = new List <HT_PHAM_VI>(); if (objPhamVi.MA_PVI_LOAI.Equals(BusinessConstant.LOAI_PHAM_VI.DON_VI.layGiaTri())) { lstPhamVi = dsPhamVi.GetPhamViDonVi_ByDoiTuong(objPhamVi.MA_DTUONG_LOAI, objPhamVi.MA_DTUONG); } if (objPhamVi.MA_PVI_LOAI.Equals(BusinessConstant.LOAI_PHAM_VI.DIA_LY.layGiaTri())) { lstPhamVi = dsPhamVi.GetPhamViDiaLy_ByDoiTuong(objPhamVi.MA_DTUONG_LOAI, objPhamVi.MA_DTUONG); } foreach (HT_PHAM_VI item in lstPhamVi) { kq = dsPhamVi.Xoa(item); if (!kq) { break; } } // Thêm các dữ liệu phân quyền mới if (kq) { foreach (int item in objPhamVi.ID_PVI) { HT_PHAM_VI htPhamVi = new HT_PHAM_VI(); //htPhamVi.ID_DTUONG_LOAI = objPhamVi.ID_DTUONG; htPhamVi.MA_DTUONG_LOAI = objPhamVi.MA_DTUONG_LOAI; htPhamVi.ID_DTUONG = objPhamVi.ID_DTUONG; htPhamVi.MA_DTUONG = objPhamVi.MA_DTUONG; htPhamVi.PHAN_LOAI = objPhamVi.PHAN_LOAI.ElementAt(objPhamVi.ID_PVI.IndexOf(item)); htPhamVi.MA_PVI_LOAI = objPhamVi.MA_PVI_LOAI; htPhamVi.ID_PVI = item; htPhamVi.MA_PVI = objPhamVi.MA_PVI.ElementAt(objPhamVi.ID_PVI.IndexOf(item)); htPhamVi.TTHAI_BGHI = BusinessConstant.TrangThaiBanGhi.SU_DUNG.layGiaTri(); htPhamVi.TTHAI_NVU = BusinessConstant.TrangThaiNghiepVu.DA_DUYET.layGiaTri(); htPhamVi.MA_DVI_QLY = objPhamVi.MA_DVI_QLY; htPhamVi.MA_DVI_TAO = objPhamVi.MA_DVI_TAO; htPhamVi.NGAY_NHAP = objPhamVi.NGAY_NHAP; htPhamVi.NGUOI_NHAP = objPhamVi.NGUOI_NHAP; htPhamVi.NGAY_CNHAT = objPhamVi.NGAY_CNHAT; htPhamVi.NGUOI_CNHAT = objPhamVi.NGUOI_CNHAT; kq = dsPhamVi.Them(htPhamVi); if (!kq) { break; } } } if (kq) { trans.Complete(); responseMessage = ApplicationConstant.QuanTriHeThongResponseMessage.M_ResponseMessage_QuanTriHeThong_ThanhCong; bsRetDetail.Result = ApplicationConstant.OperationStatus.Successful.layNgonNgu(); bsRetDetail.Detail = responseMessage.layGiaTri(); return(ApplicationConstant.ResponseStatus.THANH_CONG); } else { responseMessage = ApplicationConstant.QuanTriHeThongResponseMessage.M_ResponseMessage_QuanTriHeThong_KhongThanhCong; bsRetDetail.Result = ApplicationConstant.OperationStatus.Failed.layNgonNgu(); bsRetDetail.Detail = responseMessage.layGiaTri(); return(ApplicationConstant.ResponseStatus.KHONG_THANH_CONG); } } } catch (Exception ex) { responseMessage = ApplicationConstant.QuanTriHeThongResponseMessage.M_ResponseMessage_QuanTriHeThong_KhongThanhCong; bsRetDetail.Result = ApplicationConstant.OperationStatus.Failed.layNgonNgu(); bsRetDetail.Detail = responseMessage.layGiaTri(); LLogging.WriteLog(ex.TargetSite.Name, LLogging.LogType.ERR, ex); throw ex; } }
private void LoadDuLieuPhanQuyen(PHAM_VI objPhamVi) { if (objPhamVi.IsNullOrEmpty()) { lstPhamViDonViNode = null; lstPhamViDonViNode = new List <PhamViDonViNode>(); string loaiDoiTuong = null; loaiDoiTuong = lstSourceLoaiDTuong.ElementAt(cmbDoiTuong.SelectedIndex).KeywordStrings.First(); DataRow dr = (DataRow)grDSDoiTuong.SelectedItem; if (dr != null) { objPhamVi = new PHAM_VI(); objPhamVi.ID_DTUONG = int.Parse(dr["ID"].ToString()); objPhamVi.MA_DTUONG = dr[2].ToString(); objPhamVi.MA_DVI_QLY = dr[5].ToString(); objPhamVi.MA_DVI_TAO = ClientInformation.MaDonVi; objPhamVi.MA_DTUONG_LOAI = loaiDoiTuong; objPhamVi.MA_PVI_LOAI = lstSourceLoaiPhamVi.ElementAt(cmbLoaiPhamVi.SelectedIndex).KeywordStrings.First(); QuanTriHeThongProcess process = new QuanTriHeThongProcess(); string responseMessage = string.Empty; ApplicationConstant.ResponseStatus status = process.LayPhanQuyenPhamVi(ref objPhamVi, ref responseMessage); if (status == ApplicationConstant.ResponseStatus.THANH_CONG && !objPhamVi.MA_PVI.IsNullOrEmpty()) { for (int i = 0; i < objPhamVi.MA_PVI.Count(); i++) { PhamViDonViNode phamViDonViNode = new PhamViDonViNode(); phamViDonViNode.ID_PVI = Int32.Parse(objPhamVi.ID_PVI[i].ToString()); phamViDonViNode.MA_PVI = objPhamVi.MA_PVI[i].ToString(); phamViDonViNode.PHAN_LOAI = objPhamVi.PHAN_LOAI[i].ToString(); lstPhamViDonViNode.Add(phamViDonViNode); } foreach (RadTreeViewItem item in getTreeViewItems(trvTreeDonVi)) { if (!item.Tag.IsNullOrEmpty()) { string[] tag = item.Tag.ToString().Split('#'); int sub_count_dm = Int32.Parse(tag[3]); string node = tag[0].ToString(); if (sub_count_dm > 0) { int sub_count_pv = getSubCountNodePv(node); if (sub_count_pv < sub_count_dm && sub_count_pv > 0) { item.CheckState = System.Windows.Automation.ToggleState.Indeterminate; } else if (sub_count_pv == sub_count_dm) { item.IsChecked = true; } else { item.IsChecked = false; } } else { item.IsChecked = objPhamVi.MA_PVI.Contains(node); } } } } } } else { foreach (RadTreeViewItem item in trvTreeDonVi.Items) { item.IsChecked = objPhamVi.MA_PVI.Contains(item.Tag.ToString()); } } }
private void Luu() { //Mouse.OverrideCursor = Cursors.Wait; try { string loaiDoiTuong = null; loaiDoiTuong = lstSourceLoaiDTuong.ElementAt(cmbDoiTuong.SelectedIndex).KeywordStrings.First(); DataRow dr = (DataRow)grDSDoiTuong.SelectedItem; if (dr != null) { PHAM_VI objPhamVi = new PHAM_VI(); objPhamVi.ID_DTUONG = int.Parse(dr["ID"].ToString()); objPhamVi.MA_DTUONG = dr[2].ToString(); objPhamVi.MA_DVI_QLY = dr[5].ToString(); objPhamVi.MA_DVI_TAO = ClientInformation.MaDonViGiaoDich; objPhamVi.MA_DTUONG_LOAI = loaiDoiTuong; objPhamVi.MA_PVI_LOAI = lstSourceLoaiPhamVi.ElementAt(cmbLoaiPhamVi.SelectedIndex).KeywordStrings.First(); int idxMA_PVI = 0; List <string> lstMaPhamVi = new List <string>(); foreach (RadTreeViewItem item in trvTreeDonVi.CheckedItems) { //if (item.Level == 2) //{ // lstMaPhamVi.Add(item.Tag.ToString()); //} lstMaPhamVi.Add(item.Tag.ToString()); } objPhamVi.MA_PVI = new string[lstMaPhamVi.Count]; objPhamVi.ID_PVI = new int[lstMaPhamVi.Count]; objPhamVi.PHAN_LOAI = new string[lstMaPhamVi.Count]; foreach (string item in lstMaPhamVi) { string[] tag = item.Split('#'); objPhamVi.MA_PVI[idxMA_PVI] = tag[0]; objPhamVi.PHAN_LOAI[idxMA_PVI] = tag[1]; objPhamVi.ID_PVI[idxMA_PVI] = Int32.Parse(tag[2]); idxMA_PVI++; } objPhamVi.NGUOI_NHAP = ClientInformation.TenDangNhap; objPhamVi.NGUOI_CNHAT = ClientInformation.TenDangNhap; objPhamVi.NGAY_NHAP = ClientInformation.NgayLamViecHienTai; objPhamVi.NGAY_CNHAT = ClientInformation.NgayLamViecHienTai; QuanTriHeThongProcess process = new QuanTriHeThongProcess(); string responseMessage = string.Empty; ApplicationConstant.ResponseStatus status = process.LuuPhanQuyenPhamVi(ref objPhamVi, ref responseMessage); if (status == ApplicationConstant.ResponseStatus.THANH_CONG) { LoadDuLieuPhanQuyen(objPhamVi); LMessage.ShowMessage("M.DungChung.LuuDuLieuThanhCong", LMessage.MessageBoxType.Information); //LMessage.ShowMessage(responseMessage, LMessage.MessageBoxType.Information); } else { LMessage.ShowMessage("M.DungChung.LuuDuLieuKhongThanhCong", LMessage.MessageBoxType.Warning); } } else { LMessage.ShowMessage("Choose object for role setting", LMessage.MessageBoxType.Warning); return; } } catch (System.Exception ex) { CommonFunction.ThongBaoLoi(ex); LLogging.WriteLog(System.Reflection.MethodInfo.GetCurrentMethod().ToString(), LLogging.LogType.ERR, ex); } //Mouse.OverrideCursor = Cursors.Arrow; }