Exemple #1
0
        private void OnCellMouseUp(object sender, DataGridViewCellMouseEventArgs e)
        {
            if (curClicked != null && curClicked.RowIndex >= 0)
            {
                AppGrid.InvalidateCell(curClicked);
            }

            curClicked = null;
        }
Exemple #2
0
        private void OnCellMouseDown(object sender, DataGridViewCellMouseEventArgs e)
        {
            if (e.RowIndex < 0 || e.ColumnIndex < 6)
            {
                return;
            }

            curClicked = AppGrid.Rows[e.RowIndex].Cells[e.ColumnIndex];
            AppGrid.InvalidateCell(curClicked);
        }
 public override void Validate(AppControl control)
 {
     if ((control.DataSource != null) && !(control.Control is AppGridTree))
     {
         AppGrid grid = control.Control as AppGrid;
         if (((grid == null) || ((grid.Row == null) || (grid.Row.AppGridCells.Count <= 0))) || string.IsNullOrEmpty(grid.Row.AppGridCells[0].CellType))
         {
             base.Results.AddRange(ValidateSql(control));
         }
     }
 }
Exemple #4
0
        private void OnCellMouseLeave(object sender, DataGridViewCellEventArgs e)
        {
            curRow = -1;
            curCol = -1;

            if (e.RowIndex < 0 || e.ColumnIndex < 6)
            {
                return;
            }

            AppGrid.InvalidateCell(AppGrid.Rows[e.RowIndex].Cells[e.ColumnIndex]);
        }
Exemple #5
0
        private void OnCellMouseEnter(object sender, DataGridViewCellEventArgs e)
        {
            curRow = e.RowIndex;
            curCol = e.ColumnIndex;

            if (e.RowIndex < 0 || e.ColumnIndex < 6)
            {
                return;
            }

            AppGrid.InvalidateCell(AppGrid.Rows[curRow].Cells[curCol]);
        }
        public override void Validate(AppControl control)
        {
            AppGrid grid = control.Control as AppGrid;

            if (grid == null)
            {
                return;                //不是grid
            }
            if (control.DataSource != null)
            {
                ValidateDataSource(control.DataSource);
            }

            ValidateColumns(grid, control.DataSource, control.State.IsSqlPassed);
        }
        /// <summary>
        /// 检测表格中数据列的列名是否包含在SQL中
        /// </summary>
        /// <param name="grid"></param>
        /// <param name="ds"></param>
        /// <param name="isSqlPassed"></param>
        /// <returns></returns>
        private void ValidateColumns(AppGrid grid, DataSource ds, bool isSqlPassed)
        {
            if (ds.Type.EqualIgnoreCase("sp") || ds.Type.EqualIgnoreCase("StoredProcedure"))
            {
                return;                                                                              //存储过程不处理
            }
            if (string.IsNullOrEmpty(ds.Sql))
            {
                return;
            }

            //检查数据列是否在SQL语句中
            int begin = ds.Sql.IndexOf("select", StringComparison.OrdinalIgnoreCase);
            int end   = ds.Sql.IndexOf("from", StringComparison.OrdinalIgnoreCase);

            if (end < begin || end < 0)
            {
                return;
            }
            if (ds.Sql.IndexOf("*", begin, end - begin, StringComparison.OrdinalIgnoreCase) < 0)
            {
                //如果没有*
                if (grid.Row == null || grid.Row.AppGridCells == null)
                {
                    return;
                }

                //如果SQL语法没问题则校验绑定字段是否存在
                if (isSqlPassed)
                {
                    foreach (var appGridCell in grid.Row.AppGridCells)
                    {
                        if (ds.Sql.IndexOf(appGridCell.Field, StringComparison.OrdinalIgnoreCase) < 0)
                        {
                            Results.Add(new Result(string.Format("检查数据列{0}", appGridCell.Field),
                                                   string.Format("SQL中未包含{0}", appGridCell.Field), Level.Error,
                                                   GetType()));
                        }
                    }
                }
            }
        }
