public void dgCategories_Delete(object sender, DataGridCommandEventArgs e) { try { pnlAddCategory.Visible = false; int categoryID = Convert.ToInt16(dgCategories.DataKeys[e.Item.ItemIndex]); clsCategory objClsCategory = new clsCategory(); objClsCategory.CategoryID = categoryID; clsBLCategory objClsBLCategory = new clsBLCategory(); int NoOfRowsReturned = objClsBLCategory.DeleteCategory(objClsCategory); if (NoOfRowsReturned <= 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 delete this department as some issues under this department are not yet resolved or closed.');</script>"); } else { lblError.Visible = false; lblError.Text = ""; } dgCategories.EditItemIndex = -1; getCategories(); } catch (V2Exceptions ex) { throw; } catch (System.Exception ex) { FileLog objFileLog = FileLog.GetLogger(); objFileLog.WriteLine(LogType.Error, ex.Message, "categoryMaster.aspx", "dgCategories_Delete", ex.StackTrace); throw new V2Exceptions(ex.ToString(), ex); } }
protected void btnSubmit_Click(object sender, System.EventArgs e) { try { if (txtAddCategory.Text == "") { getCategories(); // pnlAddCategory.Visible = true; lblMessage.Visible = true; } else { clsCategory objClsCategory = new clsCategory(); clsBLCategory objClsBLCategory = new clsBLCategory(); objClsCategory.AddCategories = Server.HtmlEncode(txtAddCategory.Text.Trim()); int noOfRowsReturned = 0; noOfRowsReturned = objClsBLCategory.DoesExist(objClsCategory); if (noOfRowsReturned >= 1) { lblMessage.Text = "This DepartMent is already existing in the Table."; lblMessage.Visible = true; // pnlAddCategory.Visible = true; getCategories(); } else { objClsCategory.AddCategories = Server.HtmlEncode(txtAddCategory.Text.Trim()); objClsCategory.AddIdActive = Convert.ToInt32(ddlAddStatus.SelectedValue); objClsCategory.EmployeeId = ddlEmployeeName.SelectedValue.ToString(); objClsBLCategory.InsertCategory(objClsCategory); pnlAddCategory.Visible = false; txtAddCategory.Text = ""; ddlAddStatus.SelectedIndex = 0; getCategories(); } } } catch (V2Exceptions ex) { throw; } catch (System.Exception ex) { FileLog objFileLog = FileLog.GetLogger(); objFileLog.WriteLine(LogType.Error, ex.Message, "categoryMaster.aspx", "btnSubmit_Click", ex.StackTrace); throw new V2Exceptions(ex.ToString(), ex); } }
private void dgCategories_ItemCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e) { try { pnlAddCategory.Visible = false; EmployeePanel.Visible = true; DataSet dsEmployee = new DataSet(); clsBLCategory objClsBLCategory = new clsBLCategory(); clsCategory objClsCategory = new clsCategory(); if (e.CommandName == "View") { strCatagory = null; objClsCategory.CategoryID = Convert.ToInt32(dgCategories.DataKeys[e.Item.ItemIndex]); Label lblCategory = (Label)dgCategories.Items[e.Item.ItemIndex].FindControl("lblCategory"); lblEmployeeList.Text = "List of Administrator for Department <b> " + lblCategory.Text + " </b> "; dsEmployee = objClsBLCategory.GetCategoryEmployeeNames(objClsCategory); for (int i = 0; i < dsEmployee.Tables[0].Rows.Count; i++) { strCatagory = strCatagory + "" + dsEmployee.Tables[0].Rows[i][0].ToString(); strCatagory = strCatagory + "</br>"; lblEmployeename1.Text = strCatagory.Replace("<br>", "/r/n"); } if (dsEmployee.Tables[0].Rows.Count == 0) { lblEmployeeList.Text = " Administrator Not available for <b>" + lblCategory.Text + " </b> Department"; lblEmployeename1.Text = ""; //lblEmployeename1.Text = dsEmployee.Tables[0].Rows[0][0].ToString(); } EmployeePanel.Visible = true; } getCategories(); } catch (V2Exceptions ex) { throw; } catch (System.Exception ex) { FileLog objFileLog = FileLog.GetLogger(); objFileLog.WriteLine(LogType.Error, ex.Message, "categoryMaster.aspx", "dgCategories_ItemCommand", ex.StackTrace); throw new V2Exceptions(ex.ToString(), ex); } }
private void GetCategoryEmployeeName(string CategoryName) { try { clsBLCategory objclsBLCategory = new clsBLCategory(); dsEmployeeName = objclsBLCategory.GetCategoryEmployeeName(CategoryName); } catch (V2Exceptions ex) { throw; } catch (System.Exception ex) { FileLog objFileLog = FileLog.GetLogger(); objFileLog.WriteLine(LogType.Error, ex.Message, "categoryMaster.aspx", "GetCategoryEmployeeName", ex.StackTrace); throw new V2Exceptions(ex.ToString(), ex); } }
private void getCategories() { try { clsBLCategory objclsBLCategory = new clsBLCategory(); dsCategories = new DataSet(); dsCategories = objclsBLCategory.getCategories(); if (dsCategories.Tables[0].Rows.Count > 0) { dgCategories.DataSource = dsCategories.Tables[0]; dgCategories.DataBind(); if (dgCategories.PageCount > 1) { dgCategories.PagerStyle.Visible = true; } else { dgCategories.PagerStyle.Visible = false; } lblRecordMsg.Visible = false; } else if (dsCategories.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, "categoryMaster.aspx", "getCategories", ex.StackTrace); throw new V2Exceptions(ex.ToString(), ex); } }
private void GetEmployeeName() { try { clsBLCategory objclsBLCategory = new clsBLCategory(); dsGetEmployeeName = objclsBLCategory.GetEmployeeName(); ddlEmployeeName.Items.Add(new ListItem("Select Administrator", "0")); for (int i = 0; i < dsGetEmployeeName.Tables[0].Rows.Count; i++) { ddlEmployeeName.Items.Add(new ListItem(dsGetEmployeeName.Tables[0].Rows[i]["Emp_Name"].ToString(), dsGetEmployeeName.Tables[0].Rows[i]["Emp_User_Name"].ToString()));; } } catch (V2Exceptions ex) { throw; } catch (System.Exception ex) { FileLog objFileLog = FileLog.GetLogger(); objFileLog.WriteLine(LogType.Error, ex.Message, "categoryMaster.aspx", "GetEmployeeName", ex.StackTrace); throw new V2Exceptions(ex.ToString(), ex); } }