Esempio n. 1
0
        public void BindData(ReportFilter filter)
        {
            try
            {
                xrl_TenCongTy.Text = ReportController.GetInstance().GetCompanyName(filter.SessionDepartment);
                var location = new ReportController().GetCityName(filter.SessionDepartment);
                xrtngayketxuat.Text = string.Format(xrtngayketxuat.Text, location, DateTime.Now.Day,
                                                    DateTime.Now.Month, DateTime.Now.Year);
                var month = filter.StartMonth != 0 ? filter.StartMonth : 1;
                var year  = filter.Year < 1900 ? DateTime.Now.Year : filter.Year;
                // get organization
                var organization = cat_DepartmentServices.GetByDepartments(filter.SessionDepartment);
                if (organization == null)
                {
                    return;
                }

                //select form db
                var departments = string.IsNullOrEmpty(filter.SelectedDepartment)
                    ? new string[] { }
                    : filter.SelectedDepartment.Split(new[] { "," }, StringSplitOptions.RemoveEmptyEntries);
                for (int i = 0; i < departments.Length; i++)
                {
                    departments[i] = "'{0}'".FormatWith(departments[i]);
                }

                var table = SQLHelper.ExecuteTable(SQLManagementAdapter.GetStore_ExpiredContractInMonth(
                                                       string.Join(",",
                                                                   departments), month, year));

                DataSource = table;
                //binding data
                xrt_EmployeeCode.DataBindings.Add("Text", DataSource, "EmployeeCode");
                xrt_FullName.DataBindings.Add("Text", DataSource, "FullName");
                xrt_Sex.DataBindings.Add("Text", DataSource, "SexName");
                xrt_Department.DataBindings.Add("Text", DataSource, "DepartmentName");
                xrt_ContractDate.DataBindings.Add("Text", DataSource, "ContractDate", "{0:dd/MM/yyyy}");
                xrt_ContractEndDate.DataBindings.Add("Text", DataSource, "ContractEndDate", "{0:dd/MM/yyyy}");
                xrt_Position.DataBindings.Add("Text", DataSource, "PositionName");
                xrt_ContractType.DataBindings.Add("Text", DataSource, "ContractTypeName");
                xrt_Education.DataBindings.Add("Text", DataSource, "EducationName");
                GroupHeader1.GroupFields.AddRange(new[] { new GroupField("DepartmentId", XRColumnSortOrder.Ascending) });
                xrDepartmentName.DataBindings.Add("Text", DataSource, "DepartmentName");
            }
            catch (Exception ex)
            {
                Dialog.Alert("Có lỗi xảy ra: " + ex.Message);
            }
        }