Exemplo n.º 1
0
        public void OnSave(ref string msg, HT_NHNSD obj)
        {
            try
            {
                if (Validate(ref msg, obj))
                {
                    QuanTriHeThongProcess process          = new QuanTriHeThongProcess();
                    List <string>         lstStrIdNSD      = new List <string>(); //(from row in dt.AsEnumerable() select row.Field<string>("ID")).Distinct().ToList();
                    List <int>            lstIdNSD         = lstStrIdNSD.Select(i => i.StringToInt32()).ToList();
                    ApplicationConstant.ResponseStatus ret = ApplicationConstant.ResponseStatus.KHONG_THANH_CONG;
                    var    lstTruyCap      = new List <HT_TRUY_CAP>();
                    string responseMessage = null;

                    // Nếu là thêm mới
                    if (obj.ID == 0)
                    {
                        ret = process.ThemNHNSD(ref obj, lstIdNSD, lstTruyCap, ref responseMessage);
                        afterAddNew(ref msg, ret, obj, responseMessage);
                    }
                    else
                    {
                        ret = process.SuaNHNSD(ref obj, lstIdNSD, lstTruyCap, ref responseMessage);
                        afterModify(ref msg, ret, obj, responseMessage);
                    }
                }
            }
            catch (Exception ex)
            {
                msg = LanguageNode.GetValueMessageLanguage(ex.Message);
                LLogging.WriteLog(System.Reflection.MethodInfo.GetCurrentMethod().ToString(), LLogging.LogType.ERR, ex);
            }
        }
Exemplo n.º 2
0
        public void onSave()
        {
            Mouse.OverrideCursor = Cursors.Wait;
            try
            {
                if (Validate())
                {
                    QuanTriHeThongProcess process          = new QuanTriHeThongProcess();
                    List <string>         lstStrIdNSD      = (from row in dt.AsEnumerable() select row.Field <string>("ID")).Distinct().ToList();
                    List <int>            lstIdNSD         = lstStrIdNSD.Select(i => i.StringToInt32()).ToList();
                    ApplicationConstant.ResponseStatus ret = ApplicationConstant.ResponseStatus.KHONG_THANH_CONG;
                    string responseMessage = null;

                    // Nếu là thêm mới
                    if (id == 0)
                    {
                        getObject(DatabaseConstant.Action.THEM);
                        ret = process.ThemNHNSD(ref obj, lstIdNSD, lstTruyCap, ref responseMessage);
                        afterAddNew(ret, obj, responseMessage);
                    }
                    else
                    {
                        getObject(DatabaseConstant.Action.SUA);
                        ret = process.SuaNHNSD(ref obj, lstIdNSD, lstTruyCap, ref responseMessage);
                        afterModify(ret, obj, responseMessage);
                    }
                }
            }
            catch (System.Exception ex)
            {
                CommonFunction.ThongBaoLoi(ex);
                LLogging.WriteLog(System.Reflection.MethodInfo.GetCurrentMethod().ToString(), LLogging.LogType.ERR, ex);
            }
            Mouse.OverrideCursor = Cursors.Arrow;
        }
Exemplo n.º 3
0
        public void onSave()
        {
            this.Cursor = Cursors.Wait;
            try
            {
                if (ValidateValue())
                {
                    HT_TSO ret = null;
                    QuanTriHeThongProcess process = new QuanTriHeThongProcess();

                    // Nếu là thêm mới
                    if (id == 0)
                    {
                        //getObject(DatabaseConstant.Action.THEM);
                        //ret = process.ThemNSD(obj, lstIdNHNSD);
                        //afterAddNew(ret);
                    }
                    // Nếu là sửa
                    else
                    {
                        getObjectValue(DatabaseConstant.Action.SUA);
                        ret = process.capNhatGiaTriThamSo(obj);
                        afterModify(ret);
                    }
                }
            }
            catch (System.Exception ex)
            {
                CommonFunction.ThongBaoLoi(ex);
                LLogging.WriteLog(System.Reflection.MethodInfo.GetCurrentMethod().ToString(), LLogging.LogType.ERR, ex);
            }
            Mouse.OverrideCursor = Cursors.Arrow;
        }
