Exemplo n.º 1
0
        private void grvUser_ValidateRow(object sender, DevExpress.XtraGrid.Views.Base.ValidateRowEventArgs e)
        {
            DevExpress.XtraGrid.Views.Grid.GridView View      = (DevExpress.XtraGrid.Views.Grid.GridView)sender;
            DevExpress.XtraGrid.Columns.GridColumn  sMaNhom   = View.Columns["ID_NHOM"];
            DevExpress.XtraGrid.Columns.GridColumn  sTenUser  = View.Columns["USER_NAME"];
            DevExpress.XtraGrid.Columns.GridColumn  sFullName = View.Columns["FULL_NAME"];

            if (View.GetRowCellValue(e.RowHandle, sTenUser).ToString() == "")
            {
                e.Valid = false;
                View.SetColumnError(sTenUser, Commons.Modules.ObjLanguages.GetLanguage(Commons.Modules.ModuleName, this.Name, "MsgKiemtraTenUserNULL", Commons.Modules.TypeLanguage));
                XtraMessageBox.Show(Commons.Modules.ObjLanguages.GetLanguage(Commons.Modules.ModuleName, this.Name, "MsgKiemtraTenUserNULL", Commons.Modules.TypeLanguage), "", MessageBoxButtons.OK, MessageBoxIcon.Error); return;
            }

            if (View.GetRowCellValue(e.RowHandle, sTenUser).ToString() == "")
            {
                e.Valid = false;
                View.SetColumnError(sTenUser, Commons.Modules.ObjLanguages.GetLanguage(Commons.Modules.ModuleName, this.Name, "MsgKiemtraTenUserNULL", Commons.Modules.TypeLanguage));
                XtraMessageBox.Show(Commons.Modules.ObjLanguages.GetLanguage(Commons.Modules.ModuleName, this.Name, "MsgKiemtraTenUserNULL", Commons.Modules.TypeLanguage), "", MessageBoxButtons.OK, MessageBoxIcon.Error); return;
            }
            if (!CheckUser(View.GetRowCellValue(e.RowHandle, sTenUser).ToString()))
            {
                e.Valid = false;
                View.SetColumnError(sTenUser, Commons.Modules.ObjLanguages.GetLanguage(Commons.Modules.ModuleName, this.Name, "MsgDatontainguoidung", Commons.Modules.TypeLanguage));
                XtraMessageBox.Show(Commons.Modules.ObjLanguages.GetLanguage(Commons.Modules.ModuleName, this.Name, "MsgDatontainguoidung", Commons.Modules.TypeLanguage), "", MessageBoxButtons.OK, MessageBoxIcon.Error); return;
            }
            if (View.GetRowCellValue(e.RowHandle, sFullName).ToString() == "")
            {
                e.Valid = false;
                View.SetColumnError(sFullName, Commons.Modules.ObjLanguages.GetLanguage(Commons.Modules.ModuleName, this.Name, "MsgKiemtraFullNameNULL", Commons.Modules.TypeLanguage));
                XtraMessageBox.Show(Commons.Modules.ObjLanguages.GetLanguage(Commons.Modules.ModuleName, this.Name, "MsgKiemtraFullNameNULL", Commons.Modules.TypeLanguage), "", MessageBoxButtons.OK, MessageBoxIcon.Error); return;
            }
        }
Exemplo n.º 2
0
 private void grvNhom_ValidateRow(object sender, DevExpress.XtraGrid.Views.Base.ValidateRowEventArgs e)
 {
     DevExpress.XtraGrid.Views.Grid.GridView View     = (DevExpress.XtraGrid.Views.Grid.GridView)sender;
     DevExpress.XtraGrid.Columns.GridColumn  sTenNhom = View.Columns["TEN_NHOM"];
     if (View.GetRowCellValue(e.RowHandle, sTenNhom).ToString() == "")
     {
         e.Valid = false;
         View.SetColumnError(sTenNhom, Commons.Modules.ObjLanguages.GetLanguage(Commons.Modules.ModuleName, this.Name, "MsgTenNhomKhongNull", Commons.Modules.TypeLanguage));
         XtraMessageBox.Show(Commons.Modules.ObjLanguages.GetLanguage(Commons.Modules.ModuleName, this.Name, "MsgKiemtraTenUserNULL", Commons.Modules.TypeLanguage), "", MessageBoxButtons.OK, MessageBoxIcon.Error); return;
     }
 }
