Exemple #1
0
    private void loadheaderstaffwise(string DeptCode, string DesigCode) /* poomalar 16.10.17 */
    {
        try
        {
            Fpspread1.Visible  = false;
            rprint.Visible     = false;
            lblMainErr.Visible = false;
            string collCode = Convert.ToString(ddlcollege.SelectedItem.Value);

            Fpspread1.Sheets[0].AutoPostBack          = false;
            Fpspread1.Sheets[0].ColumnHeader.RowCount = 1;
            Fpspread1.Sheets[0].RowCount    = 0;
            Fpspread1.Sheets[0].ColumnCount = 7;

            Fpspread1.Sheets[0].RowHeader.Visible = false;
            Fpspread1.CommandBar.Visible          = false;
            darkstyle.Font.Name       = "Book Antiqua";
            darkstyle.Font.Bold       = true;
            darkstyle.Font.Size       = FontUnit.Medium;
            darkstyle.HorizontalAlign = HorizontalAlign.Center;
            darkstyle.ForeColor       = Color.Black;
            darkstyle.BackColor       = ColorTranslator.FromHtml("#0CA6CA");
            Fpspread1.Sheets[0].ColumnHeader.DefaultStyle = darkstyle;

            Fpspread1.Sheets[0].ColumnHeader.Cells[0, 0].Text = "S.No.";
            Fpspread1.Sheets[0].ColumnHeader.Cells[0, 1].Text = "Select";
            Fpspread1.Sheets[0].ColumnHeader.Cells[0, 2].Text = "Staff Name";
            Fpspread1.Sheets[0].ColumnHeader.Cells[0, 3].Text = "Staff Code";
            Fpspread1.Sheets[0].ColumnHeader.Cells[0, 4].Text = "Designation";
            Fpspread1.Sheets[0].ColumnHeader.Cells[0, 5].Text = "Total Hours";
            Fpspread1.Sheets[0].ColumnHeader.Cells[0, 6].Text = "Amount/Hrs";


            Fpspread1.Columns[0].Width = 50;
            Fpspread1.Columns[1].Width = 50;
            Fpspread1.Columns[2].Width = 200;
            Fpspread1.Columns[3].Width = 100;
            Fpspread1.Columns[4].Width = 200;
            Fpspread1.Columns[5].Width = 100;
            Fpspread1.Columns[6].Width = 100;


            Fpspread1.Columns[0].Locked = true;
            Fpspread1.Columns[2].Locked = true;
            Fpspread1.Columns[3].Locked = true;
            Fpspread1.Columns[4].Locked = true;

            CheckAll.AutoPostBack   = true;
            CheckInd.AutoPostBack   = false;
            DoubleHrs.MaximumValue  = 70;
            DoubleHrs.ErrorMessage  = "Allow only Numerics & Max Hours is 70!";
            DoubleAmnt.ErrorMessage = "Allow only Numerics!";
            string           query        = "";
            ReuasableMethods rs           = new ReuasableMethods();
            string           deptcodesel  = rs.GetSelectedItemsValueAsString(cbl_dept);
            string           desigcodesel = rs.GetSelectedItemsValueAsString(cblDesig);

            query = "select sm.staff_code,sm.staff_name,h.dept_name,desig.desig_name,st.stftype,sc.category_name,h.dept_code,desig.desig_code,sm.college_Code,sm.appl_no,isnull(Tot_Hrs,0) Tot_Hrs,isnull(Amnt_Per_Hrs,0) Amnt_Per_Hrs from staffmaster sm,hrdept_master h,desig_master desig,staffcategorizer sc,stafftrans st LEFT JOIN HourWise_PaySettings HW ON st.staff_code=hw.StaffCode and hw.dept_code=st.dept_code and hw.desig_code=hw.desig_code  where sm.staff_code=st.staff_code and sm.college_code=h.college_code and sm.college_code=desig.collegeCode and sm.college_code=sc.college_code and (isnull(st.stfnature,0)='1' or isnull(st.stfnature,'')='part') and st.dept_code=h.dept_code and st.desig_code=desig.desig_code and st.category_code=sc.category_code and st.latestrec='1' and sm.resign='0' and sm.settled='0' and ISNULL(Discontinue,'0')='0' and sm.college_code='" + collCode + "' and h.dept_code in('" + deptcodesel + "') and desig.desig_code in('" + desigcodesel + "')";// and isnull(hw.PayType,0)='"+paytype+"'";
            DataSet dquery = new DataSet();


            dquery = d2.select_method_wo_parameter(query, "Text");
            int sno      = 1;
            int rowcount = 0;
            if (dquery.Tables.Count > 0 && dquery.Tables[0].Rows.Count > 0)
            {
                if (cbl_dept.Items.Count > 0 && txt_dept.Text.Trim() != "--Select--")
                {
                    Fpspread1.Sheets[0].RowCount++;
                    Fpspread1.Sheets[0].Cells[Fpspread1.Sheets[0].RowCount - 1, 1].CellType        = CheckAll;
                    Fpspread1.Sheets[0].Cells[Fpspread1.Sheets[0].RowCount - 1, 1].HorizontalAlign = HorizontalAlign.Center;
                    Fpspread1.Sheets[0].Cells[Fpspread1.Sheets[0].RowCount - 1, 1].Font.Name       = "Book Antiqua";
                    Fpspread1.Sheets[0].Cells[Fpspread1.Sheets[0].RowCount - 1, 1].Font.Bold       = true;

                    for (int st = 0; st < cbl_dept.Items.Count; st++)
                    {
                        if (cbl_dept.Items[st].Selected == true)
                        {
                            rowcount = 0;
                            Fpspread1.Sheets[0].RowCount++;
                            Fpspread1.Sheets[0].Cells[Fpspread1.Sheets[0].RowCount - 1, 0].Text            = Convert.ToString(cbl_dept.Items[st].Text);
                            Fpspread1.Sheets[0].Cells[Fpspread1.Sheets[0].RowCount - 1, 0].HorizontalAlign = HorizontalAlign.Center;
                            Fpspread1.Sheets[0].Cells[Fpspread1.Sheets[0].RowCount - 1, 0].Font.Name       = "Book Antiqua";
                            Fpspread1.Sheets[0].Cells[Fpspread1.Sheets[0].RowCount - 1, 0].Font.Bold       = true;
                            Fpspread1.Sheets[0].SpanModel.Add(Fpspread1.Sheets[0].RowCount - 1, 0, 1, 7);

                            DataView dv = new DataView();
                            dquery.Tables[0].DefaultView.RowFilter = " dept_code='" + Convert.ToString(cbl_dept.Items[st].Value) + "'";
                            dv = dquery.Tables[0].DefaultView;
                            if (dv.Count > 0)
                            {
                                for (int i = 0; i < dv.Count; i++)
                                {
                                    rowcount++;
                                    Fpspread1.Sheets[0].RowCount++;
                                    Fpspread1.Sheets[0].Cells[Fpspread1.Sheets[0].RowCount - 1, 0].Text            = Convert.ToString(sno++);
                                    Fpspread1.Sheets[0].Cells[Fpspread1.Sheets[0].RowCount - 1, 0].HorizontalAlign = HorizontalAlign.Center;
                                    Fpspread1.Sheets[0].Cells[Fpspread1.Sheets[0].RowCount - 1, 0].Font.Name       = "Book Antiqua";
                                    Fpspread1.Sheets[0].Cells[Fpspread1.Sheets[0].RowCount - 1, 1].CellType        = CheckInd;

                                    Fpspread1.Sheets[0].Cells[Fpspread1.Sheets[0].RowCount - 1, 1].HorizontalAlign = HorizontalAlign.Center;
                                    Fpspread1.Sheets[0].Cells[Fpspread1.Sheets[0].RowCount - 1, 1].Font.Name       = "Book Antiqua";

                                    Fpspread1.Sheets[0].Cells[Fpspread1.Sheets[0].RowCount - 1, 2].Text            = Convert.ToString(dv[i]["staff_name"]);
                                    Fpspread1.Sheets[0].Cells[Fpspread1.Sheets[0].RowCount - 1, 2].HorizontalAlign = HorizontalAlign.Left;
                                    Fpspread1.Sheets[0].Cells[Fpspread1.Sheets[0].RowCount - 1, 2].Font.Name       = "Book Antiqua";

                                    Fpspread1.Sheets[0].Cells[Fpspread1.Sheets[0].RowCount - 1, 3].Text            = Convert.ToString(dv[i]["staff_code"]);
                                    Fpspread1.Sheets[0].Cells[Fpspread1.Sheets[0].RowCount - 1, 3].HorizontalAlign = HorizontalAlign.Center;
                                    Fpspread1.Sheets[0].Cells[Fpspread1.Sheets[0].RowCount - 1, 3].Font.Name       = "Book Antiqua";

                                    Fpspread1.Sheets[0].Cells[Fpspread1.Sheets[0].RowCount - 1, 4].Text            = Convert.ToString(dv[i]["desig_name"]);
                                    Fpspread1.Sheets[0].Cells[Fpspread1.Sheets[0].RowCount - 1, 4].Tag             = Convert.ToString(dv[i]["desig_code"]);
                                    Fpspread1.Sheets[0].Cells[Fpspread1.Sheets[0].RowCount - 1, 4].Note            = Convert.ToString(dv[i]["dept_code"]);
                                    Fpspread1.Sheets[0].Cells[Fpspread1.Sheets[0].RowCount - 1, 4].HorizontalAlign = HorizontalAlign.Left;
                                    Fpspread1.Sheets[0].Cells[Fpspread1.Sheets[0].RowCount - 1, 4].Font.Name       = "Book Antiqua";

                                    Fpspread1.Sheets[0].Cells[Fpspread1.Sheets[0].RowCount - 1, 5].CellType        = DoubleHrs;
                                    Fpspread1.Sheets[0].Cells[Fpspread1.Sheets[0].RowCount - 1, 5].Text            = Convert.ToString(dv[i]["Tot_Hrs"]);
                                    Fpspread1.Sheets[0].Cells[Fpspread1.Sheets[0].RowCount - 1, 5].HorizontalAlign = HorizontalAlign.Center;
                                    Fpspread1.Sheets[0].Cells[Fpspread1.Sheets[0].RowCount - 1, 5].Font.Name       = "Book Antiqua";

                                    Fpspread1.Sheets[0].Cells[Fpspread1.Sheets[0].RowCount - 1, 6].Text            = Convert.ToString(dv[i]["Amnt_Per_Hrs"]);
                                    Fpspread1.Sheets[0].Cells[Fpspread1.Sheets[0].RowCount - 1, 6].HorizontalAlign = HorizontalAlign.Center;
                                    Fpspread1.Sheets[0].Cells[Fpspread1.Sheets[0].RowCount - 1, 6].Font.Name       = "Book Antiqua";
                                }
                            }
                            else
                            {
                                Fpspread1.Sheets[0].Rows[Fpspread1.Sheets[0].RowCount - 1].Remove();
                            }
                        }
                    }
                }
            }
            else
            {
                Fpspread1.Sheets[0].Rows[Fpspread1.Sheets[0].RowCount - 1].Remove();
            }

            Fpspread1.Sheets[0].PageSize = Fpspread1.Sheets[0].RowCount;
            Fpspread1.Sheets[0].SetColumnMerge(2, FarPoint.Web.Spread.Model.MergePolicy.Always);
            Fpspread1.Visible  = true;
            rprint.Visible     = true;
            btnSave.Visible    = true;
            lblMainErr.Visible = false;
        }
        catch (Exception e)
        {
            e.ToString();
        }
    }