Example #1
0
        /// <summary>
        /// Insert data
        /// </summary>
        /// <param name="obj">Object of entity</param>
        /// <returns></returns>
        public object Insert(object obj)
        {
            var o = new Pol_Dictionary();
            try
            {
                o = (Pol_Dictionary)obj;

                if (Select(o.Code) != null)
                    return null; // already exists

                if (o.Id == Guid.Empty)
                    o.Id = Guid.NewGuid();

                var oki = _db.Pol_Dictionarys.Add(o);
                _db.SaveChanges();

                return oki;
            }
            catch
            {
                _db.Pol_Dictionarys.Remove(o);

                return null;
            }
        }
Example #2
0
        protected override bool UpdateObject()
        {
            try
            {
                if (!ValidInput()) return false;

                var id = (Guid)grvMain.GetFocusedRowCellValue("Id");

                var o = new Pol_Dictionary()
                {
                    Id = id,
                    Code = txtCode.Text,
                    Text = txtName.Text,
                    Note = txtDescript.Text
                };

                var oki = _bll.Pol_Dictionary.UpdateRole(o);
                if (oki == null) XtraMessageBox.Show(STR_DUPLICATE, STR_EDIT);

                return oki != null ? true : false;
            }
            catch { return false; }
        }
Example #3
0
 /// <summary>
 /// Create list of roles
 /// </summary>
 void CreateRoles()
 {
     var o = new Pol_Dictionary() { Type = Global.STR_ROLE, Code = "CV", Text = "Cổng vào", Note = "Có vai trò ở cổng vào" };
     Pol_Dictionary.Insert(o);
     o = new Pol_Dictionary() { Type = Global.STR_ROLE, Code = "CR", Text = "Cổng ra", Note = "Có vai trò ở cổng ra" };
     Pol_Dictionary.Insert(o);
     o = new Pol_Dictionary() { Type = Global.STR_ROLE, Code = "ND", Text = "Người dùng", Note = "Có vai trò cơ bản nhất" };
     Pol_Dictionary.Insert(o);
     o = new Pol_Dictionary() { Type = Global.STR_ROLE, Code = "QL", Text = "Quản lí", Note = "Có vai trò quản lí người dùng, nhóm, loại, xe" };
     Pol_Dictionary.Insert(o);
     o = new Pol_Dictionary() { Type = Global.STR_ROLE, Code = "QT", Text = "Quản trị", Note = "Có tất cả vai trò" };
     Pol_Dictionary.Insert(o);
     o = new Pol_Dictionary() { Type = Global.STR_ROLE, Code = "TK", Text = "Thống kê", Note = "Xem và in ấn các báo cáo, thống kê" };
     Pol_Dictionary.Insert(o);
 }
Example #4
0
 /// <summary>
 /// Create list region of Vietnam
 /// </summary>
 void CreateRegion()
 {
     var o = new Pol_Dictionary() { Type = Global.STR_REGION, Code = Global.STR_REGION + "_0", Text = "Miền Bắc", Order = 0 };
     Pol_Dictionary.Insert(o);
     o = new Pol_Dictionary() { Type = Global.STR_REGION, Code = Global.STR_REGION + "_1", Text = "Miền Trung", Order = 1 };
     Pol_Dictionary.Insert(o);
     o = new Pol_Dictionary() { Type = Global.STR_REGION, Code = Global.STR_REGION + "_2", Text = "Miền Nam", Order = 2 };
     Pol_Dictionary.Insert(o);
 }