Exemplo n.º 3
0
        private void grvTroCapBHXH_ValidateRow(object sender, DevExpress.XtraGrid.Views.Base.ValidateRowEventArgs e)
        {
            grvTroCapBHXH.ClearColumnErrors();
            DevExpress.XtraGrid.Views.Grid.GridView View          = (DevExpress.XtraGrid.Views.Grid.GridView)sender;
            DevExpress.XtraGrid.Columns.GridColumn  ID_CN         = View.Columns["ID_CN"];
            DevExpress.XtraGrid.Columns.GridColumn  NGHI_TU_NGAY  = View.Columns["NGHI_TU_NGAY"];
            DevExpress.XtraGrid.Columns.GridColumn  NGHI_DEN_NGAY = View.Columns["NGHI_DEN_NGAY"];
            DevExpress.XtraGrid.Columns.GridColumn  ID_LDV        = View.Columns["ID_LDV"];
            DevExpress.XtraGrid.Columns.GridColumn  ID_HTNTC      = View.Columns["ID_HTNTC"];
            if (View.GetRowCellValue(e.RowHandle, ID_LDV).ToString() == "")
            {
                e.Valid = false;
                View.SetColumnError(ID_LDV, Commons.Modules.ObjLanguages.GetLanguage(Commons.Modules.ModuleName, this.Name, "MsgKiemtraLDVNULL", Commons.Modules.TypeLanguage)); return;
            }
            if (View.GetRowCellValue(e.RowHandle, ID_HTNTC).ToString() == "")
            {
                e.Valid = false;
                View.SetColumnError(ID_HTNTC, Commons.Modules.ObjLanguages.GetLanguage(Commons.Modules.ModuleName, this.Name, "MsgKiemtraHTNTCNULL", Commons.Modules.TypeLanguage)); return;
            }

            if (View.GetRowCellValue(e.RowHandle, NGHI_TU_NGAY).ToString() == "")
            {
                e.Valid = false;
                View.SetColumnError(NGHI_TU_NGAY, Commons.Modules.ObjLanguages.GetLanguage(Commons.Modules.ModuleName, this.Name, "MsgKiemtraTuNgayCNULL", Commons.Modules.TypeLanguage)); return;
            }
            if (View.GetRowCellValue(e.RowHandle, NGHI_DEN_NGAY).ToString() == "")
            {
                e.Valid = false;
                View.SetColumnError(NGHI_DEN_NGAY, Commons.Modules.ObjLanguages.GetLanguage(Commons.Modules.ModuleName, this.Name, "MsgKiemtraDenNgayNULL", Commons.Modules.TypeLanguage)); return;
            }

            //kiểm tra dữ liệu trùng
            DataTable tempt = Commons.Modules.ObjSystems.ConvertDatatable(grvTroCapBHXH);
            int       n     = 0;

            try
            {
                string sSql = "SELECT dbo.fuKiemTraTroCapBHXH(" + View.GetRowCellValue(e.RowHandle, ID_CN) + ",'" + Convert.ToDateTime(View.GetRowCellValue(e.RowHandle, NGHI_TU_NGAY)).ToString("MM/dd/yyyy") + "','" + Convert.ToDateTime(View.GetRowCellValue(e.RowHandle, NGHI_DEN_NGAY)).ToString("MM/dd/yyyy") + "'," + ThangdateEdit.DateTime.Month + "," + ThangdateEdit.DateTime.Year + ")";
                n = Convert.ToInt32(SqlHelper.ExecuteScalar(Commons.IConnections.CNStr, CommandType.Text, sSql));
            }
            catch
            { }
            if (n == 0)
            {
                //kiểm tra từ ngày dến ngày trên lưới
                DateTime tn = Convert.ToDateTime(View.GetRowCellValue(e.RowHandle, NGHI_TU_NGAY));
                DateTime dn = Convert.ToDateTime(View.GetRowCellValue(e.RowHandle, NGHI_DEN_NGAY));
                n = tempt.AsEnumerable().Count(x => x.Field <Int64>("ID_CN") == Convert.ToInt64(View.GetRowCellValue(e.RowHandle, ID_CN)) && x.Field <DateTime>("NGHI_TU_NGAY") > tn && x.Field <DateTime>("NGHI_DEN_NGAY") < dn);
                if (n == 1)
                {
                    e.Valid = false;
                    View.SetColumnError(ID_CN, Commons.Modules.ObjLanguages.GetLanguage(Commons.Modules.ModuleName, this.Name, "MsgTrungDuLieu", Commons.Modules.TypeLanguage));
                    View.SetColumnError(NGHI_TU_NGAY, Commons.Modules.ObjLanguages.GetLanguage(Commons.Modules.ModuleName, this.Name, "MsgTrungDuLieu", Commons.Modules.TypeLanguage));
                    val = false;
                    return;
                }
            }
        }