Exemplo n.º 4
0
 private void calendar_DisplayDateChanged(object sender, CalendarDateChangedEventArgs e)
 {
     try
     {
         if (((DateTime)e.AddedDate).ToString("yyyy").StringToInt32() > 1753 && (((DateTime)e.AddedDate).ToString("yyyyMM") != ((DateTime)e.RemovedDate).ToString("yyyyMM")))
         {
             calendar.BlackoutDates.Clear();
             DateTime    dt          = (DateTime)e.AddedDate;
             List <bool> workingDays = QuanTriHeThongProcess.IsWorkingDays(dt.GetYear(), dt.GetMonth());
             for (int i = 0; i < workingDays.Count; i++)
             {
                 if (!workingDays[i])
                 {
                     calendar.BlackoutDates.Add(new CalendarDateRange(dt));
                 }
                 dt = dt.PlusDays(1);
             }
         }
     }
     catch (Exception ex)
     {
         if (ex.GetType() == typeof(CustomException))
         {
             new frmThongBaoLoi(LLanguage.SearchResourceByKey(ex.Message), ex.InnerException).ShowDialog();
         }
         else
         {
             new frmThongBaoLoi(LLanguage.SearchResourceByKey("M"), ex).ShowDialog();
         }
         //LLogging.WriteLog(System.Reflection.MethodInfo.GetCurrentMethod().ToString(), LLogging.LogType.ERR, ex);
     }
 }
Exemplo n.º 5
0
        private void btnResetPassword_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (Validation())
                {
                    string newPassword = LSecurity.MD5Encrypt(txtNewPassword.Password);

                    QuanTriHeThongProcess process          = new QuanTriHeThongProcess();
                    string responseMessage                 = "";
                    ApplicationConstant.ResponseStatus ret = ApplicationConstant.ResponseStatus.KHONG_THANH_CONG;

                    ret = process.ThietLapMatKhauNguoiDung(userName, newPassword, ref responseMessage);

                    if (ret == ApplicationConstant.ResponseStatus.THANH_CONG)
                    {
                        LMessage.ShowMessage("M.ResponseMessage.QuanTriHeThong.NguoiDung.ResetMatKhauThanhCong", LMessage.MessageBoxType.Information);
                        CustomControl.CommonFunction.CloseUserControl(this);
                    }
                    else
                    {
                        LMessage.ShowMessage(responseMessage, LMessage.MessageBoxType.Warning);
                    }
                }
            }
            catch (System.Exception ex)
            {
                CommonFunction.ThongBaoLoi(ex);
                LLogging.WriteLog(System.Reflection.MethodInfo.GetCurrentMethod().ToString(), LLogging.LogType.ERR, ex);
            }
        }
        private void Worker_DoWork_KiemTra(object sender, DoWorkEventArgs e)
        {
            try
            {
                // background
                QuanTriHeThongProcess process          = new QuanTriHeThongProcess();
                ApplicationConstant.ResponseStatus ret = ApplicationConstant.ResponseStatus.KHONG_THANH_CONG;
                string  serverVersion        = "";
                string  lastestClientVersion = "";
                HT_PBAN htPban = new HT_PBAN();
                List <HT_PBAN_CTIET> listHtPbanCtiet = new List <HT_PBAN_CTIET>();
                List <HT_PBAN_FILE>  listHtPbanFile  = new List <HT_PBAN_FILE>();
                string responseMessage = "";
                ret       = process.CheckClientVersion(ClientInformation.Version, ref serverVersion, ref lastestClientVersion, ref htPban, ref listHtPbanCtiet, ref listHtPbanFile, ref responseMessage);
                ResStatus = ret;
                if (ret == ApplicationConstant.ResponseStatus.THANH_CONG)
                {
                    ServerVersion        = serverVersion;
                    LastestClientVersion = lastestClientVersion;
                    if (ClientInformation.Version.Equals(LastestClientVersion))
                    {
                        IsLastestVersion = true;
                        ResContent       = LLanguage.SearchResourceByKey("M.ResponseMessage.QuanTriHeThong.PhienBan.SystemUpToDate") + " " + ClientInformation.Version;
                    }
                    else
                    {
                        IsLastestVersion = false;
                        HtPban           = htPban;
                        ListHtPbanCtiet  = listHtPbanCtiet;
                        ListHtPbanFile   = listHtPbanFile;
                        ResContent       = LLanguage.SearchResourceByKey("M.ResponseMessage.QuanTriHeThong.PhienBan.PhienBanHienTai") +
                                           " " + ClientInformation.Version + ". " +
                                           LLanguage.SearchResourceByKey("M.ResponseMessage.QuanTriHeThong.PhienBan.PhienBanMoiNhat") +
                                           " " + LastestClientVersion;
                    }
                }
                else if (ret == ApplicationConstant.ResponseStatus.KHONG_THANH_CONG)
                {
                    ResContent = LLanguage.SearchResourceByKey(responseMessage);
                }
                else
                {
                    ResContent = "";
                }

                Thread.Sleep(3000);
            }
            catch (Exception ex)
            {
                ResStatus  = ApplicationConstant.ResponseStatus.KHONG_THANH_CONG;
                ResContent = LLanguage.SearchResourceByKey("M.ResponseMessage.QuanTriHeThong.PhienBan.KiemTraKhongThanhCong");
                LLogging.WriteLog(System.Reflection.MethodInfo.GetCurrentMethod().ToString(), LLogging.LogType.SYS, ex);
                Worker_KiemTra.CancelAsync();
                // Vẫn xử lý tại client cho logout
                //Application.Current.Shutdown();
            }
        }
