protected void Fpspreadpophouse_buttoncommand(object sender, EventArgs e)
 {
     try
     {
         Fpspreadpophouse.SaveChanges();
         string activerow = Fpspreadpophouse.ActiveSheetView.ActiveRow.ToString();
         string activecol = Fpspreadpophouse.ActiveSheetView.ActiveColumn.ToString();
         if (activecol == "3")
         {
             int act1 = Convert.ToInt32(activerow);
             int act2 = Convert.ToInt16(activecol);
             if (Fpspreadpophouse.Sheets[0].Cells[act1, act2].Value.ToString() == "1")
             {
                 flaghouse = true;
                 Fpspreadpophouse.Sheets[0].Cells[act1, act2 + 1].Text = "";
             }
             else
             {
                 flaghouse = false;
             }
         }
         if (activecol == "5")
         {
             int act1 = Convert.ToInt32(activerow);
             int act2 = Convert.ToInt16(activecol);
             if (Fpspreadpophouse.Sheets[0].Cells[act1, act2].Value.ToString() == "1")
             {
                 flaghouse = true;
                 Fpspreadpophouse.Sheets[0].Cells[act1, act2 + 1].Text = "";
             }
             else
             {
                 flaghouse = false;
             }
         }
         Fpspreadpophouse.SaveChanges();
     }
     catch { }
 }
 protected void Fpspreadpophouse_render(object sender, EventArgs e)
 {
     if (flaghouse == true)
     {
         Fpspreadpophouse.SaveChanges();
         string activrow = "";
         activrow = Fpspreadpophouse.Sheets[0].ActiveRow.ToString();
         string activecol = Fpspreadpophouse.Sheets[0].ActiveColumn.ToString();
         int    actcol    = Convert.ToInt16(activecol);
         int    hy_order  = 0;
         for (int i = 0; i <= Convert.ToInt16(Fpspreadpophouse.Sheets[0].RowCount) - 1; i++)
         {
             int isval = Convert.ToInt32(Fpspreadpophouse.Sheets[0].Cells[i, actcol].Value);
             if (isval == 1)
             {
                 hy_order++;
                 Fpspreadpophouse.Sheets[0].Cells[Convert.ToInt32(activrow), actcol].Locked = true;
             }
         }
         Fpspreadpophouse.Sheets[0].Cells[Convert.ToInt32(activrow), actcol + 1].Text = hy_order.ToString();
     }
 }
 protected void btnresetpriority_click(object sender, EventArgs e)
 {
     if (Fpspreadpophouse.Sheets[0].Rows.Count > 0)
     {
         string collegecode = Convert.ToString(ddlcolhouse.SelectedItem.Value);
         int    insup       = 0;
         for (int i = 0; i < Fpspreadpophouse.Sheets[0].Rows.Count; i++)
         {
             string Degreecode = Convert.ToString(Fpspreadpophouse.Sheets[0].Cells[i, 1].Tag);
             Fpspreadpophouse.Sheets[0].Cells[i, 3].Locked = false;
             Fpspreadpophouse.Sheets[0].Cells[i, 3].Value  = 0;
             Fpspreadpophouse.Sheets[0].Cells[i, 4].Text   = "";
             insup = d2.update_method_wo_parameter("update Degree set Dept_Priority=NULL where Degree_Code='" + Degreecode + "' and college_code='" + collegecode + "'", "Text");
         }
         Fpspreadpophouse.SaveChanges();
         btngo_click(sender, e);
         if (insup != 0)
         {
             alertpop.Visible  = true;
             lbl_alert.Visible = true;
             lbl_alert.Text    = "Priority Reset Successfully";
         }
     }
 }
    protected void btngo_click(object sender, EventArgs e)
    {
        try
        {
            // btnresetpriority_click(sender, e);
            string degreecode  = rs.GetSelectedItemsValueAsString(cbl_degree);
            string collegecode = Convert.ToString(ddlcolhouse.SelectedItem.Value);
            if (!string.IsNullOrEmpty(degreecode) && ddlcolhouse.Items.Count > 0)
            {
                string selectquery = "select Degree_Code,isnull(c.type,'')+'-'+c.Course_Name+'-'+dt.Dept_Name as Dept_Name,Dept_Priority,Acronym from Degree d,Department dt,course c where d.Dept_Code=dt.Dept_Code and c.Course_Id =d.Course_Id and d.college_code in ('" + collegecode + "') and d.Degree_Code in('" + degreecode + "') order by ISNULL(c.Priority,0)";
                ds.Clear();
                ds = d2.select_method_wo_parameter(selectquery, "Text");
                if (ds.Tables.Count > 0)
                {
                    if (ds.Tables[0].Rows.Count > 0)
                    {
                        Fpspreadpophouse.Sheets[0].RowCount              = 0;
                        Fpspreadpophouse.Sheets[0].ColumnCount           = 0;
                        Fpspreadpophouse.CommandBar.Visible              = false;
                        Fpspreadpophouse.Sheets[0].AutoPostBack          = false;
                        Fpspreadpophouse.Sheets[0].ColumnHeader.RowCount = 1;
                        Fpspreadpophouse.Sheets[0].RowHeader.Visible     = false;
                        Fpspreadpophouse.Sheets[0].ColumnCount           = 5;

                        FarPoint.Web.Spread.CheckBoxCellType cbhousepriority = new FarPoint.Web.Spread.CheckBoxCellType();
                        cbhousepriority.AutoPostBack = true;


                        FarPoint.Web.Spread.StyleInfo darkstyle = new FarPoint.Web.Spread.StyleInfo();
                        darkstyle.BackColor          = ColorTranslator.FromHtml("#0CA6CA");
                        darkstyle.Font.Name          = "Book Antiqua";
                        darkstyle.Font.Size          = FontUnit.Medium;
                        darkstyle.Font.Bold          = true;
                        darkstyle.Border.BorderSize  = 1;
                        darkstyle.HorizontalAlign    = HorizontalAlign.Center;
                        darkstyle.VerticalAlign      = VerticalAlign.Middle;
                        darkstyle.Border.BorderColor = System.Drawing.Color.Transparent;
                        Fpspreadpophouse.ActiveSheetView.ColumnHeader.DefaultStyle = darkstyle;

                        Fpspreadpophouse.Sheets[0].ColumnHeader.Cells[0, 0].Text            = "S.No";
                        Fpspreadpophouse.Sheets[0].ColumnHeader.Cells[0, 0].Font.Bold       = true;
                        Fpspreadpophouse.Sheets[0].ColumnHeader.Cells[0, 0].Font.Name       = "Book Antiqua";
                        Fpspreadpophouse.Sheets[0].ColumnHeader.Cells[0, 0].Font.Size       = FontUnit.Medium;
                        Fpspreadpophouse.Sheets[0].ColumnHeader.Cells[0, 0].HorizontalAlign = HorizontalAlign.Center;
                        Fpspreadpophouse.Sheets[0].ColumnHeader.Columns[0].Locked           = true;
                        Fpspreadpophouse.Columns[0].Width = 50;

                        Fpspreadpophouse.Sheets[0].ColumnHeader.Cells[0, 1].Text            = "Degree";
                        Fpspreadpophouse.Sheets[0].ColumnHeader.Cells[0, 1].Font.Bold       = true;
                        Fpspreadpophouse.Sheets[0].ColumnHeader.Cells[0, 1].Font.Name       = "Book Antiqua";
                        Fpspreadpophouse.Sheets[0].ColumnHeader.Cells[0, 1].Font.Size       = FontUnit.Medium;
                        Fpspreadpophouse.Sheets[0].ColumnHeader.Cells[0, 1].HorizontalAlign = HorizontalAlign.Center;
                        Fpspreadpophouse.Sheets[0].ColumnHeader.Columns[1].Locked           = true;
                        Fpspreadpophouse.Columns[1].Width = 400;

                        Fpspreadpophouse.Sheets[0].ColumnHeader.Cells[0, 2].Text            = "Degree Acronym";
                        Fpspreadpophouse.Sheets[0].ColumnHeader.Cells[0, 2].Font.Bold       = true;
                        Fpspreadpophouse.Sheets[0].ColumnHeader.Cells[0, 2].Font.Name       = "Book Antiqua";
                        Fpspreadpophouse.Sheets[0].ColumnHeader.Cells[0, 2].Font.Size       = FontUnit.Medium;
                        Fpspreadpophouse.Sheets[0].ColumnHeader.Cells[0, 2].HorizontalAlign = HorizontalAlign.Center;
                        Fpspreadpophouse.Sheets[0].ColumnHeader.Columns[2].Locked           = true;
                        Fpspreadpophouse.Columns[2].Width = 150;

                        Fpspreadpophouse.Sheets[0].ColumnHeader.Cells[0, 3].Text            = "Set Priority";
                        Fpspreadpophouse.Sheets[0].ColumnHeader.Cells[0, 3].Font.Bold       = true;
                        Fpspreadpophouse.Sheets[0].ColumnHeader.Cells[0, 3].Font.Name       = "Book Antiqua";
                        Fpspreadpophouse.Sheets[0].ColumnHeader.Cells[0, 3].Font.Size       = FontUnit.Medium;
                        Fpspreadpophouse.Sheets[0].ColumnHeader.Cells[0, 3].HorizontalAlign = HorizontalAlign.Center;
                        Fpspreadpophouse.Sheets[0].ColumnHeader.Columns[3].Locked           = false;

                        Fpspreadpophouse.Sheets[0].ColumnHeader.Cells[0, 4].Text            = "Degree Priority";
                        Fpspreadpophouse.Sheets[0].ColumnHeader.Cells[0, 4].Font.Bold       = true;
                        Fpspreadpophouse.Sheets[0].ColumnHeader.Cells[0, 4].Font.Name       = "Book Antiqua";
                        Fpspreadpophouse.Sheets[0].ColumnHeader.Cells[0, 4].Font.Size       = FontUnit.Medium;
                        Fpspreadpophouse.Sheets[0].ColumnHeader.Cells[0, 4].HorizontalAlign = HorizontalAlign.Center;
                        Fpspreadpophouse.Sheets[0].ColumnHeader.Columns[4].Locked           = true;
                        Fpspreadpophouse.Columns[4].Width = 85;

                        for (int row = 0; row < ds.Tables[0].Rows.Count; row++)
                        {
                            Fpspreadpophouse.Sheets[0].RowCount++;
                            Fpspreadpophouse.Sheets[0].Cells[Fpspreadpophouse.Sheets[0].RowCount - 1, 0].Text            = Convert.ToString(row + 1);
                            Fpspreadpophouse.Sheets[0].Cells[Fpspreadpophouse.Sheets[0].RowCount - 1, 0].HorizontalAlign = HorizontalAlign.Center;
                            Fpspreadpophouse.Sheets[0].Cells[Fpspreadpophouse.Sheets[0].RowCount - 1, 1].Text            = Convert.ToString(ds.Tables[0].Rows[row]["Dept_Name"]);
                            Fpspreadpophouse.Sheets[0].Cells[Fpspreadpophouse.Sheets[0].RowCount - 1, 1].Tag             = Convert.ToString(ds.Tables[0].Rows[row]["Degree_Code"]);
                            Fpspreadpophouse.Sheets[0].Cells[Fpspreadpophouse.Sheets[0].RowCount - 1, 1].HorizontalAlign = HorizontalAlign.Left;
                            Fpspreadpophouse.Sheets[0].Cells[Fpspreadpophouse.Sheets[0].RowCount - 1, 2].Text            = Convert.ToString(ds.Tables[0].Rows[row]["Acronym"]);
                            Fpspreadpophouse.Sheets[0].Cells[Fpspreadpophouse.Sheets[0].RowCount - 1, 2].HorizontalAlign = HorizontalAlign.Left;
                            Fpspreadpophouse.Sheets[0].Cells[Fpspreadpophouse.Sheets[0].RowCount - 1, 3].CellType        = cbhousepriority;
                            if (Convert.ToString(ds.Tables[0].Rows[row]["Dept_Priority"]).Trim() != "" && Convert.ToString(ds.Tables[0].Rows[row]["Dept_Priority"]).Trim() != "0")
                            {
                                Fpspreadpophouse.Sheets[0].Cells[Fpspreadpophouse.Sheets[0].RowCount - 1, 3].Value  = 1;
                                Fpspreadpophouse.Sheets[0].Cells[Fpspreadpophouse.Sheets[0].RowCount - 1, 3].Locked = true;
                            }
                            else
                            {
                                Fpspreadpophouse.Sheets[0].Cells[Fpspreadpophouse.Sheets[0].RowCount - 1, 3].Value  = 0;
                                Fpspreadpophouse.Sheets[0].Cells[Fpspreadpophouse.Sheets[0].RowCount - 1, 3].Locked = false;
                            }
                            Fpspreadpophouse.Sheets[0].Cells[Fpspreadpophouse.Sheets[0].RowCount - 1, 3].HorizontalAlign = HorizontalAlign.Center;
                            Fpspreadpophouse.Sheets[0].Cells[Fpspreadpophouse.Sheets[0].RowCount - 1, 4].Text            = (Convert.ToString(ds.Tables[0].Rows[row]["Dept_Priority"]) == "0") ? "" : Convert.ToString(ds.Tables[0].Rows[row]["Dept_Priority"]);
                            Fpspreadpophouse.Sheets[0].Cells[Fpspreadpophouse.Sheets[0].RowCount - 1, 4].HorizontalAlign = HorizontalAlign.Center;
                        }
                        spreadDiv.Visible = true;
                        Fpspreadpophouse.Sheets[0].PageSize = Fpspreadpophouse.Sheets[0].RowCount;
                    }
                    else
                    {
                        spreadDiv.Visible = false;
                    }
                }
                else
                {
                    spreadDiv.Visible = false;
                }
                Fpspreadpophouse.SaveChanges();
            }
            else
            {
                spreadDiv.Visible = false;
                alertpop.Visible  = true;
                lbl_alert.Visible = true;
                lbl_alert.Text    = "Please Select All Fields";
            }
        }
        catch { }
    }