Exemplo n.º 4
0
        private void gridViewArticulo_ValidateRow(object sender, DevExpress.XtraGrid.Views.Base.ValidateRowEventArgs e)
        {
            if (e.Row == null)
            {
                return;
            }
            DevExpress.XtraGrid.Views.Grid.GridView view = sender as DevExpress.XtraGrid.Views.Grid.GridView;
            GridColumn codigoCol         = view.Columns["CODIGO"];
            GridColumn codigoArticuloCol = view.Columns["CODIGOARTICULO"];
            GridColumn descripcionCol    = view.Columns["DESCRIPCION"];
            GridColumn precioventaCol    = view.Columns["PRECIOVENTA"];
            GridColumn impuestoCol       = view.Columns["CODIGOIMPUESTO"];
            GridColumn tipoArticuloCol   = view.Columns["CODIGOTIPOARTICULO"];

            //Revisar valores
            String  codigoString       = (String)view.GetRowCellValue(e.RowHandle, codigoCol);
            String  descripcionString  = (String)view.GetRowCellValue(e.RowHandle, descripcionCol);
            Decimal precioDbbl         = (Decimal)view.GetRowCellValue(e.RowHandle, precioventaCol);
            long    impuestoLong       = (long)view.GetRowCellValue(e.RowHandle, impuestoCol);
            long    codigoArticuloLong = (long)view.GetRowCellValue(e.RowHandle, codigoArticuloCol);
            long    tipoArticuloLong   = (long)view.GetRowCellValue(e.RowHandle, tipoArticuloCol);

            // e.Valid = true;
            if (codigoString == null || codigoString.Equals(""))
            {
                e.Valid = false;
                view.SetColumnError(codigoCol, "Ingrese un código para el producto");
            }
            if (descripcionString == null || descripcionString.Equals(""))
            {
                e.Valid = false;
                view.SetColumnError(descripcionCol, "Ingrese la descripción!");
            }
            if (impuestoLong == 0)
            {
                e.Valid = false;
                view.SetColumnError(impuestoCol, "Seleccione un impuesto!");
            }

            if (impuestoLong == 0)
            {
                e.Valid = false;
                view.SetColumnError(tipoArticuloCol, "Seleccione un un tipo e producto!");
            }
            if (this.articuloservicio.getArticulo(CredencialUsuario.getInstancia().getEmpresaSeleccionada().CODIGOEMPRESA, codigoString, codigoArticuloLong) != null)
            {
                e.Valid = false;
                view.SetColumnError(codigoCol, "Código " + codigoString + " ya se encuentra definido.");
            }

            if (this.articuloservicio.getArticuloDes(CredencialUsuario.getInstancia().getEmpresaSeleccionada().CODIGOEMPRESA, descripcionString, codigoArticuloLong) != null)
            {
                e.Valid = false;
                view.SetColumnError(codigoCol, "Producto: " + descripcionString + " ya se encuentra definido.");
            }
        }
Exemplo n.º 5
0
        private void grvDanhGiaCT_ValidateRow(object sender, DevExpress.XtraGrid.Views.Base.ValidateRowEventArgs e)
        {
            grvDanhGiaCT.ClearColumnErrors();
            DevExpress.XtraGrid.Views.Grid.GridView View = (DevExpress.XtraGrid.Views.Grid.GridView)sender;
            if (View == null)
            {
                return;
            }
            DataTable dt = Commons.Modules.ObjSystems.ConvertDatatable(grvDanhGiaCT);
            int       n  = dt.AsEnumerable().Count(x => x.Field <Int64>("ID_NDDG") == Convert.ToInt64(View.GetRowCellValue(e.RowHandle, View.Columns["ID_NDDG"])));

            if (n > 1)
            {
                e.Valid = false;
                View.SetColumnError(View.Columns["ID_NDDG"], Commons.Modules.ObjLanguages.GetLanguage(Commons.Modules.ModuleName, this.Name, "MsgKiemtraTenUserNULL", Commons.Modules.TypeLanguage), DevExpress.XtraEditors.DXErrorProvider.ErrorType.Critical);
                return;
            }
        }