Example #5
0
        /// <summary>
        /// Pol_Dictionary table
        /// </summary>
        void CreatePol_Dictionary()
        {
            if (Pol_Dictionary.Count() > 0) return;

            #region List of languages
            var o = new Pol_Dictionary() { Type = Global.STR_LANG, Code = "1", Text = "ZngIoz", Note = "Tiếng ZnG", Order = 0 };
            Pol_Dictionary.Insert(o);
            o = new Pol_Dictionary() { Type = Global.STR_LANG, Code = "2", Text = "Vietnamese", Note = "Tiếng Việt", Order = 1 };
            Pol_Dictionary.Insert(o);
            o = new Pol_Dictionary() { Type = Global.STR_LANG, Code = "3", Text = "English", Note = "Tiếng Anh", Order = 2 };
            Pol_Dictionary.Insert(o);
            #endregion

            #region List of buttons
            o = new Pol_Dictionary() { Type = Global.STR_BUTTON, Code = "Add", Text = "Thêm", Note = "Cho phép thêm dữ liệu", Order = 0 };
            Pol_Dictionary.Insert(o);
            o = new Pol_Dictionary() { Type = Global.STR_BUTTON, Code = "Edit", Text = "Sửa", Note = "Cho phép sửa dữ liệu", Order = 1 };
            Pol_Dictionary.Insert(o);
            o = new Pol_Dictionary() { Type = Global.STR_BUTTON, Code = "Delete", Text = "Xoá", Note = "Cho phép xoá dữ liệu", Order = 2 };
            Pol_Dictionary.Insert(o);
            o = new Pol_Dictionary() { Type = Global.STR_BUTTON, Code = "Default", Text = "Tự mở", Note = "Cho phép tự động hiện form", Order = 3 };
            Pol_Dictionary.Insert(o);
            o = new Pol_Dictionary() { Type = Global.STR_BUTTON, Code = "Print", Text = "In ấn", Note = "Cho phép in ấn dữ liệu", Order = 4 };
            Pol_Dictionary.Insert(o);
            o = new Pol_Dictionary() { Type = Global.STR_BUTTON, Code = "Access", Text = "Truy cập", Note = "Cho truy cập menu, form (menuz)", Order = 5 };
            Pol_Dictionary.Insert(o);
            o = new Pol_Dictionary() { Type = Global.STR_BUTTON, Code = "Full", Text = "Tất cả", Note = "Có tất cả quyền", Order = 6 };
            Pol_Dictionary.Insert(o);
            o = new Pol_Dictionary() { Type = Global.STR_BUTTON, Code = "None", Text = "Không có", Note = "Không có quyền", Order = 7 };
            Pol_Dictionary.Insert(o);
            #endregion

            CreateRoles();
            CreateRights();

            #region List of transport
            CreateRegion();
            CreateArea();
            CreateProvince();
            CreateGroup();
            #endregion
        }
Example #6
0
        /// <summary>
        /// Create list area of Vietnam
        /// </summary>
        void CreateArea()
        {
            var d = (Pol_Dictionary)Pol_Dictionary.Select(Global.STR_REGION + "_0");
            var o = new Pol_Dictionary() { Type = Global.STR_AREA, ParentId = d.Id, Code = Global.STR_AREA + "_0", Text = "ĐB. Sông Hồng", Order = 0 };
            Pol_Dictionary.Insert(o);
            o = new Pol_Dictionary() { Type = Global.STR_AREA, ParentId = d.Id, Code = Global.STR_AREA + "_1", Text = "Đông Bắc Bộ", Order = 1 };
            Pol_Dictionary.Insert(o);
            o = new Pol_Dictionary() { Type = Global.STR_AREA, ParentId = d.Id, Code = Global.STR_AREA + "_2", Text = "Tây Bắc Bộ", Order = 2 };
            Pol_Dictionary.Insert(o);

            d = (Pol_Dictionary)Pol_Dictionary.Select(Global.STR_REGION + "_1");
            o = new Pol_Dictionary() { Type = Global.STR_AREA, ParentId = d.Id, Code = Global.STR_AREA + "_3", Text = "Bắc Trung Bộ", Order = 3 };
            Pol_Dictionary.Insert(o);
            o = new Pol_Dictionary() { Type = Global.STR_AREA, ParentId = d.Id, Code = Global.STR_AREA + "_4", Text = "Nam Trung Bộ", Order = 4 };
            Pol_Dictionary.Insert(o);
            o = new Pol_Dictionary() { Type = Global.STR_AREA, ParentId = d.Id, Code = Global.STR_AREA + "_5", Text = "Tây Nguyên", Order = 5 };
            Pol_Dictionary.Insert(o);

            d = (Pol_Dictionary)Pol_Dictionary.Select(Global.STR_REGION + "_2");
            o = new Pol_Dictionary() { Type = Global.STR_AREA, ParentId = d.Id, Code = Global.STR_AREA + "_6", Text = "Đông Nam Bộ", Order = 6 };
            Pol_Dictionary.Insert(o);
            o = new Pol_Dictionary() { Type = Global.STR_AREA, ParentId = d.Id, Code = Global.STR_AREA + "_7", Text = "ĐB. Sông Cửu Long", Order = 7 };
            Pol_Dictionary.Insert(o);
        }
