protected void lvMapCategoryList_ItemCommand(object sender, ListViewCommandEventArgs e)
 {
     if (e.CommandName == "EditMappinCategoryList")
     {
         try
         {
             // ClearField();
             btnSave.Visible   = false;
             btnUpdate.Visible = true;
             btnDelete.Visible = true;
             int mappingCategoryID = Convert.ToInt32(e.CommandArgument);
             hdMappingCategoryID.Value = mappingCategoryID.ToString();
             using (MappingCategoryRT receiverTransfer = new MappingCategoryRT())
             {
                 MappingCategory mappingCategory = receiverTransfer.GetMappingCategoryByID(mappingCategoryID);
                 FillMappingCategoryForEdit(mappingCategory);
             }
         }
         catch (Exception ex)
         {
             labelMessage.Text      = "Error : " + ex.Message;
             labelMessage.ForeColor = System.Drawing.Color.Red;
         }
     }
 }
Example #2
0
 public void AddMappingCategory(MappingCategory mapCategory)
 {
     try
     {
         DatabaseHelper.Insert <MappingCategory>(mapCategory);
     }
     catch (Exception ex) { throw new Exception(ex.Message, ex); }
 }
Example #3
0
 public MappingCategory GetMappingCategoryByID(int mappingCategoryID)
 {
     try
     {
         OiiOHaatDCDataContext dbContext       = DatabaseHelper.GetDataModelDataContext();
         MappingCategory       mappingCategory = new MappingCategory();
         mappingCategory = dbContext.MappingCategories.FirstOrDefault(d => d.CategoryID == mappingCategoryID && d.IsRemoved == false);
         //dbContext.Dispose();
         return(mappingCategory);
     }
     catch (Exception ex) { throw new Exception(ex.Message, ex); }
 }
        protected void btnUpdate_Click(object sender, EventArgs e)
        {
            try
            {
                hdIsEdit.Value = "true";
                using (MappingCategoryRT receiverTransfer = new MappingCategoryRT())
                {
                    List <MappingCategory> mappingCategoryList = new List <MappingCategory>();
                    MappingCategory        mappingCategory     = new MappingCategory();
                    if (!string.IsNullOrEmpty(txtParentID.Text))
                    {
                        mappingCategoryList = receiverTransfer.GetMappingCategoryByTableID(Convert.ToInt32(txtParentID.Text));
                        if (mappingCategoryList != null && mappingCategoryList.Count > 0)
                        {
                            foreach (MappingCategory mappCategory in mappingCategoryList)
                            {
                                mappCategory.IsRemoved = true;
                                receiverTransfer.UpdateMappingCategory(mappCategory);
                            }
                        }

                        for (int rowCounter = 0; rowCounter < lvMappingCategory.Items.Count(); rowCounter++)
                        {
                            CheckBox checkBox           = (CheckBox)lvMappingCategory.Items[rowCounter].FindControl("chkModel");
                            Label    lblMappingTableIID = (Label)lvMappingCategory.Items[rowCounter].FindControl("lblMappingTableIID");

                            if (checkBox.Checked)
                            {
                                mappingCategory = CreateMappingCategory(Convert.ToInt32(txtParentID.Text), Convert.ToInt32(lblMappingTableIID.Text));
                                receiverTransfer.AddMappingCategory(mappingCategory);
                            }
                        }
                        labelMessage.Text      = "Data successfully Updated...";
                        labelMessage.ForeColor = System.Drawing.Color.Green;
                    }
                    else
                    {
                        labelMessage.Text      = "Data not Updated...";
                        labelMessage.ForeColor = System.Drawing.Color.Red;
                    }
                }

                ClearField();
                LoadMappingCategoryList();
            }
            catch (Exception ex)
            {
                labelMessage.Text      = "Error : " + ex.Message;
                labelMessage.ForeColor = System.Drawing.Color.Red;
            }
        }
Example #5
0
        public void UpdateMappingCategory(MappingCategory categoryID)
        {
            try
            {
                OiiOHaatDCDataContext msDC = DatabaseHelper.GetDataModelDataContext();

                //  MappingCategory mappingCategoryNew = msDC.MappingCategories.Single(d => d.CategoryID == categoryID.CategoryID );
                MappingCategory mappingCategoryNew = msDC.MappingCategories.Single(d => d.IID == categoryID.IID);
                DatabaseHelper.Update <MappingCategory>(msDC, categoryID, mappingCategoryNew);

                msDC.Dispose();
            }
            catch (Exception ex) { throw new Exception(ex.Message, ex); }
        }
