示例#1
0
        public virtual int Add(CaseStudy item)
        {
            int newID = 0;
            using (StoredProcedure sp = new StoredProcedure("CaseStudies_AddItem"))
            {
                sp.Params.Add("@GroupID", System.Data.SqlDbType.Int).Value = item.GroupID;
                sp.Params.Add("@LangCode", System.Data.SqlDbType.NChar).Value = item.LangCode;
                sp.Params.Add("@Title", System.Data.SqlDbType.NVarChar,255).Value = item.Title;
                sp.Params.Add("@ImageFile", System.Data.SqlDbType.VarBinary).Value = item.ImageFile;
                sp.Params.Add("@Notice", System.Data.SqlDbType.NVarChar, 1024).Value = item.Notice;
                sp.Params.Add("@Text", System.Data.SqlDbType.NVarChar).Value = item.Text;

                sp.Params.Add("@LinkUrl", System.Data.SqlDbType.NVarChar, 255).Value = Tools.FixUrl(item.LinkUrl);
                sp.Params.Add("@LinkText", System.Data.SqlDbType.NVarChar, 255).Value = item.LinkText;
                sp.Params.Add("@Link2Url", System.Data.SqlDbType.NVarChar, 255).Value = Tools.FixUrl(item.Link2Url);
                sp.Params.Add("@Link2Text", System.Data.SqlDbType.NVarChar, 255).Value = item.Link2Text;
                sp.Params.Add("@ImagePosition", System.Data.SqlDbType.Int).Value = item.ImagePosition;

                sp.Params.Add("@IsActive", System.Data.SqlDbType.Bit).Value = item.IsActive;
                sp.Params.Add("@Date", System.Data.SqlDbType.DateTime).Value = item.Date;

                sp.Params.Add("@OrderNumber", System.Data.SqlDbType.Int).Value = item.OrderNumber;

                newID = Convert.ToInt32(sp.ExecuteScalar());
            }
            return newID;
        }
示例#2
0
        public bool DeleteGroup(CaseStudy item)
        {
            bool result = false;
            using (StoredProcedure sp = new StoredProcedure("CaseStudies_DeleteGroup"))
            {
                sp.Params.Add("@GroupID", System.Data.SqlDbType.Int).Value = item.GroupID;

                result = sp.ExecuteNonQuery() > 0;
            }
            return result;
        }
示例#3
0
        public virtual List<CaseStudy> GetAll(string language)
        {
            List<CaseStudy> all = new List<CaseStudy>();
            using (StoredProcedure sp = new StoredProcedure("CaseStudies_GetAll"))
            {
                using (SqlDataReader r = (SqlDataReader)sp.ExecuteReader())
                {
                    if (r != null)
                    {
                        while (r.Read())
                        {
                            CaseStudy item = new CaseStudy();

                            item.ID = Convert.ToInt32(r["ID"]);
                            item.GroupID = Convert.ToInt32(r["GroupID"]);
                            item.LangCode = Convert.ToString(r["LangCode"]);
                            item.Title = Convert.ToString(r["Title"]);
                            item.Notice = Convert.ToString(r["Notice"]);
                            item.Text = Convert.ToString(r["Text"]);
                            item.LinkUrl = Convert.ToString(r["LinkUrl"]);
                            item.LinkText = Convert.ToString(r["LinkText"]);
                            item.Link2Url = Convert.ToString(r["Link2Url"]);
                            item.Link2Text = Convert.ToString(r["Link2Text"]);
                            item.OrderNumber = Convert.ToInt32(r["OrderNumber"]);
                            item.IsActive = Convert.ToBoolean(r["IsActive"]);
                            item.ImagePosition = Convert.ToInt32(r["ImagePosition"]);
                            item.Date = NullableConverter.ToDateTime(r["Date"]);
                            item.DateCreated = Convert.ToDateTime(r["DateCreated"]);

                            all.Add(item);
                        }
                    }
                }
            }
            return all;
        }
