protected void btnSave_Click(object sender, EventArgs e)
        {
            ChartOfAccountGroup coaGroup=new ChartOfAccountGroup();
            List<ChartOfAccountGroup> coaList = coaGroup.GetAllChartOfAccountGroup(_company.CompanyId);
            int id = 0;
            if (coaList.Count > 0)
            {
                id = coaList.Count;
            }

            coaGroup.CoaGroupId = id+1;
            coaGroup.CoaGroupName = txtGroupName.Value;
            coaGroup.ParentId = coaGroup.CoaGroupId;
            coaGroup.IsActive = true;
            coaGroup.UpdateBy = _user.UserId;
            coaGroup.UpdateDate=DateTime.Now;
            coaGroup.CompanyId = _user.CompanyId;

            int sucess = coaGroup.InsertChartOfAccountGroup();

            if (sucess > 0)
            {
                Alert.Show("Accounts group Insert sucessfully");
                this.Clear();
                this.LoadAccountGroupTable();
            }
        }
        protected void RadGrid1_OnItemCommand(object sender, GridCommandEventArgs e)
        {
            try
            {

                GridDataItem item = (GridDataItem)e.Item;

                string id = item["colId"].Text;

                switch (e.CommandName)
                {
                    case "btnSelect":
                        Response.Redirect("ChartOfAccountGroupInfo.aspx?id=" + id, true);
                        break;
                    case "btnDelete":
                        //int delete = new Bank().DeleteBankByBankId(int.Parse(id));
                        int delete = new ChartOfAccountGroup().DeleteChartOfAccountGroupByCoaGroupId(int.Parse(id));

                        if (delete == 0)
                        {
                            Alert.Show("Data was not delete..");
                        }
                        else
                            LoadAccountGroupTable();
                        break;
                }
            }
            catch (Exception ex)
            {
                Alert.Show(ex.Message);
            }
        }
        protected void btnSave_Click(object sender, EventArgs e)
        {
            ChartOfAccountGroup coaGroup=new ChartOfAccountGroup();
            List<ChartOfAccountGroup> coaList = coaGroup.GetAllChartOfAccountGroup(_company.CompanyId);
            int id = 0;
            if (coaList.Count > 0)
            {
                id = coaList.Count;
            }

            coaGroup.CoaGroupId = id;
            coaGroup.CoaGroupName = txtGroupName.Value;
            coaGroup.ParentId = coaGroup.CoaGroupId;
            coaGroup.IsActive = true;
            coaGroup.UpdateBy = _user.UserId;
            coaGroup.UpdateDate=DateTime.Now;
            coaGroup.CompanyId = _user.CompanyId;

            int sucess = 0;
            if (lblId.Text == "" || lblId.Text == "0")
            {
                coaGroup.CoaGroupId = new ChartOfAccountGroup().GetMaxCoaGroupId() + 1;

                sucess = coaGroup.InsertChartOfAccountGroup();

                if (sucess > 0)
                {
                    Alert.Show("Chart Of Account Group saved successfully");
                    this.Clear();
                }
            }
            else
            {
                coaGroup.CoaGroupId = int.Parse(lblId.Text);
                sucess = coaGroup.UpdateChartOfAccountGroup();

                if (sucess > 0)
                {
                    Response.Redirect("ChartOfAccountList.aspx", true);
                }
            }
        }
 private void LoadAccountGroup()
 {
     ChartOfAccountGroup group=new ChartOfAccountGroup();
     List<string> nameList =new List<string>();
     accountGroups = group.GetAllChartOfAccountGroup(_company.CompanyId);
     foreach (ChartOfAccountGroup acc in accountGroups)
     {
         nameList.Add(acc.CoaGroupName);
     }
     chartOfAccountGroupIdDropDownList.DataSource = nameList;
     chartOfAccountGroupIdDropDownList.DataBind();
 }
        private void LoadAccountGroupTable()
        {
            try
            {
                coaTableBody.InnerHtml = "";
                string htmlContent = "";
                ChartOfAccountGroup accountGroup = new ChartOfAccountGroup();
                List<ChartOfAccountGroup> allAccountGroups = accountGroup.GetAllChartOfAccountGroup(_company.CompanyId);
                foreach (ChartOfAccountGroup coa in allAccountGroups)
                {
                    htmlContent += "<tr>";
                    htmlContent += String.Format(@"<th>{0}</th><th>{1}</th><th>{2}</th><th>{3}</th><th>{4}</th><th>{5}</th>", coa.CoaGroupName, coa.ParentId, coa.IsActive,  coa.UpdateBy, coa.UpdateDate,coa.CompanyId);
                    htmlContent += "</tr>";
                }

                coaTableBody.InnerHtml += htmlContent;
            }
            catch (Exception exc)
            {
                Alert.Show(exc.Message);
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            _company = (Company)Session["Company"];
            _user = (Users)Session["user"];

            if (!isValidSession())
            {
                string str = Request.QueryString.ToString();
                if (str == string.Empty)
                    Response.Redirect("LogIn.aspx?refPage=default.aspx");
                else
                    Response.Redirect("LogIn.aspx?refPage=default.aspx?" + str);
            }
            if (!IsPostBack)
            {

                if (Request.QueryString["id"] != null)
                {
                    string CoaGroupId = Request.QueryString["id"].ToString();

                    ChartOfAccountGroup coa = new ChartOfAccountGroup().GetChartOfAccountGroupByCoaGroupId(int.Parse(CoaGroupId), _company.CompanyId);
                    if (coa != null || coa.CoaGroupId != 0)
                    {

                        lblId.Text = coa.CoaGroupId.ToString();
                        txtGroupName.Value = coa.CoaGroupName;
                        chkIsActive.Checked = true;
                    }
                }
            }
        }
        private void LoadAccountGroupTable()
        {
            try
            {
                ChartOfAccountGroup coaGroup=new ChartOfAccountGroup();
                List<ChartOfAccountGroup>coaList=new List<ChartOfAccountGroup>();

                coaList = coaGroup.GetAllChartOfAccountGroup(_company.CompanyId);
                if (coaList.Count == 0)
                    coaList.Add(new ChartOfAccountGroup());

                RadGrid1.DataSource = coaList;
                RadGrid1.Rebind();
            }
            catch (Exception ex)
            {
                Alert.Show(ex.Message);
            }
        }