Exemplo n.º 7
0
        private void LuuTrangThai(DatabaseConstant.Action action)
        {
            QuanTriHeThongProcess process = new QuanTriHeThongProcess();

            Mouse.OverrideCursor = Cursors.Wait;
            try
            {
                List <int> lstID = new List <int>();
                lstID.Add(obj.ID);
                process.capNhatThamSo(action, obj, null);
                LMessage.ShowMessage("M.DungChung.LuuDuLieuThanhCong", LMessage.MessageBoxType.Information);
                CommonFunction.RefreshButton(Toolbar, DatabaseConstant.Action.THEM, obj.TTHAI_NVU, mnuMain, DatabaseConstant.Function.HT_THAM_SO);
            }
            catch (System.Exception ex)
            {
                CommonFunction.ThongBaoLoi(ex);
                LLogging.WriteLog(System.Reflection.MethodInfo.GetCurrentMethod().ToString(), LLogging.LogType.ERR, ex);
            }
            Mouse.OverrideCursor = Cursors.Arrow;
        }
Exemplo n.º 8
0
        /// <summary>
        /// Xóa dữ liệu
        /// </summary>
        private void OnDelete(ref string msg, int id)
        {
            QuanTriHeThongProcess process = new QuanTriHeThongProcess();

            int[] arrayID = new int[0];
            try
            {
                Array.Resize(ref arrayID, arrayID.Length + 1);
                arrayID[arrayID.Length - 1] = id;

                List <ClientResponseDetail> listClientResponseDetail = new List <ClientResponseDetail>();
                bool ret = process.XoaListNHNSD(arrayID, ref listClientResponseDetail);

                AfterDelete(ref msg, id, ret, listClientResponseDetail);
            }
            catch (Exception ex)
            {
                msg = LanguageNode.GetValueMessageLanguage(ex.Message);
                LLogging.WriteLog(System.Reflection.MethodInfo.GetCurrentMethod().ToString(), LLogging.LogType.ERR, ex);
            }
        }
Exemplo n.º 9
0
        private void LuuTrangThai(DatabaseConstant.Action action)
        {
            QuanTriHeThongProcess process = new QuanTriHeThongProcess();

            Mouse.OverrideCursor = Cursors.Wait;
            try
            {
                List <int> lstID = new List <int>();
                foreach (var row in grDanhSach.SelectedItems)
                {
                    if (row is DataRow)
                    {
                        if ((int)((DataRow)row)[0] > 0)
                        {
                            lstID.Add((int)((DataRow)row)[0]);
                        }
                    }
                    else
                    {
                        if ((int)((DataRow)row)[0] > 0)
                        {
                            lstID.Add((int)((DataRow)row)[0]);
                        }
                    }
                }
                string loaiDoiTuong = ((RadTreeViewItem)tvwTree.SelectedItem).Tag.ToString();
                LMessage.ShowMessage("M.DungChung.LuuDuLieuThanhCong", LMessage.MessageBoxType.Information);
                BuildGridDoiTuong();
                loadWidthColumnDoiTuong();
            }
            catch (System.Exception ex)
            {
                CommonFunction.ThongBaoLoi(ex);
                LLogging.WriteLog(System.Reflection.MethodInfo.GetCurrentMethod().ToString(), LLogging.LogType.ERR, ex);
            }
            Mouse.OverrideCursor = Cursors.Arrow;
        }
