Ejemplo n.º 1
0
        public static object InsertTheme(ThemeVm theme)
        {
            int lang = (int)Utils.GetLanguage();
            var mr   = Mgr.GetAllThemese(Utils.LoggedUser, lang);

            return(Utils.ServiceResponse(PageCode, mr));
        }
Ejemplo n.º 2
0
        public static object Save(string themeType, string name, string unitScale, int codeNo)
        {
            var theme = new ThemeVm {
                ThemeType = themeType, Name = name, UnitScale = unitScale, CodeNo = codeNo
            };
            var mr = Mgr.Save(Utils.LoggedUser, theme, (int)Utils.GetLanguage());

            return(Utils.ServiceResponse(PageCode, mr));
        }
Ejemplo n.º 3
0
        public int Save(ThemeVm theme)

        {
            theme.Name = !string.IsNullOrEmpty(theme.Name)
                ? theme.Name
                : string.IsNullOrEmpty(theme.NameAr) ? theme.NameAr : theme.NameFr;
            theme.NameAr = !string.IsNullOrEmpty(theme.NameAr)
                ? theme.NameAr
                : !string.IsNullOrEmpty(theme.Name) ? theme.Name : theme.NameFr;
            theme.NameFr = !string.IsNullOrEmpty(theme.NameFr)
                ? theme.NameFr
                : !string.IsNullOrEmpty(theme.Name) ? theme.Name : theme.NameAr;
            theme.ThemeType = theme.ThemeType;
            theme.UnitScale = !string.IsNullOrEmpty(theme.UnitScale)
                ? theme.UnitScale
                : !string.IsNullOrEmpty(theme.UnitScaleAr) ? theme.UnitScaleAr : theme.UnitScaleFr;
            theme.UnitScaleAr = !string.IsNullOrEmpty(theme.UnitScaleAr)
                ? theme.UnitScaleAr
                : !string.IsNullOrEmpty(theme.UnitScale) ? theme.UnitScale : theme.UnitScaleFr;
            theme.UnitScaleFr = !string.IsNullOrEmpty(theme.UnitScaleFr)
                ? theme.UnitScaleFr
                : !string.IsNullOrEmpty(theme.UnitScale) ? theme.UnitScale : theme.UnitScaleAr;


            DimTheme them = new DimTheme
            {
                CodeNo      = theme.CodeNo,
                Name        = theme.Name,
                NameAr      = theme.NameAr,
                NameFr      = theme.NameFr,
                ThemeType   = theme.ThemeType,
                UnitScale   = theme.UnitScale,
                UnitScaleAr = theme.UnitScaleAr,
                UnitScaleFr = theme.UnitScaleFr
            };
            var _them = (from th in Context.DimThemes where th.Name == theme.Name && th.NameAr == theme.NameAr && th.NameFr == theme.NameFr && (th.CodeNo != theme.CodeNo || theme.CodeNo == 0) select th).FirstOrDefault();

            if (_them != null)
            {
                return(-4);
            }
            if (theme.CodeNo > 0)
            {
                _them             = (from th in Context.DimThemes where  th.CodeNo == theme.CodeNo select th).FirstOrDefault();
                _them.Name        = theme.Name;
                _them.NameAr      = theme.NameAr;
                _them.NameFr      = theme.NameFr;
                _them.UnitScale   = theme.UnitScale;
                _them.UnitScaleAr = theme.UnitScaleAr;
                _them.UnitScaleFr = theme.UnitScaleFr;
                _them.ThemeType   = theme.ThemeType;
                Context.DimThemes.Attach(_them);
                Context.Entry(_them).State = EntityState.Modified;
            }
            else
            {
                Context.DimThemes.Add(them);
            }
            int affectedRows = Context.SaveChanges();

            return(affectedRows);
        }
Ejemplo n.º 4
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            if (Utils.LoggedUser == null)
            {
                Response.Redirect("~/login");
            }


            var theme = new ThemeVm {
                ThemeType = ddlThemeType.SelectedValue, Name = txtThemeInsert.Text, NameAr = txtThemeAr.Text, NameFr = txtThemeFr.Text, UnitScale = txtUnitScale.Text, UnitScaleAr = txtUnitScaleAr.Text, UnitScaleFr = txtUnitScaleFr.Text
            };

            if (!string.IsNullOrEmpty(txthdfEdited.Text))
            {
                if (Utils.CheckPermission(3, 11, Utils.LoggedUser.Roles) < 1)
                {
                    ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alert", @" noty({
                    type: 'success',
                    text: '" + GetGlobalResourceObject("MessagesResource", "X_NotAuthorized") + @"',
                    layout: 'center', closeWith: ['click', 'backdrop'],
                    modal: true, killer: true
                });", true);
                    return;
                }
                theme.CodeNo = int.Parse(txthdfEdited.Text);
            }
            else
            {
                if (Utils.CheckPermission(2, 11, Utils.LoggedUser.Roles) < 1)
                {
                    ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alert", @" noty({
                    type: 'success',
                    text: '" + GetGlobalResourceObject("MessagesResource", "X_NotAuthorized") + @"',
                    layout: 'center', closeWith: ['click', 'backdrop'],
                    modal: true, killer: true
                });", true);
                    return;
                }
            }

            var mr = Mgr.Save(Utils.LoggedUser, theme, (int)Utils.GetLanguage());

            switch (mr.Status)
            {
            case ResponseStatus.Success:
                txthdfEdited.Text = string.Empty;
                ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alert", @" noty({
                    type: 'success',
                    text: '" + GetGlobalResourceObject("MessagesResource", "X_OperationSuccess") + @"',
                    layout: 'center', closeWith: ['click', 'backdrop'],
                    modal: true, killer: true
                });", true);
                txtThemeInsert.Text        = string.Empty;
                txtThemeAr.Text            = string.Empty;
                txtThemeFr.Text            = string.Empty;
                txtUnitScale.Text          = string.Empty;
                txtUnitScaleAr.Text        = string.Empty;
                txtUnitScaleFr.Text        = string.Empty;
                txthdfEdited.Text          = string.Empty;
                txthdfEditedtype.Text      = string.Empty;
                ddlThemeType.SelectedIndex = 0;
                MultiView1.ActiveViewIndex = 0;
                break;

            case ResponseStatus.InRelation:
                txthdfEdited.Text = string.Empty;
                ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alert", @" noty({
                    type: 'error',
                    text: '" + GetGlobalResourceObject("MessagesResource", "X_Error103_InRelation") + @"',
                    layout: 'center', closeWith: ['click', 'backdrop'],
                    modal: true, killer: true
                });", true);
                break;

            case ResponseStatus.Exist:
                txthdfEdited.Text = string.Empty;
                ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alert", @" noty({
                    type: 'error',
                    text: '" + GetGlobalResourceObject("MessagesResource", "X_Exist") + @"',
                    layout: 'center', closeWith: ['click', 'backdrop'],
                    modal: true, killer: true
                });", true);
                break;

            case ResponseStatus.Exception:
                txthdfEdited.Text = string.Empty;
                ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alert", @" noty({
                    type: 'error',
                    text: '" + GetGlobalResourceObject("MessagesResource", "X_Error102") + @"',
                    layout: 'center', closeWith: ['click', 'backdrop'],
                    modal: true, killer: true
                });", true);
                break;
            }
        }