Ejemplo n.º 1
0
        protected void btnDeleteItemImg_Click(object sender, EventArgs e)
        {
            if (this.IsNotRefresh)
            {
                int imageID = int.Parse(this.hdnEditMode.Value);
                // int itemID = int.Parse(this.hdnSelectedID.Value);
                try
                {
                    using (TransactionScope ts = new TransactionScope())
                    {
                        ItemMeasurementGuideImageBO objItemMeasureGuide = new ItemMeasurementGuideImageBO(this.ObjContext);
                        objItemMeasureGuide.ID = imageID;
                        objItemMeasureGuide.GetObject();
                        objItemMeasureGuide.Delete();

                        this.ObjContext.SaveChanges();
                        ts.Complete();
                    }
                    string filePath = IndicoConfiguration.AppConfiguration.PathToDataFolder + "\\ItemMeasurementGuideImages\\" + ViewState["ItemID"].ToString();
                    if (Directory.Exists(filePath))
                    {
                        Directory.Delete(filePath, true);
                    }
                    this.PopulateItemImage(int.Parse(ViewState["ItemID"].ToString()));
                }
                catch (Exception ex)
                {
                    IndicoLogging.log.Error("Error occured while Deleting the Item Image", ex);
                }
                ViewState["IsPageValied"] = true;
            }
            else
            {
                ViewState["IsPageValied"] = true;
            }
            this.PopulateDataGrid();
        }
