コード例 #1
0
        public void dgSubCategories_Edit(object sender, DataGridCommandEventArgs e)
        {
            try
            {
                //strSubCategoryStatus = ((DropDownList)e.Item.Cells[2].FindControl("ddlCategory")).SelectedItem.Value.ToString();
                //DropDownList ddl;
                //ddl = ((DropDownList)e.Item.FindControl("ddlCategory"));
                //ddl.Attributes.Add("readonly", "readonly");

                // //DropDownList ddl= new DropDownList();
                // //ddl = (e.Item.FindControl("ddlCategory") as DropDownList);
                // ddl.Attributes.Add("readonly", "readonly");
                lblSuccessMsgs.Text  = "";
                lblEmployeeList.Text = "";
                lblEmployeename.Text = "";
                lblError.Text        = "";
                int i         = dgSubCategories.CurrentPageIndex;
                int itemIndex = e.Item.ItemIndex;
                if (i < 0)
                {
                    itemIndex = i * 10 + itemIndex;
                }

                pnlAddSubCategory.Visible = false;
                clsBLSubCategory objclsBLSubCategory = new clsBLSubCategory();
                dsSubCategories = objclsBLSubCategory.getSubCategories();

                strSubCategoryStatus         = dsSubCategories.Tables[0].Rows[e.Item.DataSetIndex][4].ToString();
                ViewState["SubCategoryName"] = dsSubCategories.Tables[0].Rows[e.Item.DataSetIndex][3].ToString();

                strCategoryName = dsSubCategories.Tables[0].Rows[e.Item.DataSetIndex][2].ToString();
                dgSubCategories.EditItemIndex = (int)e.Item.ItemIndex;
                getSubCategories();
            }
            catch (V2Exceptions ex)
            {
                throw;
            }
            catch (System.Exception ex)
            {
                FileLog objFileLog = FileLog.GetLogger();
                objFileLog.WriteLine(LogType.Error, ex.Message, "subCategoryMaster.aspx", "dgSubCategories_Edit", ex.StackTrace);
                throw new V2Exceptions(ex.ToString(), ex);
            }
        }
コード例 #2
0
        public void getSubCategories()
        {
            try
            {
                clsBLSubCategory objclsBLSubCategory = new clsBLSubCategory();
                clsCategory      objClsCategory      = new clsCategory();
                dsSubCategories = objclsBLSubCategory.getSubCategories();
                if (dsSubCategories.Tables[0].Rows.Count > 0)
                {
                    dgSubCategories.DataSource = dsSubCategories.Tables[0];
                    dgSubCategories.DataBind();
                    if (dgSubCategories.PageCount > 1)
                    {
                        dgSubCategories.PagerStyle.Visible = true;
                    }
                    else
                    {
                        dgSubCategories.PagerStyle.Visible = false;
                    }

                    lblRecordMsg.Visible = false;
                }
                else if (dsSubCategories.Tables[0].Rows.Count <= 0)
                {
                    lblRecordMsg.Visible = true;
                }
            }
            catch (V2Exceptions ex)
            {
                throw;
            }
            catch (System.Exception ex)
            {
                FileLog objFileLog = FileLog.GetLogger();
                objFileLog.WriteLine(LogType.Error, ex.Message, "subCategoryMaster.aspx", "getSubCategories", ex.StackTrace);
                throw new V2Exceptions(ex.ToString(), ex);
            }
        }