Exemplo n.º 10
0
        /// <summary>
        /// Xóa dữ liệu
        /// </summary>
        private void onDelete()
        {
            QuanTriHeThongProcess process = new QuanTriHeThongProcess();

            int[] arrayID = new int[0];
            Mouse.OverrideCursor = Cursors.Wait;
            try
            {
                Array.Resize(ref arrayID, arrayID.Length + 1);
                arrayID[arrayID.Length - 1] = id;

                List <ClientResponseDetail> listClientResponseDetail = new List <ClientResponseDetail>();
                bool ret = process.XoaListNHNSD(arrayID, ref listClientResponseDetail);

                afterDelete(ret, listClientResponseDetail);
            }
            catch (System.Exception ex)
            {
                this.Cursor = Cursors.Arrow;
                CommonFunction.ThongBaoLoi(ex);
                LLogging.WriteLog(System.Reflection.MethodInfo.GetCurrentMethod().ToString(), LLogging.LogType.ERR, ex);
            }
            Mouse.OverrideCursor = Cursors.Arrow;
        }
        private void Worker_DoWork_Download(object sender, DoWorkEventArgs e)
        {
            try
            {
                // background
                QuanTriHeThongProcess process          = new QuanTriHeThongProcess();
                ApplicationConstant.ResponseStatus ret = ApplicationConstant.ResponseStatus.KHONG_THANH_CONG;
                FileBase    fileResponse    = new FileBase();
                string      responseMessage = "";
                PhienBanDTO phienBanDTO     = new PhienBanDTO();
                ret       = process.DownloadClientVersion(ClientInformation.Version, LastestClientVersion, HtPban, ref phienBanDTO, ref responseMessage);
                ResStatus = ret;
                if (ret == ApplicationConstant.ResponseStatus.THANH_CONG)
                {
                    string phuongThucCapNhat = HtPban.PTHUC_CNHAT;
                    string maPhienBanTruoc   = HtPban.MA_PBAN_TRUOC;
                    // Nếu cập nhật toàn bộ ứng dụng
                    if (phuongThucCapNhat.Equals("FULL") ||
                        (phuongThucCapNhat.Equals("CHANGE") && !maPhienBanTruoc.Equals(ClientInformation.Version)))
                    {
                        LLogging.WriteLog(System.Reflection.MethodInfo.GetCurrentMethod().ToString(), LLogging.LogType.SYS, "FULL_UPDATE");
                        string tenFile    = phienBanDTO.ListPhienBanItemDTO.FirstOrDefault().HtPbanFile.TEN_FILE;
                        string folderPath = ClientInformation.OtaVersionDir + "\\" + HtPban.MA_PBAN;
                        string filePath   = ClientInformation.OtaVersionDir + "\\" + HtPban.MA_PBAN + "\\" + tenFile;
                        PathFile = filePath;

                        if (Directory.Exists(folderPath))
                        {
                            LLogging.WriteLog(System.Reflection.MethodInfo.GetCurrentMethod().ToString(), LLogging.LogType.SYS, "DeleteDirectory: " + folderPath);
                            Directory.Delete(folderPath, true);
                        }
                        LLogging.WriteLog(System.Reflection.MethodInfo.GetCurrentMethod().ToString(), LLogging.LogType.SYS, "CreateDirectory: " + folderPath);

                        try
                        {
                            DirectoryInfo dirInfo = Directory.CreateDirectory(folderPath);
                            LLogging.WriteLog(System.Reflection.MethodInfo.GetCurrentMethod().ToString(), LLogging.LogType.SYS, "CreateDirectory result: " + dirInfo.ToString());
                        }
                        catch (System.Exception ex)
                        {
                            LLogging.WriteLog(System.Reflection.MethodInfo.GetCurrentMethod().ToString(), LLogging.LogType.SYS, "CreateDirectory result failed: " + ex);
                            ResContent             = LLanguage.SearchResourceByKey("M.ResponseMessage.QuanTriHeThong.PhienBan.TaiVeKhongThanhCong");
                            lblContent.Content     = ResContent;
                            prbProcess.Visibility  = Visibility.Collapsed;
                            btnDownload.Visibility = Visibility.Collapsed;
                            btnUpdate.Visibility   = Visibility.Collapsed;
                        }
                        LLogging.WriteLog(System.Reflection.MethodInfo.GetCurrentMethod().ToString(), LLogging.LogType.SYS, "WriteFileFromByteArray: " + filePath);
                        bool retWriteFile = LFile.WriteFileFromByteArray(phienBanDTO.ListPhienBanItemDTO.FirstOrDefault().HtPbanData.FileData, filePath);
                        LLogging.WriteLog(System.Reflection.MethodInfo.GetCurrentMethod().ToString(), LLogging.LogType.SYS, "WriteFileFromByteArray result: " + retWriteFile.ToString());
                        if (!retWriteFile)
                        {
                            ResStatus  = ApplicationConstant.ResponseStatus.KHONG_THANH_CONG;
                            ResContent = LLanguage.SearchResourceByKey("M.ResponseMessage.QuanTriHeThong.PhienBan.TaiVeKhongThanhCong");
                            Worker_Download.CancelAsync();
                        }
                        HtPban.PTHUC_CNHAT = "FULL";
                    }
                    // Nếu cập nhật phần thay đổi của ứng dụng
                    else if (phuongThucCapNhat.Equals("CHANGE"))
                    {
                        LLogging.WriteLog(System.Reflection.MethodInfo.GetCurrentMethod().ToString(), LLogging.LogType.SYS, "CHANGED_UPDATE");
                        List <PhienBanItemDTO> listPhienBanItemDTO = phienBanDTO.ListPhienBanItemDTO.ToList();
                        string folderPath = ClientInformation.OtaVersionDir + "\\" + HtPban.MA_PBAN;
                        PathFile = folderPath;

                        if (Directory.Exists(folderPath))
                        {
                            LLogging.WriteLog(System.Reflection.MethodInfo.GetCurrentMethod().ToString(), LLogging.LogType.SYS, "DeleteDirectory: " + folderPath);
                            Directory.Delete(folderPath, true);
                        }
                        LLogging.WriteLog(System.Reflection.MethodInfo.GetCurrentMethod().ToString(), LLogging.LogType.SYS, "CreateDirectory: " + folderPath);

                        try
                        {
                            DirectoryInfo dirInfo = Directory.CreateDirectory(folderPath);
                            LLogging.WriteLog(System.Reflection.MethodInfo.GetCurrentMethod().ToString(), LLogging.LogType.SYS, "CreateDirectory result: " + dirInfo.ToString());
                        }
                        catch (System.Exception ex)
                        {
                            LLogging.WriteLog(System.Reflection.MethodInfo.GetCurrentMethod().ToString(), LLogging.LogType.SYS, "CreateDirectory result failed: " + ex);
                            ResContent             = LLanguage.SearchResourceByKey("M.ResponseMessage.QuanTriHeThong.PhienBan.TaiVeKhongThanhCong");
                            lblContent.Content     = ResContent;
                            prbProcess.Visibility  = Visibility.Collapsed;
                            btnDownload.Visibility = Visibility.Collapsed;
                            btnUpdate.Visibility   = Visibility.Collapsed;
                        }

                        foreach (PhienBanItemDTO item in listPhienBanItemDTO)
                        {
                            string tenFile  = item.HtPbanFile.TEN_FILE;
                            string filePath = ClientInformation.OtaVersionDir + "\\" + HtPban.MA_PBAN + "\\" + ((item.HtPbanFile.DUONG_DAN != null && !item.HtPbanFile.DUONG_DAN.Equals("")) ? item.HtPbanFile.DUONG_DAN + "\\" : "") + tenFile;
                            LLogging.WriteLog(System.Reflection.MethodInfo.GetCurrentMethod().ToString(), LLogging.LogType.SYS, "WriteAbsFileFromByteArray: " + filePath);
                            bool retWriteFile = LFile.WriteAbsFileFromByteArray(item.HtPbanData.FileData, filePath);
                            LLogging.WriteLog(System.Reflection.MethodInfo.GetCurrentMethod().ToString(), LLogging.LogType.SYS, "WriteAbsFileFromByteArray result: " + retWriteFile.ToString());
                            if (!retWriteFile)
                            {
                                ResStatus  = ApplicationConstant.ResponseStatus.KHONG_THANH_CONG;
                                ResContent = LLanguage.SearchResourceByKey("M.ResponseMessage.QuanTriHeThong.PhienBan.TaiVeKhongThanhCong");
                                Worker_Download.CancelAsync();
                            }
                        }
                        HtPban.PTHUC_CNHAT = "CHANGE";
                    }
                    // Còn lại
                    else
                    {
                    }
                    ResContent = LLanguage.SearchResourceByKey("M.ResponseMessage.QuanTriHeThong.PhienBan.CaiDat");
                }
                else if (ret == ApplicationConstant.ResponseStatus.KHONG_THANH_CONG)
                {
                    ResContent = LLanguage.SearchResourceByKey(responseMessage);
                }
                else
                {
                    ResContent = "";
                }

                Thread.Sleep(3000);
            }
            catch (Exception ex)
            {
                ResStatus  = ApplicationConstant.ResponseStatus.KHONG_THANH_CONG;
                ResContent = LLanguage.SearchResourceByKey("M.ResponseMessage.QuanTriHeThong.PhienBan.TaiVeKhongThanhCong");
                LLogging.WriteLog(System.Reflection.MethodInfo.GetCurrentMethod().ToString(), LLogging.LogType.SYS, ex);
                Worker_Download.CancelAsync();
                // Vẫn xử lý tại client cho logout
                //Application.Current.Shutdown();
            }
        }
Exemplo n.º 12
0
        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());
                }
            }
        }
Exemplo n.º 13
0
        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;
        }