Example #6
0
        public void Should_Success_Instantiate()
        {
            MappingCategory category = new MappingCategory()
            {
                Id         = 1,
                CategoryId = 1,
                DivisionId = 1,
                ProductId  = 1
            };

            Assert.Equal(1, category.Id);
            Assert.Equal(1, category.DivisionId);
            Assert.Equal(1, category.ProductId);
        }
        ////
        private MappingCategory CreateMappingCategory(Int32 CatID, Int32 MapID)
        {
            Session["UserID"] = "1";
            MappingCategory mappingCategory = new MappingCategory();

            try
            {
                if (hdIsEdit.Value == "true")
                {
                    mappingCategory.IID = Convert.ToInt32(hdMappingCategoryID.Value.ToString());
                }
                mappingCategory.CategoryID     = CatID;
                mappingCategory.MappingTableID = MapID;
                if (mappingCategory.IID <= 0)
                {
                    mappingCategory.CreatedBy   = Convert.ToInt64(Session["UserID"]);
                    mappingCategory.CreatedDate = GlobalRT.GetServerDateTime();
                }
                else
                {
                    MappingCategory mapping = (MappingCategory)Session[sessMappingCategory];
                    mappingCategory.CreatedBy    = mapping.CreatedBy;
                    mappingCategory.CreatedDate  = mapping.CreatedDate;
                    mappingCategory.ModifiedBy   = Convert.ToInt64(Session["UserID"]);
                    mappingCategory.ModifiedDate = GlobalRT.GetServerDateTime();
                }
                if (hdIsDelete.Value != "true")
                {
                    mappingCategory.IsRemoved = false;
                }
                else
                {
                    mappingCategory.IsRemoved = true;
                }
            }
            catch (Exception ex)
            {
                labelMessage.Text      = "Error : " + ex.Message;
                labelMessage.ForeColor = System.Drawing.Color.Red;
            }
            return(mappingCategory);
        }
        protected void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                MappingCategory mappingCategory = new MappingCategory();
                using (MappingCategoryRT receiverTransfer = new MappingCategoryRT())
                {
                    List <MappingCategory> mappingCategoryList = new List <MappingCategory>();
                    for (int rowCounter = 0; rowCounter < lvMappingCategory.Items.Count(); rowCounter++)
                    {
                        CheckBox checkBox           = (CheckBox)lvMappingCategory.Items[rowCounter].FindControl("chkModel");
                        Label    lblMappingTableIID = (Label)lvMappingCategory.Items[rowCounter].FindControl("lblMappingTableIID");

                        if (checkBox.Checked)
                        {
                            mappingCategory = CreateMappingCategory(Convert.ToInt32(txtParentID.Text), Convert.ToInt32(lblMappingTableIID.Text));
                            receiverTransfer.AddMappingCategory(mappingCategory);
                        }
                    }
                    if (mappingCategory.IID > 0)
                    {
                        labelMessage.Text      = "Data successfully saved...";
                        labelMessage.ForeColor = System.Drawing.Color.Green;
                    }
                    else
                    {
                        labelMessage.Text      = "Data not saved...";
                        labelMessage.ForeColor = System.Drawing.Color.Red;
                    }
                }

                ClearField();
                LoadMappingCategoryList();
            }
            catch (Exception ex)
            {
                labelMessage.Text      = "Error : " + ex.Message;
                labelMessage.ForeColor = System.Drawing.Color.Red;
            }
        }
        private void FillMappingCategoryForEdit(MappingCategory mappingCategory)
        {
            try
            {
                MappingCategoryRT receiverTransfer = new MappingCategoryRT();
                if (mappingCategory != null)
                {
                    txtParentID.Text = Convert.ToString(mappingCategory.CategoryID);
                    string catName = receiverTransfer.GetMappingCategoryByName(Convert.ToInt32(mappingCategory.CategoryID));
                    txtCategoryID.Text = Convert.ToString(catName);

                    List <MappingCategory> mappingCategoryList = new List <MappingCategory>();
                    mappingCategoryList = receiverTransfer.GetMappingCategoryByTableID(Convert.ToInt32(mappingCategory.CategoryID));
                    if (mappingCategoryList != null && mappingCategoryList.Count > 0)
                    {
                        foreach (MappingCategory mappCategory in mappingCategoryList)
                        {
                            for (int rowCounter = 0; rowCounter < lvMappingCategory.Items.Count(); rowCounter++)
                            {
                                CheckBox checkBox           = (CheckBox)lvMappingCategory.Items[rowCounter].FindControl("chkModel");
                                Label    lblMappingTableIID = (Label)lvMappingCategory.Items[rowCounter].FindControl("lblMappingTableIID");

                                if (Convert.ToInt32(lblMappingTableIID.Text) == mappCategory.MappingTableID)
                                {
                                    checkBox.Checked = true;
                                }
                            }
                        }
                    }


                    Session[sessMappingCategory] = mappingCategory;
                }
            }
            catch (Exception ex)
            {
                labelMessage.Text      = "Error : " + ex.Message;
                labelMessage.ForeColor = System.Drawing.Color.Red;
            }
        }
Example #10
0
        public BaseWPExportData(WPExportDTO export)
        {
            this._export = export;

            MappingPost mappingPost = new MappingPost();

            this.MapperPost = mappingPost.Get;

            MappingProducts mappingProducts = new MappingProducts();

            this.MapperProduct = mappingProducts.Get;

            MappingCategory mappingCategory = new MappingCategory();

            this.MapperCategory = mappingCategory.Get;

            MappingTag mappingTag = new MappingTag();

            this.MapperTag = mappingTag.Get;

            MappingUser mappingUser = new MappingUser();

            this.MapperUser = mappingUser.Get;
        }