예제 #1
0
        public void ActionAdd(ModBaoCaoDienBienSuCoEntity entity, MAppend append, string endCode)
        {
            if (entity.ID == 0)
            {
                entity = new ModBaoCaoDienBienSuCoEntity();

                // khoi tao gia tri mac dinh khi insert
                entity.MenuID = 0;
                entity.UserID = Lib.Global.CPLogin.UserID;
                DateTime d = DateTime.Now;
                entity.ChiTiet_NgayTao = d;
                entity.Activity        = CPViewPage.UserPermissions.Approve;
            }
            else
            {
                bool isValid = ValidBCDienBien(ref entity, append, endCode);
                ViewBag.BaoCao = entity;

                if (isValid == true)
                {
                    int                 userId = HL.Lib.Global.CPLogin.UserIDOnWeb;
                    string              ec     = endCode.ToLower();
                    string[]            ecArr  = ec.Split('-');
                    string              codes  = ecArr[0].ToString();
                    ModBaoCaoSuCoEntity sc     = ModBaoCaoSuCoService.Instance.CreateQuery()
                                                 .Where(userId > 0, o => o.UserID == userId)
                                                 .Where(o => o.Code == codes)
                                                 .ToSingle();
                    if (sc != null)
                    {
                        string code = "BCDBSC" + ModBaoCaoDienBienSuCoService.Instance.GetMaxID();
                        entity.Name             = code;
                        entity.Code             = Data.GetCode(code);
                        entity.UserID           = Lib.Global.CPLogin.UserIDOnWeb;
                        entity.Activity         = true;
                        entity.BaoCaoSuCoID     = sc.ID;
                        entity.ToChuc_Ten       = sc.Name;
                        entity.ToChuc_DiaChi    = sc.Address;
                        entity.ToChuc_DienThoai = sc.Phone;
                        entity.ToChuc_Email     = sc.Email;
                        int id = ModBaoCaoDienBienSuCoService.Instance.Save(entity);

                        CPViewPage.Alert("Thêm báo cáo diễn biến thành công.");
                        CPViewPage.RefreshPage();
                        //ViewPage.Navigate("/vn/Bao-cao-su-co/" + sc.Code + "-bc-dien-bien-su-co.aspx");
                    }
                }
            }

            ViewBag.Data = entity;
        }
예제 #2
0
        private bool ValidBCDienBien(ref ModBaoCaoDienBienSuCoEntity entity, MAppend append, string endCode)
        {
            if (string.IsNullOrEmpty(entity.ChiTiet_MoTa))
            {
                CPViewPage.Message.ListMessage.Add("Bạn chưa nhập Mô tả diễn biến sự cố.");
            }

            if (CPViewPage.Message.ListMessage.Count > 0)
            {
                string message = @"Thông tin còn thiếu hoặc chưa hợp lệ: \n";

                for (int i = 0; i < CPViewPage.Message.ListMessage.Count; i++)
                {
                    message += @"\n + " + CPViewPage.Message.ListMessage[i];
                }

                CPViewPage.Alert(message);
                return(false);
            }

            return(true);
        }