Exemplo n.º 1
0
        private void BandedGridView_CellValueChanging(object sender, CellValueChangedEventArgs e)
        {
            if (InSetup)
            {
                return;
            }

            int ri = e.RowHandle;
            int ci = e.Column.AbsoluteIndex;

            if (e.Column == BackColor1 || e.Column == IconImage)             // force completion of edit
            {
                object value = e.Value;
                BandedGridView.CloseEditor();                  // Closes editor
                this.BeginInvoke((Action)(() =>                // safe way to execute lines below
                {
                    BandedGridView.SetRowCellValue(e.RowHandle, e.Column, value);
                    BandedGridView.ShowEditor();                     // open editor again
                }));
                return;
            }

            else if (ci == ValCol || ci == ValCol2)
            {
                if (e.Value == null || Lex.Ne(e.Value.ToString(), "User-defined"))
                {
                    return;                                                                                // blank out if user-defined
                }
                //ComboBoxEdit cb = BandedGridView.ActiveEditor as ComboBoxEdit;

                BandedGridView.CloseEditor();                                  // Closes editor

                this.BeginInvoke((Action)(() =>                                // safe way to execute lines below
                {
                    BandedGridView.SetRowCellValue(e.RowHandle, e.Column, ""); // blank value
                    BandedGridView.ShowEditor();                               // open editor again
                }));
            }

            return;
        }
Exemplo n.º 2
0
        private void gridView1_CellValueChanged(object sender, DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e)
        {
            if (!_reChecksumOnUpdate)
            {
                return;
            }
            // To prevent paste from clipboard
            if (e.RowHandle < 0)
            {
                return;
            }
            // To re-calculate checksum
            // Get original checksum value
            FileInfo fi = new FileInfo(Path.Combine(_currentResPath, lbRes.SelectedItem.ToString()));

            if (!_supportedFiles.ContainsKey(fi.Name.ToLower()))
            {
                XtraMessageBox.Show("Idk how but error");
                return;
            }
            var structdata = _supportedFiles[fi.Name.ToLower()];
            var lsData     = structdata.GetType().GetField("lsData").GetValue(structdata) as object[];

            if (lsData.Length <= e.RowHandle)
            {
                XtraMessageBox.Show("By someway, it's make error");
                return;
            }
            var fields = lsData[e.RowHandle].GetType().GetFields();

            if (fields.Length < e.Column.AbsoluteIndex)
            {
                XtraMessageBox.Show("Wtf did you do to make this error?");
                return;
            }
            var   originalValueField = fields[e.Column.AbsoluteIndex];
            Int64 originalChecksum   = this.GetChecksum(originalValueField.GetValue(lsData[e.RowHandle]));

            if (originalChecksum < 0)
            {
                BandedGridView view = sender as BandedGridView;
                view.SetRowCellValue(e.RowHandle, e.Column.FieldName, originalValueField.GetValue(lsData[e.RowHandle]));
                XtraMessageBox.Show("Not allow to update data here");
                return;
            }
            // Re-calculate checksum
            if (!_dataTable.ContainsKey(fi.Name.ToLower()))
            {
                XtraMessageBox.Show("Dahell is this error?");
                return;
            }
            Int64 newChecksum = this.GetChecksum(_dataTable[fi.Name.ToLower()].Rows[e.RowHandle][e.Column.AbsoluteIndex]);

            // Set checksum value
            _dataTable[fi.Name.ToLower()].Rows[e.RowHandle]["_checksum"] = Convert.ToInt64(_dataTable[fi.Name.ToLower()].Rows[e.RowHandle]["_checksum"]) - originalChecksum;
            _dataTable[fi.Name.ToLower()].Rows[e.RowHandle]["_checksum"] = Convert.ToInt64(_dataTable[fi.Name.ToLower()].Rows[e.RowHandle]["_checksum"]) + newChecksum;
            // Re-offset
            if ("String".Equals(originalValueField.FieldType.Name))
            {
                //long adjust = Encoding.Unicode.GetBytes(_dataTable[fi.Name.ToLower()].Rows[e.RowHandle][e.Column.AbsoluteIndex].ToString()).Length -
                //    Encoding.Unicode.GetBytes(originalValueField.GetValue(lsData[e.RowHandle]).ToString()).Length;
                //this.ReOffset(adjust, e.RowHandle + 1, fi.Name.ToLower(), lsData);
            }
        }