Exemplo n.º 6
0
        private void grvDCTroCapBHXH_ValidateRow(object sender, DevExpress.XtraGrid.Views.Base.ValidateRowEventArgs e)
        {
            DevExpress.XtraGrid.Views.Grid.GridView View          = (DevExpress.XtraGrid.Views.Grid.GridView)sender;
            DevExpress.XtraGrid.Columns.GridColumn  ID_CN         = View.Columns["ID_CN"];
            DevExpress.XtraGrid.Columns.GridColumn  NGHI_TU_NGAY  = View.Columns["NGHI_TU_NGAY"];
            DevExpress.XtraGrid.Columns.GridColumn  NGHI_DEN_NGAY = View.Columns["NGHI_DEN_NGAY"];
            DevExpress.XtraGrid.Columns.GridColumn  ID_LDV        = View.Columns["ID_LDV"];
            DevExpress.XtraGrid.Columns.GridColumn  ID_HTNTC      = View.Columns["ID_LDV"];
            if (View.GetRowCellValue(e.RowHandle, ID_LDV).ToString() == "")
            {
                e.Valid = false;
                View.SetColumnError(ID_LDV, Commons.Modules.ObjLanguages.GetLanguage(Commons.Modules.ModuleName, this.Name, "MsgKiemtraLDVNULL", Commons.Modules.TypeLanguage)); return;
            }
            if (View.GetRowCellValue(e.RowHandle, ID_HTNTC).ToString() == "")
            {
                e.Valid = false;
                View.SetColumnError(ID_HTNTC, Commons.Modules.ObjLanguages.GetLanguage(Commons.Modules.ModuleName, this.Name, "MsgKiemtraHTNTCNULL", Commons.Modules.TypeLanguage)); return;
            }

            if (View.GetRowCellValue(e.RowHandle, NGHI_TU_NGAY).ToString() == "")
            {
                e.Valid = false;
                View.SetColumnError(NGHI_TU_NGAY, Commons.Modules.ObjLanguages.GetLanguage(Commons.Modules.ModuleName, this.Name, "MsgKiemtraTuNgayCNULL", Commons.Modules.TypeLanguage)); return;
            }
            if (View.GetRowCellValue(e.RowHandle, NGHI_DEN_NGAY).ToString() == "")
            {
                e.Valid = false;
                View.SetColumnError(NGHI_DEN_NGAY, Commons.Modules.ObjLanguages.GetLanguage(Commons.Modules.ModuleName, this.Name, "MsgKiemtraDenNgayNULL", Commons.Modules.TypeLanguage)); return;
            }
            //kiểm tra dữ liệu trùng
            DataTable tempt = Commons.Modules.ObjSystems.ConvertDatatable(grvDCTroCapBHXH);
            int       n     = 0;

            //kiểm tra trùng trên view
            try
            {
                n = tempt.AsEnumerable().Count(x => x.Field <Int64>("ID_CN") == Convert.ToInt64(View.GetRowCellValue(e.RowHandle, ID_CN)) && x.Field <DateTime>("NGHI_TU_NGAY") == Convert.ToDateTime(View.GetRowCellValue(e.RowHandle, NGHI_TU_NGAY)));
            }
            catch (Exception ex)
            {
            }
            if (n > 1)
            {
                e.Valid = false;
                View.SetColumnError(ID_CN, Commons.Modules.ObjLanguages.GetLanguage(Commons.Modules.ModuleName, this.Name, "MsgTrungDuLieu", Commons.Modules.TypeLanguage));
                View.SetColumnError(NGHI_TU_NGAY, Commons.Modules.ObjLanguages.GetLanguage(Commons.Modules.ModuleName, this.Name, "MsgTrungDuLieu", Commons.Modules.TypeLanguage));
                val = false;
                return;
            }
        }