예제 #1
0
        /// <summary>
        /// show vacation details
        /// </summary>
        private void BindVactionDetails()
        {
            GetStaffDetails getStaffDetails = new GetStaffDetails();
            StaffDetails    staffDetails    = new StaffDetails();

            staffDetails = getStaffDetails.GetStaffDetail(showStaffInfo);

            lblTA.Text = staffDetails.totalAnnualLeave;         //total annual leave
            lblUA.Text = staffDetails.usedAnnualLeave;          //used annual leave
            lblAB.Text = staffDetails.annualLeaveBalance;       //annual leave balance

            lblTS.Text    = staffDetails.totalSickLeave;        //Total sick leave
            lblUS.Text    = staffDetails.usedSickLeave;         //Used sick leave
            lblSB.Text    = staffDetails.sickLeaveBalance;      //sick leave balance
            lblLYUSL.Text = staffDetails.lastyearUsedSickLeave; //last year used sick leave

            lblUNP.Text = staffDetails.usednopayLeave;          //Used NoPay leave
            lblUML.Text = staffDetails.usedmarriageLeave;       //Used Marriage leave
            lblUCL.Text = staffDetails.usedcompassionate;       //Used Compassionate leave

            if (Convert.ToInt32(showStaffInfo.Gender) > 0)
            {
                lblUPL.Text = staffDetails.usedpaternity;//Used Paternity leave
            }
            else
            {
                lblUsedPaternityLeave.Text = "Used Maternity Leave";
                lblUPL.Text = staffDetails.usedmaternity;//Used Maternity leave
            }

            annualLeaveRemainDay = Convert.ToSingle(staffDetails.annualLeaveBalance);
            sickLeaveRemainDay   = Convert.ToSingle(staffDetails.sickLeaveBalance);
            if (annualLeaveRemainDay <= 0)
            {
                lblAB.ForeColor = Color.Red;
            }
            if (sickLeaveRemainDay <= 0)
            {
                lblSB.ForeColor = Color.Red;
            }
        }
예제 #2
0
파일: StaffList.cs 프로젝트: willdarwin/vms
        /// <summary>
        /// Prints all.
        /// </summary>
        /// <param name="dt">The dt.</param>
        public void printAll(System.Data.DataTable dt)
        {
            try
            {
                if (dt.Rows.Count == 0)
                {
                    return;
                }

                string         saveFileName = "";
                SaveFileDialog saveDialog   = new SaveFileDialog();
                saveDialog.DefaultExt = "xlsx";
                saveDialog.FileName   = "VIT TJ Staff List " + DateTime.Today.ToString("yyyy-MM-dd");
                saveDialog.ShowDialog();
                saveFileName = saveDialog.FileName;
                if (saveFileName.IndexOf(":") < 0)
                {
                    return;
                }

                Excel.Application myExcel = new Excel.Application();
                if (myExcel == null)
                {
                    MessageBox.Show("Can not Create a Sheet! Make Sure your computer has installed the Excel!");
                    return;
                }

                myExcel.Application.Workbooks.Add(true);
                myExcel.Visible = false;

                Excel.Workbook  myBook  = myExcel.Workbooks[1];
                Excel.Worksheet mySheet = myBook.Worksheets[1];
                mySheet.Name = "VITC";
                mySheet.Columns.ColumnWidth         = 15;
                mySheet.Rows[1].RowHeight           = 50;
                mySheet.Rows[1].Interior.ColorIndex = 23;
                mySheet.Rows[1].Font.Size           = 12;
                mySheet.Rows[1].HorizontalAlignment = Excel.Constants.xlCenter;
                mySheet.Rows[1].VerticalAlignment   = Excel.Constants.xlCenter;
                mySheet.Range[mySheet.Cells[1, dt.Columns.Count + 1], mySheet.Cells[1, dt.Columns.Count + 8]].ColumnWidth = 20;


                for (int i = 0; i < dt.Columns.Count; i++)
                {
                    mySheet.Cells[1, i + 1] = dgrdDisplayStaffInfo.Columns[i].HeaderText;
                }
                mySheet.Cells[1, dt.Columns.Count + 1] = "Last Year Annual Leave Balance";
                mySheet.Cells[1, dt.Columns.Count + 2] = "Total Annual Leave";
                mySheet.Cells[1, dt.Columns.Count + 3] = "Used Annual Leave";
                mySheet.Cells[1, dt.Columns.Count + 4] = "Annual Leave Balance";
                mySheet.Cells[1, dt.Columns.Count + 5] = "Total Sick Leave";
                mySheet.Cells[1, dt.Columns.Count + 6] = "Used Sick Leave";
                mySheet.Cells[1, dt.Columns.Count + 7] = "Sick Leave Balance";
                mySheet.Cells[1, dt.Columns.Count + 8] = "Last Year Used Sick Leave";

                if (dt.Rows.Count > 0)
                {
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        for (int j = 0; j < dt.Columns.Count; j++)
                        {
                            string str = dt.Rows[i][j].ToString();
                            if (j == dt.Columns.Count - 1)
                            {
                                if (str.Length < 5)
                                {
                                    str = "0";
                                }
                                else if (Convert.ToSingle(str) < 0)
                                {
                                    if (str.Length == 5)
                                    {
                                        str = "0";
                                    }
                                    else
                                    {
                                        String lyb = str;
                                        lyb = lyb.Substring(5);
                                        str = Convert.ToSingle("-" + lyb).ToString();
                                    }
                                }
                                else
                                {
                                    str = Convert.ToSingle(str.Substring(4)).ToString();
                                }
                            }
                            if (j == 8)
                            {
                                if (str == "1")
                                {
                                    str = "M";
                                }
                                else
                                {
                                    str = "F";
                                }
                            }
                            mySheet.Cells[i + 2, j + 2] = "'" + str;
                        }
                        GetStaffDetails getStaffDetails = new GetStaffDetails();
                        Staff           staffinfo       = new Staff();
                        staffinfo = getStaffDetails.Getstaff(Convert.ToInt32(dt.Rows[i][0].ToString()));
                        StaffDetails staffDetails = getStaffDetails.GetStaffDetail(staffinfo);
                        mySheet.Cells[i + 2, dt.Columns.Count + 2] = "'" + staffDetails.totalAnnualLeave;
                        mySheet.Cells[i + 2, dt.Columns.Count + 3] = "'" + staffDetails.usedAnnualLeave;
                        mySheet.Cells[i + 2, dt.Columns.Count + 4] = "'" + staffDetails.annualLeaveBalance;
                        mySheet.Cells[i + 2, dt.Columns.Count + 5] = "'" + staffDetails.totalSickLeave;
                        mySheet.Cells[i + 2, dt.Columns.Count + 6] = "'" + staffDetails.usedSickLeave;
                        mySheet.Cells[i + 2, dt.Columns.Count + 7] = "'" + staffDetails.sickLeaveBalance;
                        mySheet.Cells[i + 2, dt.Columns.Count + 8] = "'" + staffDetails.lastyearUsedSickLeave;
                    }
                }

                myBook.SaveCopyAs(saveFileName);
                myBook.Close(false, Type.Missing, Type.Missing);

                myExcel.Quit();
                myExcel = null;
                GC.Collect();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "error" + ex);
            }
        }