Exemplo n.º 3
0
        private void UpdateRow(HRM_EMPLOYEE item)
        {
            BandedGridView bandedGridView   = this.gbList;
            int            focusedRowHandle = this.gbList.FocusedRowHandle;

            bandedGridView.SetRowCellValue(focusedRowHandle, "SubsidiaryCode", item.SubsidiaryCode);
            bandedGridView.SetRowCellValue(focusedRowHandle, "BranchCode", item.BranchCode);
            bandedGridView.SetRowCellValue(focusedRowHandle, "DepartmentCode", item.DepartmentCode);
            bandedGridView.SetRowCellValue(focusedRowHandle, "GroupCode", item.GroupCode);
            bandedGridView.SetRowCellValue(focusedRowHandle, "EmployeeCode", item.EmployeeCode);
            bandedGridView.SetRowCellValue(focusedRowHandle, "FirstName", item.FirstName);
            bandedGridView.SetRowCellValue(focusedRowHandle, "LastName", item.LastName);
            bandedGridView.SetRowCellValue(focusedRowHandle, "BirthdayDay", item.BirthdayDay);
            bandedGridView.SetRowCellValue(focusedRowHandle, "BirthdayMonth", item.BirthdayMonth);
            bandedGridView.SetRowCellValue(focusedRowHandle, "BirthdayYear", item.BirthdayYear);
            bandedGridView.SetRowCellValue(focusedRowHandle, "BirthPlace", item.BirthPlace);
            bandedGridView.SetRowCellValue(focusedRowHandle, "Sex", item.Sex);
            bandedGridView.SetRowCellValue(focusedRowHandle, "CellPhone", item.CellPhone);
            bandedGridView.SetRowCellValue(focusedRowHandle, "HomePhone", item.HomePhone);
            bandedGridView.SetRowCellValue(focusedRowHandle, "MainAddress", item.MainAddress);
            bandedGridView.SetRowCellValue(focusedRowHandle, "ContactAddress", item.ContactAddress);
            bandedGridView.SetRowCellValue(focusedRowHandle, "Position", item.Position);
            bandedGridView.SetRowCellValue(focusedRowHandle, "IDCard", item.IDCard);
            bandedGridView.SetRowCellValue(focusedRowHandle, "IDCardPlace", item.IDCardPlace);
            bandedGridView.SetRowCellValue(focusedRowHandle, "IDCardDate", item.IDCardDate);
            bandedGridView.SetRowCellValue(focusedRowHandle, "Status", item.Status);
            bandedGridView.SetRowCellValue(focusedRowHandle, "TestFromDate", item.TestFromDate);
            bandedGridView.SetRowCellValue(focusedRowHandle, "TestToDate", item.TestToDate);
            bandedGridView.SetRowCellValue(focusedRowHandle, "BeginDate", item.BeginDate);
            bandedGridView.SetRowCellValue(focusedRowHandle, "EndDate", item.EndDate);
            bandedGridView.SetRowCellValue(focusedRowHandle, "Photo", item.Photo);
            bandedGridView.SetRowCellValue(focusedRowHandle, "Email", item.Email);
            bandedGridView.SetRowCellValue(focusedRowHandle, "Nationality", item.Nationality);
            bandedGridView.SetRowCellValue(focusedRowHandle, "Ethnic", item.Ethnic);
            bandedGridView.SetRowCellValue(focusedRowHandle, "Religion", item.Religion);
            bandedGridView.SetRowCellValue(focusedRowHandle, "Education", item.Education);
            bandedGridView.SetRowCellValue(focusedRowHandle, "Language", item.Language);
            bandedGridView.SetRowCellValue(focusedRowHandle, "Informatic", item.Informatic);
            bandedGridView.SetRowCellValue(focusedRowHandle, "Professional", item.Professional);
            bandedGridView.SetRowCellValue(focusedRowHandle, "Marriage", item.Marriage);
            bandedGridView.SetRowCellValue(focusedRowHandle, "InsuranceCode", item.InsuranceCode);
            bandedGridView.SetRowCellValue(focusedRowHandle, "InsuranceDate", item.InsuranceDate);
            bandedGridView.SetRowCellValue(focusedRowHandle, "BasicSalary", item.BasicSalary);
            bandedGridView.SetRowCellValue(focusedRowHandle, "InsuranceSalary", item.InsuranceSalary);
            bandedGridView.SetRowCellValue(focusedRowHandle, "DateSalary", item.DateSalary);
            bandedGridView.SetRowCellValue(focusedRowHandle, "Health", item.Health);
            bandedGridView.SetRowCellValue(focusedRowHandle, "Weight", item.Weight);
            bandedGridView.SetRowCellValue(focusedRowHandle, "Height", item.Height);
            bandedGridView.SetRowCellValue(focusedRowHandle, "ContractCode", item.ContractCode);
            bandedGridView.SetRowCellValue(focusedRowHandle, "ContractType", item.ContractType);
            bandedGridView.SetRowCellValue(focusedRowHandle, "ContractSignDate", item.ContractSignDate);
            bandedGridView.SetRowCellValue(focusedRowHandle, "ContractFromDate", item.ContractFromDate);
            bandedGridView.SetRowCellValue(focusedRowHandle, "ContractToDate", item.ContractToDate);
            bandedGridView.SetRowCellValue(focusedRowHandle, "EnrollNumber", item.EnrollNumber);
            bandedGridView.SetRowCellValue(focusedRowHandle, "Description", item.Description);
            bandedGridView.UpdateCurrentRow();
        }