Example #7
0
        protected override bool InsertObject()
        {
            try
            {
                if (!ValidInput()) return false;

                var o = new Pol_Dictionary()
                {
                    Code = txtCode.Text,
                    Text = txtName.Text,
                    More = txtMore.Text,
                    ParentId = (Guid)lueParent.EditValue,
                    Note = txtDescript.Text,
                    Order = (int)calPosition.Value
                };

                var oki = _bll.Pol_Dictionary.InsertRight(o);
                if (oki == null) XtraMessageBox.Show(STR_DUPLICATE, STR_ADD);

                return oki != null ? true : false;
            }
            catch { return false; }
        }
Example #8
0
        protected override bool UpdateObject()
        {
            try
            {
                if (!ValidInput()) return false;

                var id = (Guid)grvMain.GetFocusedRowCellValue("Id");

                var o = new Pol_Dictionary()
                {
                    Id = id,
                    Text = txtText.Text,
                    Note = txtNote.Text,
                    Type = lokList.EditValue + ""
                };

                var gui = new Guid();
                var ok = Guid.TryParse(lokBelong.EditValue + "", out gui);
                if (ok) o.ParentId = gui;

                var oki = _bll.Pol_Dictionary.Update(o);
                if (oki == null) XtraMessageBox.Show(STR_DUPLICATE, STR_EDIT);

                return oki != null ? true : false;
            }
            catch { return false; }
        }
Example #9
0
 /// <summary>
 /// Insert region
 /// </summary>
 /// <param name="o"></param>
 /// <returns></returns>
 public object InsertRegion(Pol_Dictionary o)
 {
     o.Type = Global.STR_REGION;
     return Insert(o);
 }
Example #10
0
 /// <summary>
 /// Insert province
 /// </summary>
 /// <param name="o"></param>
 /// <returns></returns>
 public object InsertProvince(Pol_Dictionary o)
 {
     o.Type = Global.STR_PROVINCE;
     return Insert(o);
 }
Example #11
0
 /// <summary>
 /// Insert language
 /// </summary>
 /// <param name="o"></param>
 /// <returns></returns>
 public object InsertLang(Pol_Dictionary o)
 {
     o.Type = Global.STR_LANG;
     return Insert(o);
 }
Example #12
0
 /// <summary>
 /// Insert button
 /// </summary>
 /// <param name="o"></param>
 /// <returns></returns>
 public object InsertButton(Pol_Dictionary o)
 {
     o.Type = Global.STR_BUTTON;
     return Insert(o);
 }
Example #13
0
 /// <summary>
 /// Insert area
 /// </summary>
 /// <param name="o"></param>
 /// <returns></returns>
 public object InsertArea(Pol_Dictionary o)
 {
     o.Type = Global.STR_AREA;
     return Insert(o);
 }
