Esempio n. 1
0
        /// <summary>
        /// 포커스가 가 있는 그리드의 정보를 리턴합니다.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="type">The type.</param>
        /// <returns></returns>
        private GrdInfo GetFocusGridIndex(object sender)
        {
            try
            {
                GrdInfo info = new GrdInfo();
                info.IsValue = false;

                DevExpress.XtraGrid.GridControl         grdtmp  = new GridControl();
                DevExpress.XtraGrid.Views.Grid.GridView grdview = new GridView();

                if (sender.ToString() != "DevExpress.XtraGrid.Views.Grid.GridView")
                {
                    grdtmp  = (GridControl)sender;
                    grdview = (GridView)grdtmp.Views[0];
                }
                else
                {
                    grdview = (GridView)sender;
                }

                if (grdview.GetFocusedValue().ToString().Trim() == "")
                {
                    return(info);
                }



                string[] Arry = grdview.Name.Split('_');

                int    index = int.Parse(Arry[1]) - 1;
                string day   = string.Format("{0:00}", int.Parse(grdview.GetFocusedValue().ToString().Trim()));
                string mon   = string.Format("{0:00}", index + 1);


                info.Day      = day;
                info.Month    = mon;
                info.GrdIndex = index;

                string key = Year + "-" + mon + "-" + day;

                //인덱스로 찾는다 select 보다 빠르다
                DataRow r = dtHoliday.Rows.Find(new object[] { key });

                if (r == null)
                {
                    return(info);
                }

                info.HolidayName = r["HOLIDAY_NAME"].ToString().Trim();
                info.ymd         = key;
                info.IsValue     = true;
                return(info);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Esempio n. 2
0
 /// <summary>
 /// 휴일텍스트를 출력
 /// </summary>
 /// <param name="info">휴일정보.</param>
 /// <param name="point">좌표값.</param>
 private void ShowHoliDay(GrdInfo info, System.Drawing.Point point)
 {
     try
     {
         if (!info.IsValue)
         {
             return;
         }
         this.txtHoli.Tag      = info.ymd;
         this.txtHoli.Text     = info.HolidayName;
         this.txtHoli.Location = point;
         this.txtHoli.Visible  = true;
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Esempio n. 3
0
        /// <summary>
        /// 그리드에서의 엔터키
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.Windows.Forms.KeyEventArgs"/> instance containing the event data.</param>
        private void Grid_KeyDown(object sender, KeyEventArgs e)
        {
            try
            {
                if (e.KeyCode != Keys.Enter)
                {
                    return;
                }
                this.txtHoli.Text = "";
                this.txtHoli.Tag  = null;

                if (((GridView)((GridControl)sender).Views[0]).FocusedRowHandle < 0)
                {
                    return;
                }

                if (((DataTable)(((GridControl)sender).DataSource) == null ||
                     ((DataTable)((GridControl)sender).DataSource).Rows.Count <= 0))
                {
                    return;
                }

                GrdInfo info = GetFocusGridIndex(sender);

                if (!info.IsValue)
                {
                    return;
                }

                int XX = ((GridControl)sender).Location.X;
                int YY = ((GridControl)sender).Location.Y;
                int X  = 15 + 28 * ((GridView)((GridControl)sender).Views[0]).FocusedColumn.ColumnHandle;
                int Y  = 30 + 20 * ((GridView)((GridControl)sender).Views[0]).FocusedRowHandle;


                ShowHoliDay(info, new System.Drawing.Point(X + XX, Y + YY));
            }
            catch (Exception ex)
            {
                Basic.ShowMessage(3, ex.Message);
            }
        }
Esempio n. 4
0
        /// <summary>
        /// 그리드 더블클릭
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.Windows.Forms.MouseEventArgs"/> instance containing the event data.</param>
        private void Grid_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            try
            {
                this.txtHoli.Text = "";
                this.txtHoli.Tag  = null;

                DevExpress.XtraGrid.Views.Grid.ViewInfo.GridHitInfo hi = (((GridView)((GridControl)sender).Views[0]).CalcHitInfo(new Point(e.X, e.Y)));
                int iRow = hi.RowHandle;
                if (iRow < 0)
                {
                    return;
                }

                if (((DataTable)(((GridControl)sender).DataSource) == null ||
                     ((DataTable)((GridControl)sender).DataSource).Rows.Count <= 0))
                {
                    return;
                }

                GrdInfo info = GetFocusGridIndex(sender);

                if (!info.IsValue)
                {
                    return;
                }

                int XX = ((GridControl)sender).Location.X;
                int YY = ((GridControl)sender).Location.Y;
                int X  = 15 + 28 * ((GridView)((GridControl)sender).Views[0]).FocusedColumn.ColumnHandle;
                int Y  = 30 + 20 * ((GridView)((GridControl)sender).Views[0]).FocusedRowHandle;


                ShowHoliDay(info, new System.Drawing.Point(X + XX, Y + YY));
            }
            catch (Exception ex)
            {
                Basic.ShowMessage(3, ex.Message);
            }
        }