public Category(int categoryID, string name, int? parentCategoryID, string url, string imageUrl, int sortOrder, double pricePercent, double webPricePercent, string description, bool active, Slider slider = null) { _categoryID = categoryID; _name = name; _parentCategoryID = parentCategoryID; _url = url; _imageUrl = imageUrl; _sortOrder = sortOrder; _pricePercent = pricePercent; _webPricePercent = webPricePercent; _description = description; _active = active; _slider = slider; }
public Slider GetSlider(int sliderID) { Slider slider = null; using (SqlConnection objConn = new SqlConnection(WebConfigurationManager.ConnectionStrings["eshopConnectionString"].ConnectionString)) { using (SqlCommand objComm = new SqlCommand("getSlider", objConn)) { objConn.Open(); objComm.CommandType = CommandType.StoredProcedure; objComm.Parameters.Add("@sliderID", SqlDbType.Int).Value = sliderID; using (SqlDataReader reader = objComm.ExecuteReader()) { if(reader.HasRows) while (reader.Read()) { slider = new Slider(sliderID, reader.GetString(0), Common.ConvertToLocalTime(reader.GetDateTime(2)), Common.ConvertToLocalTime(reader.GetDateTime(3)), reader.GetBoolean(1)); slider.Items = getSliderItems(slider.SliderID); } } } } return slider; }
public int SaveSlider(Slider slider) { SliderDL sliderDL = new SliderDL(); return (slider.SliderID > 0) ? sliderDL.UpdateSlider(slider) : sliderDL.SaveSlider(slider); }
private void SaveSlider() { Slider slider = new Slider(); slider.SliderID = (lblSliderID.Value != null && lblSliderID.Value != string.Empty) ? int.Parse(lblSliderID.Value) : -1; slider.Name = txtName.Text; slider.Active = chkActive.Checked; slider.InsertDate = DateTime.Now.ToUniversalTime(); slider.UpdateDate = DateTime.Now.ToUniversalTime(); if (ViewState["images"] != null) { List<SliderItem> images = (List<SliderItem>)ViewState["images"]; slider.Items = new List<SliderItem>(); foreach (SliderItem item in images) slider.Items.Add(item); } SliderBL sliderBL = new SliderBL(); slider.SliderID = sliderBL.SaveSlider(slider); if (slider.SliderID > 0) { lblSliderID.Value = slider.SliderID.ToString(); //fluImage.Enabled = true; //btnImageUpload.Enabled = true; } setStatus("Slider uspešno sačuvan.", System.Drawing.Color.Green, true); }
public int UpdateSlider(Slider slider) { int status = 0; using (SqlConnection objConn = new SqlConnection(WebConfigurationManager.ConnectionStrings["eshopConnectionString"].ConnectionString)) { using (SqlCommand objComm = new SqlCommand("updateSlider", objConn)) { objConn.Open(); objComm.CommandType = CommandType.StoredProcedure; objComm.Parameters.Add("@name", SqlDbType.NVarChar, 50).Value = slider.Name; objComm.Parameters.Add("@sliderID", SqlDbType.Int).Value = slider.SliderID; objComm.Parameters.Add("@updateDate", SqlDbType.DateTime).Value = slider.UpdateDate; objComm.Parameters.Add("@active", SqlDbType.Bit).Value = slider.Active; status = objComm.ExecuteNonQuery(); foreach (SliderItem item in slider.Items) { item.SliderID = slider.SliderID; SaveSliderItem(item); } } } return 0; }
public int SaveSlider(Slider slider) { int status = 0; try { //SqlTransaction transaction = null; using (SqlConnection objConn = new SqlConnection(WebConfigurationManager.ConnectionStrings["eshopConnectionString"].ConnectionString)) { objConn.Open(); using (SqlCommand objComm = objConn.CreateCommand()) { objComm.Connection = objConn; objComm.CommandText = "saveSlider"; objComm.CommandType = CommandType.StoredProcedure; //using (SqlTransaction transaction = objConn.BeginTransaction()) //{ //objComm.Transaction = transaction; objComm.Parameters.Add("@name", SqlDbType.NVarChar, 50).Value = slider.Name; objComm.Parameters.Add("@insertDate", SqlDbType.DateTime).Value = slider.InsertDate; objComm.Parameters.Add("@active", SqlDbType.Bit).Value = slider.Active; SqlParameter sliderID = new SqlParameter("@sliderID", SqlDbType.Int); sliderID.Direction = ParameterDirection.Output; objComm.Parameters.Add(sliderID); status = objComm.ExecuteNonQuery(); slider.SliderID = int.Parse(objComm.Parameters["@sliderID"].Value.ToString()); if (slider.SliderID > 0) { if (slider.Items != null) foreach (SliderItem item in slider.Items) { item.SliderID = slider.SliderID; SaveSliderItem(item); } } //if (status > 0) //{ //objComm.CommandText = "saveSliderItem"; //for (int i = 0; i < slider.Items.Count; i++) //{ //objComm.Parameters.Clear(); //objComm.Parameters.Add("@sliderID", SqlDbType.Int).Value = sliderID; //objComm.Parameters.Add("@imageUrl", SqlDbType.NVarChar, 50).Value = slider.Items[i].ImageUrl; //status = objComm.ExecuteNonQuery(); //} //} //transaction.Commit(); //} } } } catch (SqlException ex) { } finally { } return status; }
private void SaveSlider() { Slider slider = new Slider(); slider.SliderID = (lblSliderID.Value != null && lblSliderID.Value != string.Empty) ? int.Parse(lblSliderID.Value) : -1; slider.Name = txtName.Text; slider.Active = chkActive.Checked; slider.InsertDate = DateTime.Now.ToUniversalTime(); slider.UpdateDate = DateTime.Now.ToUniversalTime(); if (ViewState["images"] != null) { int index = 0; foreach (GridViewRow row in dgvImages.Rows) { ((List<SliderItem>)ViewState["images"])[index].Url = ((TextBox)row.FindControl("txtUrl")).Text; ((List<SliderItem>)ViewState["images"])[index].SortIndex = index; index++; } List<SliderItem> images = (List<SliderItem>)ViewState["images"]; slider.Items = new List<SliderItem>(); foreach (SliderItem item in images) slider.Items.Add(item); } SliderBL sliderBL = new SliderBL(); slider.SliderID = sliderBL.SaveSlider(slider); if (slider.SliderID > 0) { lblSliderID.Value = slider.SliderID.ToString(); //fluImage.Enabled = true; //btnImageUpload.Enabled = true; } setStatus("Slider uspešno sačuvan.", System.Drawing.Color.Green, true); }