Example #14
0
        protected override bool UpdateObject()
        {
            try
            {
                if (!ValidInput()) return false;

                var id = (Guid)grvMain.GetFocusedRowCellValue("Id");

                var o = new Pol_Dictionary()
                {
                    Id = id,
                    Type = Global.STR_SHIFT,
                    Code = txtCode.Text,
                    Text = txtName.Text,
                    More2 = calValue.Value.ToString("#"),
                    Text1 = txtText1.Text,
                    Note = txtDescript.Text
                };

                var s = tedStart.Time.ToString("HH:mm:ss");
                var e = tedEnd.Time.ToString("HH:mm:ss");
                if (s != "00:00:00") o.More = s;
                if (e != "00:00:00") o.More1 = e;

                var oki = _bll.Pol_Dictionary.Update(o);
                if (oki == null) XtraMessageBox.Show(STR_DUPLICATE, STR_EDIT);

                return oki != null ? true : false;
            }
            catch { return false; }
        }
Example #15
0
        protected override bool InsertObject()
        {
            try
            {
                if (!ValidInput()) return false;

                var o = new Pol_Dictionary()
                {
                    Type = Global.STR_SHIFT,
                    Code = txtCode.Text,
                    Text = txtName.Text,
                    More2 = calValue.Value.ToString("#"),
                    Text1 = txtText1.Text,
                    Note = txtDescript.Text
                };

                var s = tedStart.Time.ToString("HH:mm:ss");
                var e = tedEnd.Time.ToString("HH:mm:ss");
                if (s != "00:00:00") o.More = s;
                if (e != "00:00:00") o.More1 = e;

                var oki = _bll.Pol_Dictionary.Insert(o);
                if (oki == null) XtraMessageBox.Show(STR_DUPLICATE, STR_ADD);

                return oki != null ? true : false;
            }
            catch { return false; }
        }
Example #16
0
 /// <summary>
 /// Update kind of data
 /// </summary>
 /// <param name="o"></param>
 /// <returns></returns>
 public object UpdateRoot(Pol_Dictionary o)
 {
     o.Type = Global.STR_ROOT;
     return Update(o);
 }
Example #17
0
        protected override bool InsertObject()
        {
            try
            {
                if (!ValidInput()) return false;

                var o = new Pol_Dictionary()
                {
                    Text = txtText.Text,
                    Note = txtNote.Text,
                    Type = lokList.EditValue + ""
                };

                var gui = new Guid();
                var ok = Guid.TryParse(lokBelong.EditValue + "", out gui);
                if (ok) o.ParentId = gui;

                var oki = _bll.Pol_Dictionary.Insert(o);
                if (oki == null) XtraMessageBox.Show(STR_DUPLICATE, STR_ADD);

                return oki != null ? true : false;
            }
            catch { return false; }
        }
Example #18
0
 /// <summary>
 /// Insert right
 /// </summary>
 /// <param name="o"></param>
 /// <returns></returns>
 public object InsertRight(Pol_Dictionary o)
 {
     o.Type = Global.STR_RIGHT;
     return Insert(o);
 }
Example #19
0
        protected override bool UpdateObject()
        {
            try
            {
                if (!ValidInput()) return false;

                var id = (Guid)grvMain.GetFocusedRowCellValue("Id");
                var c = cbbDays.EditValue + "|" + lueTransport.EditValue + "|" + lueRoute.EditValue;

                var o = new Pol_Dictionary()
                {
                    Id = id,
                    ParentId = (Guid)lueTransport.EditValue,
                    Code = c,
                    Text = lueRoute.Text,
                    More = lueRoute.EditValue + "",
                    More3 = cbbDays.EditValue + "",
                    Order = calNode.Value.ToInt32(),
                    Type = Global.STR_NODE
                };

                var gui = new Guid();
                var ok = Guid.TryParse(lueTransport.EditValue + "", out gui);
                if (ok) o.ParentId = gui;

                var oki = _bll.Pol_Dictionary.Update(o);
                if (oki == null) XtraMessageBox.Show(STR_DUPLICATE, STR_EDIT);

                return oki != null ? true : false;
            }
            catch { return false; }
        }
