Example #1
0
    public int SaveChanges(bool IsNewRecord)
    {
        KeywordsDataContext dataContext = new KeywordsDataContext();

        Keywords ObjTable;

        if (IsNewRecord)
        {
            ObjTable = new Keywords();
            dataContext.Keywords.InsertOnSubmit(ObjTable);
        }
        else
        {
            ObjTable = dataContext.Keywords.Single(p => p.Code.Equals(this.Code));
        }
        try
        {
            #region Save changes after checking Access
            ObjTable.Code        = this.Code;
            ObjTable.Name        = Tools.PersianTextCorrection(this.Name);
            ObjTable.EngName     = this.EngName;
            ObjTable.Description = this.Description;

            #endregion

            dataContext.SubmitChanges();
        }
        catch (Exception exp)
        {
        }

        return(ObjTable.Code);
    }
Example #2
0
    public void RemoveKeywordByCode(int KeywordCode)
    {
        KeywordsDataContext dc = new KeywordsDataContext();
        var dtlEntityKeywords  = dc.EntityKeywords.Where(n => n.KeywordCode.Equals(KeywordCode));

        dc.EntityKeywords.DeleteAllOnSubmit(dtlEntityKeywords);
        dc.SubmitChanges();
    }
Example #3
0
    public int SaveChanges(bool IsNewRecord)
    {
        HttpSessionState Session = HttpContext.Current.Session;
        EntityKeywords   ObjTable;

        if (IsNewRecord)
        {
            ObjTable = new EntityKeywords();
            dataContext.EntityKeywords.InsertOnSubmit(ObjTable);
        }
        else
        {
            ObjTable = dataContext.EntityKeywords.Single(p => p.Code.Equals(this.Code));
        }
        try
        {
            #region Save Detail Controls
            PropertyInfo piMasterCode = ObjTable.GetType().GetProperty("NewsCode");
            piMasterCode.SetValue(ObjTable, MasterCode, new object[] { });

            string BaseID = this.ToString().Substring(3, this.ToString().Length - 3);
            Tools  tools  = new Tools();
            tools.AccessList = tools.GetAccessList(BaseID);
            foreach (WebControl wc in ObjectList)
            {
                string       Property     = wc.ID.Substring(3, wc.ID.Length - 3);
                PropertyInfo pi           = ObjTable.GetType().GetProperty(Property);
                string       FullPropName = BaseID + "." + Property;
                if (tools.HasAccess("Edit", BaseID + "." + Property))
                {
                    pi.SetValue(ObjTable, Tools.GetControlValue(wc), new object[] { });
                }
            }
            #endregion

            dataContext.SubmitChanges();
        }
        catch (Exception exp)
        {
            throw exp;
        }

        return(ObjTable.Code);
    }
Example #4
0
    void IBaseBOL.DeleteRecord(params string[] DelParam)
    {
        Tools tools = new Tools();

        tools.AccessList = tools.GetAccessList(BaseID);

        if (tools.HasAccess("Edit", "Keywords"))
        {
            Keywords ObjTable = dataContext.Keywords.Single(p => p.Code.Equals(DelParam[0]));
            dataContext.Keywords.DeleteOnSubmit(ObjTable);
            dataContext.SubmitChanges();
        }
    }
    public int SaveChanges(bool IsNewRecord)
    {
        GarbageWords ObjTable;

        if (IsNewRecord)
        {
            ObjTable = new GarbageWords();
            dataContext.GarbageWords.InsertOnSubmit(ObjTable);
        }
        else
        {
            ObjTable = dataContext.GarbageWords.Single(p => p.Code.Equals(this.Code));
        }
        try
        {
            #region Save Controls
            Tools tools = new Tools();
            tools.AccessList = tools.GetAccessList(BaseID);
            if (tools.HasAccess("Edit", "GarbageWords.Word"))
            {
                ObjTable.Word = this.Word;
            }
            #endregion

            if (tools.HasAccess("Edit", "GarbageWords"))
            {
                dataContext.SubmitChanges();
            }
        }
        catch (Exception exp)
        {
            throw exp;
        }

        return(ObjTable.Code);
    }
    public int SaveChanges(bool IsNewRecord)
    {
        //dataContext = new KeywordsDataContext();
        EntityKeywords ObjTable;

        if (IsNewRecord)
        {
            ObjTable = new EntityKeywords();
            dataContext.EntityKeywords.InsertOnSubmit(ObjTable);
        }
        else
        {
            ObjTable = dataContext.EntityKeywords.Single(p => p.Code.Equals(this.Code));
        }
        try
        {
            #region Save changes after checking Access
            ObjTable.KeywordCode      = this.KeywordCode;
            ObjTable.HCEntityTypeCode = this.HCEntityTypeCode;
            ObjTable.EntityCode       = this.EntityCode;
            ObjTable.Deleted          = false;

            #endregion

            //IX_EntityKeywords error. LINQ Bug ?!!
            //if(IsNewRecord)
            //    dataContext.ExecuteCommand(string.Format("Insert into EntityKeywords (KeywordCode, HCEntityTypeCode, EntityCode) values ('{0}','{1}','{2}')", KeywordCode, HCEntityTypeCode, EntityCode));
            dataContext.SubmitChanges();
        }
        catch (Exception exp)
        {
            throw exp;
        }

        return(ObjTable.Code);
    }