Ejemplo n.º 2
0
        protected void RadGridItems_ItemDataBound(object sender, GridItemEventArgs e)
        {
            if (e.Item is GridDataItem)
            {
                var item = e.Item as GridDataItem;

                if (item.ItemIndex > -1 && item.DataItem is ItemBO)
                {
                    ItemBO objItem = (ItemBO)item.DataItem;

                    LinkButton linkEdit = (LinkButton)item.FindControl("linkEdit");
                    linkEdit.Attributes.Add("qid", objItem.ID.ToString());

                    LinkButton linkEditSubItem = (LinkButton)item.FindControl("linkEditSubItem");
                    linkEditSubItem.Visible = false;
                    if (objItem.Parent == 0)
                    {
                        linkEditSubItem.Attributes.Add("qid", objItem.ID.ToString());
                        linkEditSubItem.Visible = true;
                    }

                    HyperLink linkDelete = (HyperLink)item.FindControl("linkDelete");
                    linkDelete.Attributes.Add("qid", objItem.ID.ToString());

                    if (objItem.ItemAttributesWhereThisIsItem.Count > 0 || objItem.ItemsWhereThisIsParent.Count > 0 ||
                        objItem.ItemMeasurementGuideImagesWhereThisIsItem.Count > 0 || objItem.MeasurementLocationsWhereThisIsItem.Count > 0)
                    {
                        linkDelete.Visible = false;
                    }

                    HtmlAnchor         ancTemplateItemImage = (HtmlAnchor)item.FindControl("ancTemplateItemImage");
                    HtmlGenericControl iitemImage           = (HtmlGenericControl)item.FindControl("iitemImage");
                    Literal            litType = (Literal)item.FindControl("litType");

                    if ((objItem.ItemType ?? 0) > 0)
                    {
                        litType.Text = objItem.objItemType.Name;
                    }

                    if (objItem.ItemMeasurementGuideImagesWhereThisIsItem.Count > 0)
                    {
                        ItemMeasurementGuideImageBO objItemMeasurementGuide = objItem.ItemMeasurementGuideImagesWhereThisIsItem[0];

                        ancTemplateItemImage.HRef = IndicoConfiguration.AppConfiguration.DataFolderName + "/ItemMeasurementGuideImages/" + objItem.ID.ToString() + "/" + objItemMeasurementGuide.Filename + objItemMeasurementGuide.Extension;
                        if (!File.Exists(Server.MapPath(ancTemplateItemImage.HRef)))
                        {
                            ancTemplateItemImage.HRef = IndicoConfiguration.AppConfiguration.DataFolderName + "/ItemMeasurementGuideImages/noimage-png-350px-350px.gif";
                        }

                        /* else
                         * {
                         *   ancTemplateItemImage.Title = "Item Image Not Found";
                         *   iitemImage.Attributes.Add("class", "icon-eye-close");
                         *   ancTemplateItemImage.Attributes.Add("NoImage", "true");
                         * }*/

                        ancTemplateItemImage.Attributes.Add("class", "btn-link preview");
                        iitemImage.Attributes.Add("class", "icon-eye-open");

                        List <float> lstVLImageDimensions = (new ImageProcess()).GetResizedImageDimension(885, 630, 442, 315);
                        if (lstVLImageDimensions.Count > 0)
                        {
                            ancTemplateItemImage.Attributes.Add("height", lstVLImageDimensions[0].ToString());
                            ancTemplateItemImage.Attributes.Add("width", lstVLImageDimensions[1].ToString());
                            ancTemplateItemImage.Attributes.Add("NoImage", "false");
                        }
                    }
                    else
                    {
                        ancTemplateItemImage.Title = "Item Image Not Found";
                        iitemImage.Attributes.Add("class", "icon-eye-close");
                        ancTemplateItemImage.Attributes.Add("NoImage", "true");
                    }
                }
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Process the page data.
        /// </summary>
        ///

        /*private void ProcessForm(int queryId, bool isDelete)
         * {
         *  try
         *  {
         *      using (TransactionScope ts = new TransactionScope())
         *      {
         *          ItemBO objItem = new ItemBO(this.ObjContext);
         *          if (queryId > 0)
         *          {
         *              objItem.ID = queryId;
         *              objItem.GetObject();
         *          }
         *
         *          if (isDelete)
         *          {
         *              objItem.Delete();
         *          }
         *          else
         *          {
         *              objItem.Name = this.txtItemName.Text;
         *              objItem.Description = this.txtDescription.Text;
         *              objItem.Parent = int.Parse(this.ddlParentAttribute.SelectedItem.Value);
         *              if (queryId == 0)
         *              {
         *                  objItem.Add();
         *              }
         *          }
         *
         #region ItemMeasurementGuideImages
         *
         *          if (this.hdnItemImage.Value != "0")
         *          {
         *              try
         *              {
         *                  int n = 0;
         *
         *                  foreach (string fileName in this.hdnItemImage.Value.Split('|').Select(o => o.Split(',')[0]))
         *                  {
         *                      if (fileName != string.Empty)
         *                      {
         *                          n++;
         *                          ItemMeasurementGuideImageBO objItemMeasurementImage = new ItemMeasurementGuideImageBO(this.ObjContext);
         *                          objItemMeasurementImage.Size = (int)(new FileInfo(IndicoConfiguration.AppConfiguration.PathToDataFolder + "\\temp\\" + fileName)).Length;
         *                          objItemMeasurementImage.Filename = Path.GetFileNameWithoutExtension(fileName);
         *                          objItemMeasurementImage.Extension = Path.GetExtension(fileName);
         *                          objItem.ItemMeasurementGuideImagesWhereThisIsItem.Add(objItemMeasurementImage);
         *                      }
         *                  }
         *              }
         *              catch (Exception ex)
         *              {
         *                  IndicoLogging.log.Error("Error occured while saving ItemMeasureMentGuideImage", ex);
         *              }
         *          }
         *
         #endregion
         *
         *          this.ObjContext.SaveChanges();
         *          ts.Complete();
         *
         #region Copy ItemMeasureMentGuideImage
         *
         *          string sourceFileLocation = string.Empty;
         *          string destinationFolderPath = IndicoConfiguration.AppConfiguration.PathToDataFolder + "\\ItemMeasurementGuideImages\\" + objItem.ID.ToString();
         *
         *          foreach (string fileName in this.hdnItemImage.Value.Split('|').Select(o => o.Split(',')[0]))
         *          {
         *              sourceFileLocation = IndicoConfiguration.AppConfiguration.PathToDataFolder + "\\temp\\" + fileName;
         *
         *              if (fileName != string.Empty)
         *              {
         *                  if (File.Exists(destinationFolderPath + "\\" + fileName))
         *                  {
         *                      File.Delete(destinationFolderPath + "\\" + fileName);
         *                  }
         *                  else
         *                  {
         *                      if (!Directory.Exists(destinationFolderPath))
         *                          Directory.CreateDirectory(destinationFolderPath);
         *                      File.Copy(sourceFileLocation, destinationFolderPath + "\\" + fileName);
         *                  }
         *              }
         *          }
         *
         #endregion
         *      }
         *  }
         *  catch (Exception ex)
         *  {
         *      // Log the error
         *      //IndicoLogging.log("Error occured while Adding the Item", ex);
         *  }
         * }*/

        private void ProcessItems(bool isNewItem, bool isSubItem)
        {
            try
            {
                using (TransactionScope ts = new TransactionScope())
                {
                    ItemBO objItem = new ItemBO(this.ObjContext);

                    if (!isNewItem)
                    {
                        objItem.ID = int.Parse(this.hdnSelectedItemID.Value);
                        objItem.GetObject();
                    }
                    if (isSubItem)
                    {
                        objItem.Parent = int.Parse(this.ddlParentAttribute.SelectedValue);
                    }
                    else
                    {
                        #region ItemMeasurementGuideImages

                        if (this.hdnItemImage.Value != "0")
                        {
                            try
                            {
                                int n = 0;

                                foreach (string fileName in this.hdnItemImage.Value.Split('|').Select(o => o.Split(',')[0]))
                                {
                                    if (fileName != string.Empty)
                                    {
                                        n++;
                                        ItemMeasurementGuideImageBO objItemMeasurementImage = new ItemMeasurementGuideImageBO(this.ObjContext);
                                        objItemMeasurementImage.Size      = (int)(new FileInfo(IndicoConfiguration.AppConfiguration.PathToDataFolder + "\\temp\\" + fileName)).Length;
                                        objItemMeasurementImage.Filename  = Path.GetFileNameWithoutExtension(fileName);
                                        objItemMeasurementImage.Extension = Path.GetExtension(fileName);
                                        objItem.ItemMeasurementGuideImagesWhereThisIsItem.Add(objItemMeasurementImage);
                                    }
                                }
                            }
                            catch (Exception ex)
                            {
                                IndicoLogging.log.Error("Error occured while saving ItemMeasureMentGuideImage", ex);
                            }
                        }

                        #endregion
                    }

                    objItem.Name        = (!isSubItem) ? this.txtItemName.Text : this.hdnSubItemName.Value.ToString();
                    objItem.ItemType    = int.Parse(this.ddlItemType.SelectedValue);
                    objItem.Description = (!isSubItem) ? this.txtDescription.Text : this.hdnSubItemDescription.Value.ToString();
                    if (isNewItem)
                    {
                        objItem.Add();
                    }

                    this.ObjContext.SaveChanges();
                    ts.Complete();

                    #region Copy ItemMeasureMentGuideImage

                    if (!isSubItem)
                    {
                        string sourceFileLocation    = string.Empty;
                        string destinationFolderPath = IndicoConfiguration.AppConfiguration.PathToDataFolder + "\\ItemMeasurementGuideImages\\" + objItem.ID.ToString();

                        foreach (string fileName in this.hdnItemImage.Value.Split('|').Select(o => o.Split(',')[0]))
                        {
                            sourceFileLocation = IndicoConfiguration.AppConfiguration.PathToDataFolder + "\\temp\\" + fileName;

                            if (fileName != string.Empty)
                            {
                                if (File.Exists(destinationFolderPath + "\\" + fileName))
                                {
                                    File.Delete(destinationFolderPath + "\\" + fileName);
                                }
                                else
                                {
                                    if (!Directory.Exists(destinationFolderPath))
                                    {
                                        Directory.CreateDirectory(destinationFolderPath);
                                    }
                                    File.Copy(sourceFileLocation, destinationFolderPath + "\\" + fileName);
                                }
                            }
                        }
                    }

                    #endregion
                }
            }
            catch (Exception ex)
            {
                IndicoLogging.log.Error("Error occured while processing Item", ex);
            }
        }