Example #20
0
 /// <summary>
 /// Insert kind of data
 /// </summary>
 /// <param name="o"></param>
 /// <returns></returns>
 public object InsertRoot(Pol_Dictionary o)
 {
     o.Type = Global.STR_ROOT;
     return Insert(o);
 }
Example #21
0
        protected override bool UpdateObject()
        {
            try
            {
                if (!ValidInput()) return false;

                var id = (Guid)grvMain.GetFocusedRowCellValue("Id");

                var o = new Pol_Dictionary()
                {
                    Id = id,
                    Code = txtCode.Text,
                    Text = txtName.Text,
                    More = txtMore.Text,
                    Note = txtDescript.Text,
                    Order = (int)calPosition.Value
                };

                var parent = lueParent.EditValue + "";
                if (parent != "") o.ParentId = (Guid)lueParent.EditValue;

                var oki = _bll.Pol_Dictionary.UpdateRight(o);
                if (oki == null) XtraMessageBox.Show(STR_DUPLICATE, STR_EDIT);

                return oki != null ? true : false;
            }
            catch { return false; }
        }
Example #22
0
 /// <summary>
 /// Insert station
 /// </summary>
 /// <param name="o"></param>
 /// <returns></returns>
 public object InsertStation(Pol_Dictionary o)
 {
     o.Type = Global.STR_STATION;
     return Insert(o);
 }
Example #23
0
 /// <summary>
 /// Create list group of vehicle
 /// </summary>
 void CreateGroup()
 {
     var o = new Pol_Dictionary() { Type = Global.STR_GROUP, Code = "A", Text = "Xe tải lưu đậu & vãng lai", Note = "", Order = 0 };
     Pol_Dictionary.Insert(o);
     o = new Pol_Dictionary() { Type = Global.STR_GROUP, Code = "B", Text = "Xe khách lưu đậu ngày", Note = "Cứ 24 giờ tính 01 ngày", Order = 1 };
     Pol_Dictionary.Insert(o);
     o = new Pol_Dictionary() { Type = Global.STR_GROUP, Code = "C", Text = "Taxi vãng lai", Note = "", Order = 2 };
     Pol_Dictionary.Insert(o);
     o = new Pol_Dictionary() { Type = Global.STR_GROUP, Code = "D", Text = "Xe ba bánh", Note = "", Order = 3 };
     Pol_Dictionary.Insert(o);
     o = new Pol_Dictionary() { Type = Global.STR_GROUP, Code = "E", Text = "Xe khách vãng lai, quá cảnh, trung chuyển", Note = "Trong vòng 60 phút", Order = 4 };
     Pol_Dictionary.Insert(o);
 }
Example #24
0
 /// <summary>
 /// Insert transport
 /// </summary>
 /// <param name="o"></param>
 /// <returns></returns>
 public object InsertTransport(Pol_Dictionary o)
 {
     o.Type = Global.STR_TRANSPORT;
     return Insert(o);
 }
