Exemplo n.º 1
0
        private void dgLichKham_CellLostFocus(object sender, SourceGrid2.PositionCancelEventArgs e)
        {
            if (e.Position.Column < 3 || e.Position.Row < 2)
            {
                return;
            }
            SourceGrid2.Cells.Real.Cell cell = e.Cell as SourceGrid2.Cells.Real.Cell;
            object value    = cell.Value;
            string strValue = value == null ? string.Empty : value.ToString().Trim();

            if (_currentValue == strValue)
            {
                return;
            }

            LichKham lichKham = cell.Tag as LichKham;

            if (lichKham == null)
            {
                lichKham             = new LichKham();
                lichKham.Ngay        = Convert.ToDateTime(dgLichKham[e.Position.Row, 0].Tag);
                lichKham.Type        = (int)GetLoaiLichKham(e.Position.Column - 1);
                lichKham.Value       = strValue;
                lichKham.CreatedDate = DateTime.Now;
                lichKham.CreatedBy   = Guid.Parse(Global.UserGUID);
            }
            else
            {
                lichKham.Value       = strValue;
                lichKham.UpdatedDate = DateTime.Now;
                lichKham.UpdatedBy   = Guid.Parse(Global.UserGUID);
            }

            Result result = LichKhamBus.InsertLichKham(lichKham);

            if (result.IsOK)
            {
                cell.Tag = lichKham;
            }
            else
            {
                MsgBox.Show(Application.ProductName, result.GetErrorAsString("LichKhamBus.InsertLichKham"), IconType.Error);
                Utility.WriteToTraceLog(result.GetErrorAsString("LichKhamBus.InsertLichKham"));
            }
        }
Exemplo n.º 2
0
        private void OnView()
        {
            SourceGrid2.Cells.Real.Cell cell = dgLichKham.FocusCell as SourceGrid2.Cells.Real.Cell;
            if (cell != null)
            {
                if (cell.Column < 3 || cell.Row < 2)
                {
                    return;
                }
                object value = cell.Value;
                _currentValue = value == null ? string.Empty : value.ToString().Trim();

                LichKham lichKham = cell.Tag as LichKham;
                if (lichKham == null)
                {
                    lichKham             = new LichKham();
                    lichKham.Ngay        = Convert.ToDateTime(dgLichKham[cell.Row, 0].Tag);
                    lichKham.Type        = (int)GetLoaiLichKham(cell.Column - 1);
                    lichKham.Value       = _currentValue;
                    lichKham.CreatedDate = DateTime.Now;
                    lichKham.CreatedBy   = Guid.Parse(Global.UserGUID);
                }
                else
                {
                    lichKham.Value       = _currentValue;
                    lichKham.UpdatedDate = DateTime.Now;
                    lichKham.UpdatedBy   = Guid.Parse(Global.UserGUID);
                }

                Result result = LichKhamBus.InsertLichKham(lichKham);
                if (result.IsOK)
                {
                    cell.Tag = lichKham;
                }
                else
                {
                    MsgBox.Show(Application.ProductName, result.GetErrorAsString("LichKhamBus.InsertLichKham"), IconType.Error);
                    Utility.WriteToTraceLog(result.GetErrorAsString("LichKhamBus.InsertLichKham"));
                }
            }

            DisplayAsThread();
        }
Exemplo n.º 3
0
        private void dgLichKham_KeyUp(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Delete && AllowEdit && dgLichKham.Selection != null)
            {
                List <SourceGrid2.Cells.Real.Cell> deletedCells = new List <SourceGrid2.Cells.Real.Cell>();
                foreach (SourceGrid2.Cells.Real.Cell cell in dgLichKham.Selection.GetCells())
                {
                    if (cell.Column < 3 || cell.Row < 2 || cell.Value == null ||
                        cell.Value.ToString().Trim() == string.Empty)
                    {
                        continue;
                    }

                    deletedCells.Add(cell);
                }

                foreach (SourceGrid2.Cells.Real.Cell cell in deletedCells)
                {
                    LichKham lichKham = cell.Tag as LichKham;
                    if (lichKham == null)
                    {
                        continue;
                    }
                    lichKham.UpdatedDate = DateTime.Now;
                    lichKham.UpdatedBy   = Guid.Parse(Global.UserGUID);
                    lichKham.Value       = string.Empty;

                    Result result = LichKhamBus.InsertLichKham(lichKham);
                    if (result.IsOK)
                    {
                        cell.Value = null;
                    }
                    else
                    {
                        MsgBox.Show(Application.ProductName, result.GetErrorAsString("LichKhamBus.InsertLichKham"), IconType.Error);
                        Utility.WriteToTraceLog(result.GetErrorAsString("LichKhamBus.InsertLichKham"));
                        return;
                    }
                }
            }

            dgLichKham.AutoSizeView(false);
        }
Exemplo n.º 4
0
        private void OnDisplayLichKham()
        {
            Result result = LichKhamBus.GetLichKhamTheoThang(_thang, _nam);

            if (result.IsOK)
            {
                MethodInvoker method = delegate
                {
                    ClearData();
                    int             colCount  = 15;
                    int             rowCount  = GetRowCount();
                    List <LichKham> lichKhams = result.QueryResult as List <LichKham>;

                    dgLichKham.Redim(rowCount, colCount);
                    dgLichKham.FixedRows    = 2;
                    dgLichKham.FixedColumns = 1;
                    InitHeader();
                    FillData(lichKhams);
                    dgLichKham.AutoSizeView(false);
                };

                if (InvokeRequired)
                {
                    BeginInvoke(method);
                }
                else
                {
                    method.Invoke();
                }
            }
            else
            {
                MsgBox.Show(Application.ProductName, result.GetErrorAsString("LichKhamBus.GetLichKhamTheoThang"), IconType.Error);
                Utility.WriteToTraceLog(result.GetErrorAsString("LichKhamBus.GetLichKhamTheoThang"));
            }
        }