Exemple #8
0
        //create and position window elements
        private void initializeWindow()
        {
            this.WindowStartupLocation = WindowStartupLocation.CenterScreen;
            WindowState  = WindowState.Maximized;
            WindowCanvas = new Canvas();
            createGrid();
            createSidePanel();
            AppGrid.Focus();

            populateGrid = new Levels(this);


            populateGrid.levels[0]();



            this.Content = WindowCanvas;
            Mover        = new Movement(this);
            setupPageEvents();
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                emp = Session["Employee"] as List <Employee_t>;

                if (emp != null)
                {
                    if (emp[0].PwdReset == 1)
                    {
                        Response.Redirect("~/ResetPassword.aspx", false);
                    }

                    name.Text = emp[0].Firstname + "" + emp[0].Lastname;
                    using (PerformanceAppEntities db = new PerformanceAppEntities())
                    {
                        int         empId = emp[0].Emp_Id;
                        var         query = db.Appraisal_t.Where(m => m.EmpId == empId);
                        Appraisal_t app   = null;
                        if (query.Count() != 0)
                        {
                            app = query.ToList().Single();
                        }
                        DataTable  Self_Emp = new DataTable();
                        DataColumn Emp_Id   = new DataColumn("Emp_Id", System.Type.GetType("System.Int32"));
                        Self_Emp.Columns.Add(Emp_Id);
                        DataColumn Name = new DataColumn("Name", System.Type.GetType("System.String"));
                        Self_Emp.Columns.Add(Name);
                        DataColumn AppPeriod = new DataColumn("AppPeriod", System.Type.GetType("System.String"));
                        Self_Emp.Columns.Add(AppPeriod);
                        DataColumn AppStatus = new DataColumn("AppStatus", System.Type.GetType("System.String"));
                        Self_Emp.Columns.Add(AppStatus);

                        for (int i = 0; i < emp.Count; i++)
                        {
                            DataRow row = Self_Emp.NewRow();
                            row["Emp_Id"] = emp[i].Emp_Id;
                            row["Name"]   = emp[i].Firstname + "" + emp[i].Lastname;
                            if (app != null)
                            {
                                DateTime from = app.From ?? DateTime.Now;
                                DateTime to   = app.To ?? DateTime.Now;
                                row["AppPeriod"] = from.ToString("dd-MM-yyyy") + " to " + to.ToString("dd-MM-yyyy");
                            }
                            else
                            {
                                row["AppPeriod"] = DateTime.Now.ToString("dd-MM-yyyy") + " to " + DateTime.Now.AddDays(30).ToString("dd-MM-yyyy");
                            }

                            if (app == null)
                            {
                                row["AppStatus"] = "Not Completed";
                            }
                            else if (app.Status == 1 || app.Status == null)
                            {
                                row["AppStatus"] = "partially Completed";
                            }
                            else
                            {
                                row["AppStatus"] = "Completed";
                            }
                            Self_Emp.Rows.Add(row);
                            Self_Emp.AcceptChanges();
                        }
                        if (app != null)
                        {
                            if (app.Status == 0 || app.Status == 1)
                            {
                                SelfGrid.DataSource = Self_Emp;
                                SelfGrid.DataBind();
                            }
                            else
                            {
                                SelfGrid.DataSource = null;
                                SelfGrid.DataBind();
                            }
                        }
                        else
                        {
                            SelfGrid.DataSource = Self_Emp;
                            SelfGrid.DataBind();
                        }


                        var query1 = db.Employee_t.Where(m => m.Appraiser == empId);
                        List <Employee_t> AppEmployee = null;
                        DataTable         App_Emp     = new DataTable();
                        DataColumn        AppEmp_Id   = new DataColumn("Emp_Id", System.Type.GetType("System.Int32"));
                        App_Emp.Columns.Add(AppEmp_Id);
                        DataColumn AppName = new DataColumn("Name", System.Type.GetType("System.String"));
                        App_Emp.Columns.Add(AppName);
                        DataColumn AppPeriod1 = new DataColumn("AppPeriod", System.Type.GetType("System.String"));
                        App_Emp.Columns.Add(AppPeriod1);
                        DataColumn AppStatus1 = new DataColumn("AppStatus", System.Type.GetType("System.String"));
                        App_Emp.Columns.Add(AppStatus1);
                        if (query1.Count() != 0)
                        {
                            AppEmployee = query1.ToList();
                        }
                        else
                        {
                            tabs1.Visible = false;
                        }
                        if (AppEmployee != null)
                        {
                            for (int i = 0; i < AppEmployee.Count; i++)
                            {
                                DataRow row = App_Emp.NewRow();
                                int     Id  = AppEmployee[i].Emp_Id;
                                row["Emp_Id"] = AppEmployee[i].Emp_Id;
                                row["Name"]   = AppEmployee[i].Firstname + "" + AppEmployee[i].Lastname;
                                var         appappraisal = db.Appraisal_t.Where(m => m.EmpId == Id);
                                Appraisal_t appAppr      = null;
                                if (appappraisal.Count() != 0)
                                {
                                    appAppr = appappraisal.Single();
                                    DateTime from = appAppr.From ?? DateTime.Now;
                                    DateTime to   = appAppr.To ?? DateTime.Now;
                                    row["AppPeriod"] = from.ToString("dd-MM-yyyy") + " to " + to.ToString("dd-MM-yyyy");
                                }
                                else
                                {
                                    row["AppPeriod"] = DateTime.Now.ToString("dd-MM-yyyy") + " to " + DateTime.Now.AddDays(30).ToString("dd-MM-yyyy");
                                }

                                if (appAppr == null)
                                {
                                    row["AppStatus"] = "Not Completed";
                                }
                                else if (appAppr.Status == 1)
                                {
                                    row["AppStatus"] = "partially Completed";
                                }
                                else if (appAppr.Status == 2)
                                {
                                    row["AppStatus"] = "Completed";
                                }
                                else if (appAppr.Status == 3)
                                {
                                    row["AppStatus"] = "Appraiser Review Completed";
                                }
                                else if (appAppr.Status == 4)
                                {
                                    row["AppStatus"] = "Reviewer Review Completed";
                                }

                                App_Emp.Rows.Add(row);
                                App_Emp.AcceptChanges();
                            }
                            AppGrid.DataSource = App_Emp;
                            AppGrid.DataBind();
                        }

                        var query2 = db.Employee_t.Where(m => m.Reviewer == empId);
                        List <Employee_t> RevEmployee = null;
                        DataTable         Rev_Emp     = new DataTable();
                        DataColumn        RevEmp_Id   = new DataColumn("Emp_Id", System.Type.GetType("System.Int32"));
                        Rev_Emp.Columns.Add(RevEmp_Id);
                        DataColumn RevName = new DataColumn("Name", System.Type.GetType("System.String"));
                        Rev_Emp.Columns.Add(RevName);
                        DataColumn AppPeriod2 = new DataColumn("AppPeriod", System.Type.GetType("System.String"));
                        Rev_Emp.Columns.Add(AppPeriod2);
                        DataColumn AppStatus2 = new DataColumn("AppStatus", System.Type.GetType("System.String"));
                        Rev_Emp.Columns.Add(AppStatus2);
                        if (query2.Count() != 0)
                        {
                            RevEmployee = query2.ToList();
                        }
                        else
                        {
                            tabs2.Visible = false;
                        }
                        if (RevEmployee != null)
                        {
                            for (int i = 0; i < RevEmployee.Count; i++)
                            {
                                DataRow row = Rev_Emp.NewRow();
                                int     Id  = RevEmployee[i].Emp_Id;
                                row["Emp_Id"] = RevEmployee[i].Emp_Id;
                                row["Name"]   = RevEmployee[i].Firstname + "" + RevEmployee[i].Lastname;
                                var         appappraisal1 = db.Appraisal_t.Where(m => m.EmpId == Id);
                                Appraisal_t RevAppr       = null;
                                if (appappraisal1.Count() != 0)
                                {
                                    RevAppr = appappraisal1.Single();
                                    DateTime from = RevAppr.From ?? DateTime.Now;
                                    DateTime to   = RevAppr.To ?? DateTime.Now;
                                    row["AppPeriod"] = from.ToString("dd-MM-yyyy") + " to " + to.ToString("dd-MM-yyyy");
                                }
                                else
                                {
                                    row["AppPeriod"] = DateTime.Now.ToString("dd-MM-yyyy") + " to " + DateTime.Now.AddDays(30).ToString("dd-MM-yyyy");
                                }

                                if (RevAppr == null)
                                {
                                    row["AppStatus"] = "Not Completed";
                                }
                                else if (RevAppr.Status == 1)
                                {
                                    row["AppStatus"] = "partially Completed";
                                }
                                else if (RevAppr.Status == 2)
                                {
                                    row["AppStatus"] = "Completed";
                                }
                                else if (RevAppr.Status == 3)
                                {
                                    row["AppStatus"] = "Appraiser Review Completed";
                                }
                                else if (RevAppr.Status == 4)
                                {
                                    row["AppStatus"] = "Reviewer Review Completed";
                                }
                                Rev_Emp.Rows.Add(row);
                                Rev_Emp.AcceptChanges();
                            }
                            RevGrid.DataSource = Rev_Emp;
                            RevGrid.DataBind();
                        }
                    }
                }
                else
                {
                    Response.Redirect("~/Login.aspx", false);
                }
            }
            catch (Exception ex)
            {
                using (PerformanceAppEntities db = new PerformanceAppEntities())
                {
                    Log_t log = new Log_t();
                    log.Error_Message = ex.Message;

                    log.Page     = "Dashboard";
                    log.Method   = "Page_Load";
                    log.Datetime = DateTime.Now;
                    db.Log_t.Add(log);
                    db.SaveChanges();
                    Response.Redirect("~/Login.aspx", false);
                }
            }
        }
 private void SchedulePatient_ModalDialogCancel(object sender, EventArgs e)
 {
     this.AppGrid.ClearSelectedIndex();
     this.Button1_Click(this.Button1, EventArgs.Empty);
     AppGrid.DataBind();
 }