示例#4
0
        public virtual bool Update(CaseStudy item)
        {
            bool result = false;
            using (StoredProcedure sp = new StoredProcedure("CaseStudies_UpdateItem"))
            {
                sp.Params.Add("@GroupID", System.Data.SqlDbType.Int).Value = item.GroupID;
                sp.Params.Add("@LangCode", System.Data.SqlDbType.NChar).Value = item.LangCode;
                sp.Params.Add("@Title", System.Data.SqlDbType.NVarChar, 255).Value = item.Title;

                sp.Params.Add("@Notice", System.Data.SqlDbType.NVarChar, 1024).Value = item.Notice;
                sp.Params.Add("@Text", System.Data.SqlDbType.NVarChar).Value = item.Text;

                sp.Params.Add("@LinkUrl", System.Data.SqlDbType.NVarChar, 255).Value = Tools.FixUrl(item.LinkUrl);
                sp.Params.Add("@LinkText", System.Data.SqlDbType.NVarChar, 255).Value = item.LinkText;
                sp.Params.Add("@Link2Url", System.Data.SqlDbType.NVarChar, 255).Value = Tools.FixUrl(item.Link2Url);
                sp.Params.Add("@Link2Text", System.Data.SqlDbType.NVarChar, 255).Value = item.Link2Text;
                sp.Params.Add("@ImagePosition", System.Data.SqlDbType.Int).Value = item.ImagePosition;

                sp.Params.Add("@IsActive", System.Data.SqlDbType.Bit).Value = item.IsActive;
                sp.Params.Add("@Date", System.Data.SqlDbType.DateTime).Value = item.Date;

                result = sp.ExecuteNonQuery() > 0;
            }
            return result;
        }
示例#5
0
        public virtual CaseStudy GetByLangGroup(string language, int groupId)
        {
            CaseStudy item = null;
            using (StoredProcedure sp = new StoredProcedure("CaseStudies_GetByLangGroup"))
            {
                sp.Params.Add("@GroupID", System.Data.SqlDbType.Int).Value = groupId;
                sp.Params.Add("@LangCode", System.Data.SqlDbType.NChar).Value = language;
                using (SqlDataReader r = (SqlDataReader)sp.ExecuteReader())
                {
                    if (r != null && r.Read())
                    {
                        item = new CaseStudy();

                        item.ID = Convert.ToInt32(r["ID"]);
                        item.GroupID = Convert.ToInt32(r["GroupID"]);
                        item.LangCode = Convert.ToString(r["LangCode"]);
                        item.Title = Convert.ToString(r["Title"]);
                        item.Notice = Convert.ToString(r["Notice"]);
                        item.Text = Convert.ToString(r["Text"]);
                        item.LinkUrl = Convert.ToString(r["LinkUrl"]);
                        item.LinkText = Convert.ToString(r["LinkText"]);
                        item.Link2Url = Convert.ToString(r["Link2Url"]);
                        item.Link2Text = Convert.ToString(r["Link2Text"]);
                        item.OrderNumber = Convert.ToInt32(r["OrderNumber"]);
                        item.HasImage = Convert.ToBoolean(r["HasImage"]);
                        item.IsActive = Convert.ToBoolean(r["IsActive"]);
                        item.ImagePosition = Convert.ToInt32(r["ImagePosition"]);
                        item.OrderNumber = Convert.ToInt32(r["OrderNumber"]);
                        item.Date = NullableConverter.ToDateTime(r["Date"]);
                        item.DateCreated = Convert.ToDateTime(r["DateCreated"]);
                    }
                }
            }
            return item;
        }
示例#6
0
        public virtual List<CaseStudy> GetByLangForSection(string langCode, int sectionID)
        {
            List<CaseStudy> all = new List<CaseStudy>();
            using (StoredProcedure sp = new StoredProcedure("CaseStudies_GetByLangForSection"))
            {
                sp.Params.Add("@SectionID", System.Data.SqlDbType.Int).Value = sectionID;
                sp.Params.Add("@LangCode", System.Data.SqlDbType.NChar).Value = langCode;

                using (SqlDataReader r = (SqlDataReader)sp.ExecuteReader())
                {
                    if (r != null)
                    {
                        while (r.Read())
                        {
                            CaseStudy item = new CaseStudy();

                            item.ID = Convert.ToInt32(r["ID"]);
                            item.GroupID = Convert.ToInt32(r["GroupID"]);
                            item.LangCode = Convert.ToString(r["LangCode"]);
                            item.Title = Convert.ToString(r["Title"]);
                            item.Notice = Convert.ToString(r["Notice"]);
                            item.Text = Convert.ToString(r["Text"]);
                            item.LinkUrl = Convert.ToString(r["LinkUrl"]);
                            item.LinkText = Convert.ToString(r["LinkText"]);
                            item.Link2Url = Convert.ToString(r["Link2Url"]);
                            item.Link2Text = Convert.ToString(r["Link2Text"]);
                            item.OrderNumber = Convert.ToInt32(r["OrderNumber"]);
                            item.IsActive = Convert.ToBoolean(r["IsActive"]);
                            item.ImagePosition = Convert.ToInt32(r["ImagePosition"]);
                            item.Date = NullableConverter.ToDateTime(r["Date"]);
                            item.DateCreated = Convert.ToDateTime(r["DateCreated"]);

                            all.Add(item);
                        }
                    }
                }
            }
            return all;
        }