Beispiel #1
0
        protected void btnDelete_Click(object sender, EventArgs e)
        {
            int itemSubCatId = int.Parse(this.hdnSelectedSubCategoryID.Value.Trim());

            if (itemSubCatId > 0)
            {
                try
                {
                    using (TransactionScope ts = new TransactionScope())
                    {
                        ItemBO objSubItem = new ItemBO(this.ObjContext);
                        objSubItem.ID = itemSubCatId;
                        objSubItem.GetObject();
                        objSubItem.Delete();

                        this.ObjContext.SaveChanges();
                        ts.Complete();
                        this.PopulateDataGrid();
                    }
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
        }
Beispiel #2
0
        /// <summary>
        /// Process the page data.
        /// </summary>
        private void ProcessForm(int itemId)
        {
            try
            {
                using (TransactionScope ts = new TransactionScope())
                {
                    ItemBO objItemSubCategoryBO = new ItemBO(this.ObjContext);

                    if (itemId > 0)
                    {
                        objItemSubCategoryBO.ID = itemId;
                        objItemSubCategoryBO.GetObject();
                    }

                    objItemSubCategoryBO.Parent      = int.Parse(this.ddlItem.SelectedValue);
                    objItemSubCategoryBO.Name        = this.txtName.Text;
                    objItemSubCategoryBO.Description = this.txtDescription.Text;

                    if (itemId == 0)
                    {
                        objItemSubCategoryBO.Add();
                    }

                    this.ObjContext.SaveChanges();
                    ts.Complete();
                }
            }
            catch (Exception ex)
            {
                // Log the error
                //IndicoLogging.log("Error occured while Adding the Item", ex);
            }
        }
Beispiel #3
0
        private void DeleteItem(int item)
        {
            try
            {
                using (TransactionScope ts = new TransactionScope())
                {
                    ItemBO objItem = new ItemBO(this.ObjContext);
                    if (item > 0)
                    {
                        objItem.ID = item;
                        objItem.GetObject();

                        /*if (objItem.ItemAttributesWhereThisIsItem.Count > 0)
                         * {
                         *  foreach (ItemAttributeBO itemAttr in objItem.ItemAttributesWhereThisIsItem.ToList())
                         *  {
                         *      ItemAttributeBO objItemAttribute = new ItemAttributeBO(this.ObjContext);
                         *      objItemAttribute.ID = itemAttr.ID;
                         *      objItemAttribute.GetObject();
                         *
                         *      objItemAttribute.Delete();
                         *  }
                         *  this.ObjContext.SaveChanges();
                         * }
                         *
                         * if (objItem.ItemMeasurementGuideImagesWhereThisIsItem.Count > 0)
                         * {
                         *  foreach (ItemMeasurementGuideImageBO imgi in objItem.ItemMeasurementGuideImagesWhereThisIsItem.ToList())
                         *  {
                         *      ItemMeasurementGuideImageBO objImgi = new ItemMeasurementGuideImageBO(this.ObjContext);
                         *      objImgi.ID = imgi.ID;
                         *      objImgi.GetObject();
                         *
                         *      objImgi.Delete();
                         *  }
                         *  this.ObjContext.SaveChanges();
                         * }*/
                        objItem.Delete();
                    }

                    this.ObjContext.SaveChanges();
                    ts.Complete();
                }
            }
            catch (Exception ex)
            {
                IndicoLogging.log.Error("Error occured while Deleting the Item", ex);
            }
        }
        private void ProcessML(bool isNewML)
        {
            try
            {
                using (TransactionScope ts = new TransactionScope())
                {
                    MeasurementLocationBO objML = new MeasurementLocationBO(this.ObjContext);

                    if (!isNewML)
                    {
                        objML.ID = int.Parse(this.hdnSelectedMeasurementLocationListID.Value);
                        objML.GetObject();
                    }

                    objML.IsSend = (int.Parse(this.hdnIsSend.Value.ToString()) > 0) ? true : false;
                    objML.Name   = this.hdnName.Value.ToString();
                    objML.Key    = this.hdnKey.Value.ToString();

                    if (isNewML)
                    {
                        int itemId = int.Parse(this.ddlItem.SelectedValue.ToString());

                        ItemBO objItem = new ItemBO(this.ObjContext);
                        objItem.ID = itemId;
                        objItem.GetObject();

                        objItem.MeasurementLocationsWhereThisIsItem.Add(objML);
                    }

                    this.ObjContext.SaveChanges();
                    ts.Complete();
                }
            }
            catch (Exception ex)
            {
                IndicoLogging.log.Error("Error occured while processing Measurement Locations", ex);
            }
        }
Beispiel #5
0
        private void PopulateItem(int itemId)
        {
            if (this.IsNotRefresh)
            {
                ItemBO objItem = new ItemBO();
                objItem.ID = itemId;
                objItem.GetObject();

                this.txtItemName.Text = objItem.Name;
                this.ddlItemType.ClearSelection();
                this.ddlItemType.Items.FindByValue(objItem.ItemType.ToString()).Selected = true;
                this.txtDescription.Text = objItem.Description;
                this.PopulateItemImage(itemId);

                ViewState["IsPopulateSubItemModel"] = false;
                ViewState["IsPopulateItemModel"]    = true;
            }
            else
            {
                ViewState["IsPopulateSubItemModel"] = false;
                ViewState["IsPopulateItemModel"]    = false;
            }
        }
        protected void btnAddMeasurementLocation_Click(object sender, EventArgs e)
        {
            // Populate popup items dropdown
            this.ddlItem.Items.Clear();
            this.ddlItem.Items.Add(new ListItem("Select an Item", "0"));

            List <int> lstExistingItems = (new MeasurementLocationBO()).SearchObjects().GroupBy(o => o.Item).Select(m => m.First().Item).ToList();
            List <int> lstNewItems      = (new ItemBO()).SearchObjects().Where(o => o.Parent == 0).OrderBy(o => o.Name).Select(o => o.ID).Except(lstExistingItems).ToList();

            foreach (int item in lstNewItems)
            {
                ItemBO objItem = new ItemBO();
                objItem.ID = item;
                objItem.GetObject();

                this.ddlItem.Items.Add(new ListItem(objItem.Name, objItem.ID.ToString()));
            }

            this.dgAddEditMLs.DataSource = null;
            this.dgAddEditMLs.DataBind();

            this.hdnIsNewML.Value        = "1";
            ViewState["IsPopulateModel"] = true;
        }
Beispiel #7
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);
            }
        }