Exemple #11
0
        public override void Validate(AppControl control)
        {
            AppGrid grid = control.Control as AppGrid;

            if (grid == null)
            {
                return;  //不是grid
            }

            var ds = control.DataSource;

            if (ds == null)
            {
                Results.Add(new Result("AppGridE", "未配置数据源", Level.Warn, typeof(AppGridEValidation)));
                return;
            }

            if (grid.Row != null && grid.Row.AppGridCells.Count > 0)
            {
                //List<bool> _sumtype = new List<bool>();
                string _strSumTemp = "";

                if (grid.Summary != null && grid.Summary.AppGridCells.Count > 0)
                {
                    for (int i = 0; i < grid.Summary.AppGridCells.Count; i++)
                    {
                        var scell = grid.Summary.AppGridCells[i];
                        if (scell.SumTotalField.IsNotNullOrEmpty())
                        {
                            _strSumTemp += "," + scell.SumTotalField + " AS _s" + i;
                        }
                    }
                }

                //appGridE, appGrid
                foreach (var cell in grid.Row.AppGridCells)
                {
                    string strSql1 = "", strSql2 = "", _strSQL = "";
                    string error = string.Empty;

                    //替换关键字
                    string strSQL = CommonValidation.GetFilter(ds.Sql);

                    if (ds.PageMode.EqualIgnoreCase("2"))
                    {
                        string[] arrSql = SplitSql(strSQL);

                        if (arrSql != null)
                        {
                            strSql1 = arrSql[0];                                // 外层不带“SELECT”关键字的部分 SQL 语句
                            strSQL  = arrSql[1];                                // 内层从“SELECT”关键字开始的 SQL 语句
                            strSql2 = GetSortedSql(arrSql[2], cell, ds);        // 外层 SQL
                        }
                    }

                    strSQL = GetSortedSql(strSQL, cell, ds);

                    //是否分页allowpaging, pageSize == 0
                    //allowpaing
                    if (ds.KeyName.IsNotNullOrEmpty())
                    {
                        //取记录数 if showPageCount
                        string strSQLTemp = Regex.Replace(strSQL, @"SELECT\s+([\w|\W]+)\s+FROM", "SELECT COUNT(*)" + _strSumTemp + " FROM");
                        strSQLTemp = Regex.Replace(strSQLTemp, @"\s+ORDER BY([\w|\W]+)", "");
                        if (!ValidateSql(strSQLTemp, out error))
                        {
                            Results.Add(new Result(string.Format("检查数据列{0}", cell.Field),
                                                   string.Format("{0}字段当showPageCount == true时会出错:{1}", cell.OrderBy, error), Level.Warn,
                                                   GetType()));
                            return;
                        }

                        if (ds.PageMode.EqualIgnoreCase("2"))
                        {
                            _strSQL = GetPageSql(strSQL, ds.Entity, ds.KeyName, ds.PageMode);
                            _strSQL = strSql1 + _strSQL + strSql2;
                        }
                        else
                        {
                            _strSQL = GetPageSql(strSQL, ds.Entity, ds.KeyName, ds.PageMode);
                        }
                    }
                    else
                    {
                        //不指定主键的分页查询
                    }

                    if (strSQL.IsNotNullOrEmpty() && !ValidateSql(_strSQL, out error))
                    {
                        Results.Add(new Result(string.Format("检查数据列{0}", cell.Field),
                                               string.Format("排序字段配置错误{0}:{1}", cell.OrderBy, error), Level.Error,
                                               GetType()));
                    }

                    if (cell.Attribute != null)
                    {
                        foreach (var attr in cell.Attribute.Attributes)
                        {
                            if (attr.Name.EqualIgnoreCase("sql"))
                            {
                                if (CommonValidation.IsIncorrectSql(attr.Value))
                                {
                                    Results.Add(new Result("AppGridE",
                                                           string.Format("[{0}]单元格的SQL有误:{1}", cell.Title,
                                                                         attr.Value), Level.Error,
                                                           typeof(AppGridEValidation)));
                                }
                            }
                        }
                    }
                }
            }
        }