Exemplo n.º 4
0
        private void bandedGridView1_CellValueChanged(object sender, DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e)
        {
            BandedGridView view = sender as BandedGridView;

            if (view == null)
            {
                return;
            }
            btnSaveChanged.Visible = true;
            string staffCode = view.GetRowCellValue(e.RowHandle, view.Columns[0]).ToString();

            if (e.Column == gridLevelDateI)
            {
                if (e.Value != null)
                {
                    string   cellValue   = e.Value.ToString();
                    DateTime changeValue = DateTime.Parse(cellValue).AddDays(365);
                    string   str         = changeValue.ToString();
                    view.SetRowCellValue(e.RowHandle, view.Columns[8], str);
                }
            }
            if (e.Column == gridLevelDateII)
            {
                if (e.Value != null)
                {
                    string   cellValue   = e.Value.ToString();
                    DateTime changeValue = DateTime.Parse(cellValue).AddDays(365);
                    string   str         = changeValue.ToString();
                    view.SetRowCellValue(e.RowHandle, view.Columns[8], str);
                }
            }
            if (e.Column == gridDateLevelIII)
            {
                if (e.Value != null)
                {
                    string   cellValue   = e.Value.ToString();
                    DateTime changeValue = DateTime.Parse(cellValue).AddDays(365);
                    string   str         = changeValue.ToString();
                    view.SetRowCellValue(e.RowHandle, view.Columns[8], str);
                }
            }

            if (e.Column == gridTestDateActual)
            {
                if (e.Value != null)
                {
                    string   cellValue   = e.Value.ToString();
                    DateTime changeValue = DateTime.Parse(cellValue).AddDays(365);
                    string   str         = changeValue.ToString();
                    view.SetRowCellValue(e.RowHandle, view.Columns[8], str);
                }
            }

            if (e.Column == gridCapDo)
            {
                if (e.Value != null)
                {
                    string cellValue = e.Value.ToString();
                    view.SetRowCellValue(e.RowHandle, view.Columns[7], cellValue);
                }
            }
            if (e.Column == gridLevelII)
            {
                if (e.Value != null)
                {
                    string cellValue = e.Value.ToString();
                    view.SetRowCellValue(e.RowHandle, view.Columns[7], cellValue);
                }
            }
            if (e.Column == gridLevelIII)
            {
                if (e.Value != null)
                {
                    string cellValue = e.Value.ToString();
                    view.SetRowCellValue(e.RowHandle, view.Columns[7], cellValue);
                }
            }
        }
Exemplo n.º 5
0
        private void bandedGridView1_CellValueChanged(object sender, CellValueChangedEventArgs e)
        {
            BandedGridView view = sender as BandedGridView;

            if (view == null)
            {
                return;
            }
            btnSaveChanged.Visible = true;
            string staffCode = view.GetRowCellValue(e.RowHandle, view.Columns[0]).ToString();

            if (e.Column == gridLevelDateI)
            {
                if (e.Value != null)
                {
                    string   cellValue   = e.Value.ToString();
                    DateTime changeValue = DateTime.Parse(cellValue).AddDays(365);
                    string   str         = changeValue.ToString();
                    view.SetRowCellValue(e.RowHandle, view.Columns[10], str);
                }
            }
            if (e.Column == gridLevelDateII)
            {
                if (e.Value != null)
                {
                    string   cellValue   = e.Value.ToString();
                    DateTime changeValue = DateTime.Parse(cellValue).AddDays(365);
                    string   str         = changeValue.ToString();
                    view.SetRowCellValue(e.RowHandle, view.Columns[10], str);
                }
            }
            if (e.Column == gridLevelDateIII)
            {
                if (e.Value != null)
                {
                    string cellValue = null;
                    if (Ultils.IsNull(e.Value.ToString()))
                    {
                        cellValue = e.Value.ToString();
                        DateTime changeValue = DateTime.Parse(cellValue).AddDays(365);
                        string   str         = changeValue.ToString();
                        view.SetRowCellValue(e.RowHandle, view.Columns[10], str);
                    }
                }
            }
            if (e.Column == gridTestDateActual)
            {
                if (e.Value != null)
                {
                    string   cellValue   = e.Value.ToString();
                    DateTime changeValue = DateTime.Parse(cellValue).AddDays(365);
                    string   str         = changeValue.ToString();
                    view.SetRowCellValue(e.RowHandle, view.Columns[10], str);
                }
            }

            if (e.Column == gridLevelI)
            {
                if (e.Value != null)
                {
                    string cellValue = e.Value.ToString();
                    view.SetRowCellValue(e.RowHandle, view.Columns[9], cellValue);
                }
            }
            if (e.Column == gridLevelII)
            {
                if (e.Value != null)
                {
                    string cellValue = e.Value.ToString();
                    view.SetRowCellValue(e.RowHandle, view.Columns[9], cellValue);
                }
            }
            if (e.Column == gridLevelIII)
            {
                if (e.Value != null)
                {
                    string cellValue = e.Value.ToString();
                    view.SetRowCellValue(e.RowHandle, view.Columns[9], cellValue);
                }
            }
        }