コード例 #3
0
        public void dgSubCategories_Update(object sender, DataGridCommandEventArgs e)
        {
            try
            {
                lblEmployeeList.Text = "";
                lblEmployeename.Text = "";
                clsBLSubCategory objclsBLSubCategory = new clsBLSubCategory();
                dsSubCategories = objclsBLSubCategory.getSubCategories();

                strSubCategoryStatus = ((DropDownList)e.Item.Cells[4].FindControl("ddlStatus")).SelectedItem.Value.ToString();//dsSubCategories.Tables[0].Rows[e.Item.ItemIndex][4].ToString();
                int            subCategoryID     = Convert.ToInt32(dgSubCategories.DataKeys[e.Item.ItemIndex]);
                string         newSubCategory    = Server.HtmlEncode(((TextBox)e.Item.FindControl("txtSubCategory")).Text.Trim());
                clsSubCategory objClsSubCategory = new clsSubCategory();
                if (newSubCategory == "")
                {
                    lblError.Visible = true;
                    lblError.Text    = "Please fill the Category.";
                    getSubCategories();
                }
                else
                {
                    lblError.Text = "";
                    DataSet dsNoOfRowsReturned = new DataSet();

                    int newCategory = Convert.ToInt32(((DropDownList)e.Item.FindControl("ddlCategory")).SelectedItem.Value);
                    objClsSubCategory.NewCategory    = newCategory;
                    objClsSubCategory.NewSubCategory = newSubCategory;
                    dsNoOfRowsReturned = objclsBLSubCategory.DoesExistWhenEdited(objClsSubCategory);
                    //int subCatID = Convert.ToInt32(dsSubCategories.Tables[0].Rows[e.Item.ItemIndex][0]);
                    int subCatID = Convert.ToInt32(e.Item.Cells[0].Text);
                    if (dsNoOfRowsReturned.Tables[0].Rows.Count > 0 && Convert.ToInt32(dsNoOfRowsReturned.Tables[0].Rows[0][1]) == newCategory)// && objClsSubCategory.SubCategoryID != subCatID)
                    {
                        if (subCatID != Convert.ToInt32(dsNoOfRowsReturned.Tables[0].Rows[0][0]))
                        {
                            lblError.Visible = true;
                            lblError.Text    = "This Department/Category is already Existing in the Table.";
                            getSubCategories();
                        }
                        else
                        {
                            objClsSubCategory.NewSubCategory = newSubCategory;
                            objClsSubCategory.SubCategoryID  = subCategoryID;
                            objClsSubCategory.NewCategory    = Convert.ToInt32(((DropDownList)e.Item.FindControl("ddlCategory")).SelectedItem.Value);
                            int status = Convert.ToInt32(((DropDownList)e.Item.Cells[4].FindControl("ddlStatus")).SelectedItem.Value);//Convert.ToInt32(((DropDownList)e.Item.FindControl("ddlStatus")).SelectedItem.Value);
                            objClsSubCategory.IsActive = status;
                            int noOfRecordsReturned = objclsBLSubCategory.updateSubCategory(objClsSubCategory);
                            if (noOfRecordsReturned > 0)
                            {
                                //if (status == 0)
                                //{
                                lblError.Visible = true;
                                //lblError.Text = "Cannot Delete this Department as some issues under this Department are not yet resolved or closed.";
                                Page.RegisterStartupScript("key", "<script>alert('Cannot update the details, as some issues under this Department are not yet resolved or closed.');</script>");
                                ViewState["SubCategoryName"] = null;
                                //}
                            }
                            else
                            {
                                dgSubCategories.EditItemIndex = -1;
                                lblError.Visible = false;
                                getSubCategories();
                                lblSuccessMsgs.Visible       = true;
                                lblSuccessMsgs.Text          = "Details updated successfully";
                                ViewState["SubCategoryName"] = null;
                            }
                            dgSubCategories.EditItemIndex = -1;
                            lblError.Visible = false;
                            getSubCategories();
                        }
                    }
                    else
                    {
                        objClsSubCategory.NewSubCategory = newSubCategory;
                        objClsSubCategory.SubCategoryID  = subCategoryID;
                        objClsSubCategory.NewCategory    = Convert.ToInt32(((DropDownList)e.Item.FindControl("ddlCategory")).SelectedItem.Value);
                        int status = ((DropDownList)e.Item.Cells[4].FindControl("ddlStatus")).SelectedIndex;//Convert.ToInt32(((DropDownList)e.Item.FindControl("ddlStatus")).SelectedItem.Value);
                        objClsSubCategory.IsActive = status;
                        int noOfRecordsReturned = objclsBLSubCategory.updateSubCategory(objClsSubCategory);
                        if (noOfRecordsReturned > 0)
                        {
                            //if (status == 0)
                            //{
                            lblError.Visible = true;
                            //lblError.Text = "Cannot Delete this Department as some issues under this Department are not yet resolved or closed.";
                            Page.RegisterStartupScript("key", "<script>alert('Cannot update the details as some issues under this Department are not yet resolved or closed.');</script>");
                            ViewState["SubCategoryName"] = null;
                            //}
                        }
                        else
                        {
                            dgSubCategories.EditItemIndex = -1;
                            lblError.Visible = false;
                            getSubCategories();
                            lblSuccessMsgs.Visible       = true;
                            lblSuccessMsgs.Text          = "Details updated successfully";
                            ViewState["SubCategoryName"] = null;
                        }
                        dgSubCategories.EditItemIndex = -1;
                        lblError.Visible = false;
                        getSubCategories();
                    }
                }
            }
            catch (V2Exceptions ex)
            {
                throw;
            }
            catch (System.Exception ex)
            {
                FileLog objFileLog = FileLog.GetLogger();
                objFileLog.WriteLine(LogType.Error, ex.Message, "subCategoryMaster.aspx", "dgSubCategories_Update", ex.StackTrace);
                throw new V2Exceptions(ex.ToString(), ex);
            }
        }