Example #25
0
 /// <summary>
 /// Create list province of Vietnam
 /// </summary>
 void CreateProvince()
 {
     var d = (Pol_Dictionary)Pol_Dictionary.Select(Global.STR_AREA + "_0");
     var o = new Pol_Dictionary() { Type = Global.STR_PROVINCE, ParentId = d.Id, Code = Global.STR_PROVINCE + "_0", Text = "Hà Nội (cũ)", Order = 0 };
     Pol_Dictionary.Insert(o);
     o = new Pol_Dictionary() { Type = Global.STR_PROVINCE, ParentId = d.Id, Code = Global.STR_PROVINCE + "_1", Text = "Hà Nam", Order = 1 };
     Pol_Dictionary.Insert(o);
     o = new Pol_Dictionary() { Type = Global.STR_PROVINCE, ParentId = d.Id, Code = Global.STR_PROVINCE + "_2", Text = "Hà Nội (mở rộng)", Order = 2 };
     Pol_Dictionary.Insert(o);
     o = new Pol_Dictionary() { Type = Global.STR_PROVINCE, ParentId = d.Id, Code = Global.STR_PROVINCE + "_3", Text = "", Order = 3 };
     Pol_Dictionary.Insert(o);
     o = new Pol_Dictionary() { Type = Global.STR_PROVINCE, ParentId = d.Id, Code = Global.STR_PROVINCE + "_4", Text = "", Order = 4 };
     Pol_Dictionary.Insert(o);
     o = new Pol_Dictionary() { Type = Global.STR_PROVINCE, ParentId = d.Id, Code = Global.STR_PROVINCE + "_5", Text = "", Order = 5 };
     Pol_Dictionary.Insert(o);
     o = new Pol_Dictionary() { Type = Global.STR_PROVINCE, ParentId = d.Id, Code = Global.STR_PROVINCE + "_6", Text = "", Order = 6 };
     Pol_Dictionary.Insert(o);
 }
Example #26
0
 /// <summary>
 /// Update button
 /// </summary>
 /// <param name="o"></param>
 /// <returns></returns>
 public object UpdateButton(Pol_Dictionary o)
 {
     o.Type = Global.STR_BUTTON;
     return Update(o);
 }
Example #27
0
        /// <summary>
        /// Create list of rights
        /// </summary>
        void CreateRights()
        {
            var a = new Services();
            var b = a.GetPlugins();
            var c = Services.GetMenu(b);
            var l1 = typeof(Home.Level1).Name;
            var l2 = typeof(Home.Sytem.Level2).Name;
            var d1 = new Pol_Dictionary();
            var d2 = new Pol_Dictionary();

            foreach (var i in c)
            {
                if (i.Code.Contains(l1)) // level 1
                {
                    d1 = new Pol_Dictionary() { Type = Global.STR_RIGHT, Code = i.Code, Text = i.Text, Order = i.Order, Show = i.Show };
                    d1 = (Pol_Dictionary)Pol_Dictionary.Insert(d1);
                }
                else if (i.Code.Contains(l2)) // level 2
                {
                    d2 = new Pol_Dictionary() { Type = Global.STR_RIGHT, ParentId = d1.Id, Code = i.Code, Text = i.Text, Order = i.Order, Show = i.Show };
                    d2 = (Pol_Dictionary)Pol_Dictionary.Insert(d2);
                }
                else // level 3
                {
                    var d3 = new Pol_Dictionary() { Type = Global.STR_RIGHT, ParentId = d2.Id, Code = i.Code, Text = i.Text, Order = i.Order, Show = i.Show };
                    d3 = (Pol_Dictionary)Pol_Dictionary.Insert(d3);
                }
            }
        }
Example #28
0
 /// <summary>
 /// Update language
 /// </summary>
 /// <param name="o"></param>
 /// <returns></returns>
 public object UpdateLang(Pol_Dictionary o)
 {
     o.Type = Global.STR_LANG;
     return Update(o);
 }
Example #29
0
 /// <summary>
 /// Update right
 /// </summary>
 /// <param name="o"></param>
 /// <returns></returns>
 public object UpdateRight(Pol_Dictionary o)
 {
     o.Type = Global.STR_RIGHT;
     return Update(o);
 }
Example #30
0
        protected override bool InsertObject()
        {
            try
            {
                if (!ValidInput()) return false;

                var o = new Pol_Dictionary()
                {
                    Code = txtCode.Text,
                    Text = txtName.Text,
                    Note = txtDescript.Text
                };

                var oki = _bll.Pol_Dictionary.InsertRole(o);
                if (oki == null) XtraMessageBox.Show(STR_DUPLICATE, STR_ADD);

                return oki != null ? true : false;
            }
            catch { return false; }
        }