Ejemplo n.º 1
0
 protected override void OnGetCellErrorInfo(GetErrorInfoEventArgs e)
 {
     var errorMessage = GetUserData(e.Row, e.Col) as ErrorMessage;
     if (errorMessage != null)
     {
         e.ErrorText = errorMessage.Message;
         return;
     }
     base.OnGetCellErrorInfo(e);
 }
        private void c1FlexGrid_EDIT_GetCellErrorInfo(object sender, GetErrorInfoEventArgs e)
        {
            C1FlexGrid grid = sender as C1FlexGrid;

            switch (_nSelectedGroup)
            {
                case (int)Definition.MachineGroups.POSITIONS:   // Name,PosNumber,InternalPos,Description
                    if (e.Col == 3)
                    {
                        try
                        {
                            if ( grid[e.Row, "Name"].ToString().Length <=0)
                            {
                                e.ErrorText = myIniHandler.GetValue("Admin-Machines", "Enter_Name");
                            }
                        }
                        catch { e.ErrorText = myIniHandler.GetValue("Admin-Machines", "Enter_Name"); /**/}
                    }
                    if (e.Col == 4)
                    {
                        try
                        {
                            if (grid[e.Row, "PosNumber"].ToString().Length <= 0)
                            {
                                e.ErrorText = myIniHandler.GetValue("Admin-Machines", "Enter_Pos_Number");
                            }
                        }
                        catch { e.ErrorText = myIniHandler.GetValue("Admin-Machines", "Enter_Pos_Number"); /**/}
                    }
                    if (e.Col == 5)
                    {
                        try
                        {
                            if (grid[e.Row, "InternalPos"].ToString().Length <= 0)
                            {
                                e.ErrorText = myIniHandler.GetValue("Admin-Machines", "Enter_Internal_Pos");
                            }
                        }
                        catch { e.ErrorText = myIniHandler.GetValue("Admin-Machines", "Enter_Internal_Pos"); /**/}
                    }
                    if (e.Col == 6)
                    {
                        try
                        {
                            if (grid[e.Row, "Registration_Point"].ToString().Length <= 0)
                            {
                                e.ErrorText = myIniHandler.GetValue("Admin-Machines", "Select_Registration_Point");
                            }
                        }
                        catch { e.ErrorText = myIniHandler.GetValue("Admin-Machines", "Select_Registration_Point"); /**/}
                    }
                    break;

                case (int)Definition.MachineGroups.COMMANDS:    //Name,Number,Description
                    if (e.Col == 3)
                    {
                        try
                        {
                            if (grid[e.Row, "Name"].ToString().Length <= 0)
                            {
                                e.ErrorText = myIniHandler.GetValue("Admin-Machines", "Enter_Name");
                            }
                        }
                        catch { e.ErrorText = myIniHandler.GetValue("Admin-Machines", "Enter_Name"); /**/}
                    }
                    if (e.Col == 4)
                    {
                        try
                        {
                            if (grid[e.Row, "Number"].ToString().Length <= 0)
                            {
                                e.ErrorText = myIniHandler.GetValue("Admin-Machines", "Enter_Pos_Number");
                            }
                        }
                        catch { e.ErrorText = myIniHandler.GetValue("Admin-Machines", "Enter_Pos_Number"); /**/}
                    }
                    break;

                case (int)Definition.MachineGroups.PROGRAMS:    //Name,Description
                    if (e.Col == 3)
                    {
                        try
                        {
                            if (grid[e.Row, "Name"].ToString().Length <= 0)
                            {
                                e.ErrorText = myIniHandler.GetValue("Admin-Machines", "Enter_Name");
                            }
                        }
                        catch { e.ErrorText = myIniHandler.GetValue("Admin-Machines", "Enter_Name"); /**/}
                    }
                    break;

                case (int)Definition.MachineGroups.PROGRAMPARAMETERNAMES: //Name,units_of_measurement_ID AS Unit,parameter_number AS 'Parameter Number',Description

                    if (e.Col == 3)//units_of_measurement_ID
                    {
                        try
                        {
                            if (grid[e.Row, 3].ToString().Length <= 0)
                            {
                                e.ErrorText = myIniHandler.GetValue("Admin-Machines", "Enter_Unit"); ;
                            }
                        }
                        catch { e.ErrorText = myIniHandler.GetValue("Admin-Machines", "Enter_Unit");  /**/}
                    }

                    if (e.Col == 4) // parameter_number
                    {
                        try
                        {
                            if (grid[e.Row, 4].ToString().Length <= 0)
                             //   if (grid[e.Row, "Pararmeter Number"].ToString().Length <= 0)
                            {
                                e.ErrorText = myIniHandler.GetValue("Admin-Machines", "Pararmeter_Number"); ;
                            }
                        }
                        catch { e.ErrorText = myIniHandler.GetValue("Admin-Machines", "Pararmeter_Number");  /**/}
                    }
                    break;

                case (int)Definition.MachineGroups.STATESIGNALS:   // Name,Signal_type,Signal_number,Bit,actual_count,limit_1,limit_2,Description
                    //  SELECT idmachine_state_signals As ID,Machine_ID,Name,Signal_type,Signal_number,bit_Number AS Bit, actual_count AS `actual count`,limit_1 AS `Limit 1`,limit_2 AS `Limit 2`,Description FROM machine_state_signals

                    if (e.Col == 3)
                    {
                        try
                        {
                            if (grid[e.Row, "Name"].ToString().Length <= 0)
                            {
                                e.ErrorText = myIniHandler.GetValue("Admin-Machines", "Enter_Name");
                            }
                        }
                        catch { e.ErrorText = myIniHandler.GetValue("Admin-Machines", "Enter_Name"); }
                    }
                    if (e.Col == 4)
                    {
                        try
                        {
                            if (grid[e.Row, "Signal_type"].ToString().Length <= 0)
                            {
                                e.ErrorText = myIniHandler.GetValue("Admin-Machines", "Enter_In_Output");
                            }
                        }
                        catch { e.ErrorText = myIniHandler.GetValue("Admin-Machines", "Enter_In_Output"); }
                    }
                    if (e.Col == 5)
                    {
                        try
                        {
                            if (grid[e.Row, "Signal_number"].ToString().Length <= 0)
                            {
                                e.ErrorText = myIniHandler.GetValue("Admin-Machines", "Enter_Number");
                            }
                        }
                       catch { e.ErrorText = myIniHandler.GetValue("Admin-Machines", "Enter_Number"); }
                    }
                    if (e.Col == 6)
                    {
                        try
                        {
                            if (grid[e.Row, "Bit"].ToString().Length <= 0)
                            {
                                e.ErrorText = myIniHandler.GetValue("Admin-Machines", "Enter_Bit");
                            }
                        }
                        catch { e.ErrorText = myIniHandler.GetValue("Admin-Machines", "Enter_Bit");}
                    }
                    try
                    {
                       if (grid[e.Row, "Signal_type"] != null)
                        {
                            string strSignal_Type = grid[e.Row, "Signal_type"].ToString();
                             //if (strSignal_Type.Length <= 0) //myIniHandler.GetValue("Admin-Machines", "Input")
                            if (String.Equals(strSignal_Type, myIniHandler.GetValue("Admin-Machines", "Input"))
                                || String.Equals(strSignal_Type, myIniHandler.GetValue("Admin-Machines", "Output")))
                             {
                                /* if (e.Col == 7)
                                 {
                                     try
                                     {
                                         if (grid[e.Row, "actual count"].ToString().Length <= 0)
                                         {
                                             e.ErrorText = myIniHandler.GetValue("Admin-Machines", "Enter_Start_Value");
                                         }
                                     }
                                     catch { e.ErrorText = myIniHandler.GetValue("Admin-Machines", "Enter_Start_Value"); }
                                 }*/
                                 if (e.Col == 8)
                                 {
                                     try
                                     {
                                         if (grid[e.Row, "Limit 1"].ToString().Length <= 0)
                                         {
                                             e.ErrorText = myIniHandler.GetValue("Admin-Machines", "Enter_Limit");
                                         }
                                     }
                                     catch { e.ErrorText = myIniHandler.GetValue("Admin-Machines", "Enter_Limit"); }
                                 }
                                 if (e.Col == 9)
                                 {
                                     try
                                     {
                                         if (grid[e.Row, "Limit 2"].ToString().Length <= 0)
                                         {
                                             e.ErrorText = myIniHandler.GetValue("Admin-Machines", "Enter_Limit");
                                         }
                                     }
                                     catch { e.ErrorText = myIniHandler.GetValue("Admin-Machines", "Enter_Limit"); }
                                 }
                             }
                        }
                    }
                    catch { }
                    break;

                case (int)Definition.MachineGroups.PROGRAMPARAMETERS:   // program_Number_ID,Value,machine_program_parameter_name_ID AS ParameterName,Description

                    if (e.Col == 4)
                    {
                        try
                        {
                            if (grid[e.Row, "Value"].ToString().Length <= 0)
                            {
                                e.ErrorText = myIniHandler.GetValue("Admin-Machines", "Enter_Value");
                            }
                        }
                        catch { e.ErrorText = myIniHandler.GetValue("Admin-Machines", "Enter_Value");/**/}
                    }
                    if (e.Col == 5)
                    {
                        try
                        {
                            if (grid[e.Row, "ParameterName"].ToString().Length <= 0)
                            {
                                e.ErrorText = myIniHandler.GetValue("Admin-Machines", "Enter_Name");
                            }
                        }
                        catch { e.ErrorText = myIniHandler.GetValue("Admin-Machines", "Enter_Name"); /**/}
                    }
                    break;

                case (int)Definition.MachineGroups.STATUSBITS:   // Name,Bit_number AS bit,Description
                    if (e.Col == 3)
                    {
                        try
                        {
                            if (grid[e.Row, "Name"].ToString().Length <= 0)
                            {
                                e.ErrorText = myIniHandler.GetValue("Admin-Machines", "Enter_Name");
                            }
                        }
                        catch { e.ErrorText = myIniHandler.GetValue("Admin-Machines", "Enter_Name"); /**/}
                    }
                    if (e.Col == 4)
                    {
                        try
                        {
                            if (grid[e.Row, "bit"].ToString().Length <= 0)
                            {
                                e.ErrorText = myIniHandler.GetValue("Admin-Machines", "Enter_Bit");
                            }
                        }
                        catch { e.ErrorText = myIniHandler.GetValue("Admin-Machines", "Enter_Bit"); /**/}
                    }

                    break;
            }
Ejemplo n.º 3
0
        private void c1FlexGrid_Commands_GetCellErrorInfo(object sender, GetErrorInfoEventArgs e)
        {
            C1FlexGrid grid = sender as C1FlexGrid;

               string strValue = null;
               int nCommand = -1;
               if (e.Row <= 0) { return; }

               try
               {
               nCommand = Int32.Parse(grid.GetData(e.Row, "Command").ToString());
               }
               catch {  return; }

               if (grid.Cols[e.Col].Name == "Command" && e.Row > 0)
               {
               if (nCommand == 0)
               {
                   e.ErrorText = "Please select a command!";
               }
               else
               {
                   e.ErrorText = "";

               }

               }

               if (grid.Cols[e.Col].Name == "Value0" && e.Row > 0) //
               {
               if (nCommand > 0)
               {
                   strValue = grid[e.Row, "Value0"].ToString();
                   if (strValue.Length <= 0 || strValue.StartsWith("<Please select"))
                   {
                       try
                       {
                           string[] nArray = GetStringArrayForErrorText("Command", nCommand);
                           e.ErrorText = nArray[1];
                       }
                       catch { }
                   }
                   else
                   {
                       e.ErrorText = "";

                   }
               }
               }

               if (grid.Cols[e.Col].Name == "Value1" && e.Row > 0) //
               {
               if (nCommand > 0)
               {
                   strValue = grid[e.Row, "Value1"].ToString();
                   if (strValue.Length <= 0 || strValue.StartsWith("<Please select"))
                   {
                       try{
                         string[] nArray = GetStringArrayForErrorText("Command", nCommand);
                         e.ErrorText = nArray[2];
                       }
                       catch { }
                   }
                   else
                   {
                       e.ErrorText = "";
                   }
               }
               }

               if (grid.Cols[e.Col].Name == "Value2" && e.Row > 0) //
               {
               if (nCommand > 0)
               {
                   strValue = grid[e.Row, "Value2"].ToString();
                   if (strValue.Length <= 0 || strValue.StartsWith("<Please select"))
                   {
                       try{
                          string[] nArray = GetStringArrayForErrorText("Command", nCommand);
                          e.ErrorText = nArray[3];
                       }
                       catch { }
                   }
                   else
                   {
                       e.ErrorText = "";
                   }
               }
               }

               if (grid.Cols[e.Col].Name == "Value3" && e.Row > 0) //
               {
               if (nCommand > 0)
               {
                   strValue = grid[e.Row, "Value3"].ToString();
                   if (strValue.Length <= 0 || strValue.StartsWith("<Please select"))
                   {
                       try{
                          string[] nArray = GetStringArrayForErrorText("Command", nCommand);
                         e.ErrorText = nArray[4];
                       }
                       catch { }
                   }
                   else
                   {
                       e.ErrorText = "";

                   }
               }
               }
        }
Ejemplo n.º 4
0
        private void c1FlexGrid_Conditions_GetCellErrorInfo(object sender, GetErrorInfoEventArgs e)
        {
            C1FlexGrid grid = sender as C1FlexGrid;
               int nCondition = -1;
               string strValue = null;

               if (grid.Cols[e.Col].Name == null) { return; }
               if (e.Row < 0) { return; }

             if (e.Row > 0)
             {
                 //if (grid.Cols[e.Col].Name == "Condition")
                 //if (e.Col == 1)
                 {
                     try
                     {
                         Int32.TryParse(grid.GetData(e.Row, "Condition").ToString(), out nCondition);
                     }
                     catch { }
                 }
             }

             if (grid.Cols[e.Col].Name == "Condition" && e.Row > 0)
             {
                 if (nCondition == 0)
                 {
                    e.ErrorText = e.ErrorText = "Please select a condition!";
                 }
                 else { e.ErrorText = null; }

             }

             if (nCondition > 0)
             {
                 if (grid.Cols[e.Col].Name == "ValueName" && e.Row > 0)
                 {
                     if (nCondition > 0 && nCondition <= nConditionInputArray.Length)
                     {
                         string[] nArray = GetStringArrayForErrorText("Condition", nCondition);
                         strValue = grid[e.Row, "ValueName"].ToString();
                         if (strValue.Length <= 0 || strValue.StartsWith("0")) { e.ErrorText = nArray[2]; } else { e.ErrorText = null; }
                     }
                 }

                 if (grid.Cols[e.Col].Name == "Operation" && e.Row > 0)
                 {
                     if (nCondition > 0 && nCondition <= nConditionInputArray.Length)
                     {
                         string[] nArray = GetStringArrayForErrorText("Condition", nCondition);
                         strValue = grid[e.Row, "Operation"].ToString();
                         if (strValue.Length <= 0 || strValue.StartsWith("0")) { e.ErrorText = nArray[3]; }
                         else
                         {
                             e.ErrorText = null;
                         }
                     }
                 }

                 if (grid.Cols[e.Col].Name == "Value" && e.Row > 0)
                 {
                     if (nCondition > 0 && nCondition <= nConditionInputArray.Length)
                     {
                         string[] nArray = GetStringArrayForErrorText("Condition", nCondition);
                         strValue = grid[e.Row, "Value"].ToString();
                         if (strValue.Length <= 0) { e.ErrorText = nArray[4]; } else { e.ErrorText = null; }
                     }
                 }

             }
        }
Ejemplo n.º 5
0
        private void c1FlexGrid_Conditions_GetCellErrorInfo(object sender, GetErrorInfoEventArgs e)
        {
            C1FlexGrid grid = sender as C1FlexGrid;
            int nPort = -1;

            bInputError = false;

            if (grid.Cols[e.Col].Name == null) { return; }
            if (e.Row < 0) { return; }

               if (e.Row > 0)
               {
               try
               {
                   Int32.TryParse(grid.GetData(e.Row, "Port").ToString(), out nPort);
               }
               catch {  }
               }

            if (grid.Cols[e.Col].Name == "Port" && e.Row > 0) // port field
             {
                 if (nPort <= 0 || nPort > 65535)
                 {
                     //Console.WriteLine(e.Row.ToString());
                     e.ErrorText = "Please enter a valid Port number! (1-65535)";
                     bInputError = true;
                    // return;
                 }
                 else { e.ErrorText = ""; }

             }

             if (e.Col == 5 && e.Row > 0) // ip address field
             {
                 int nType = -1;
                 if (grid.GetData(e.Row, "Type") != null)
                 {
                     Int32.TryParse(grid.GetData(e.Row, "Type").ToString(), out nType);
                     if (nType == 1)// client
                     {
                         if (!IsIPv4(grid.GetData(e.Row, 5).ToString()))
                         {
                             e.ErrorText = "not a valid ip address";
                             bInputError = true;
                         }
                         else { e.ErrorText = ""; }
                     }
                     else
                     {
                         e.ErrorText = "";
                     }
                 }
                 else { e.ErrorText = "type is null"; bInputError = true; }
             }

            if (grid.Cols[e.Col].Name == "Name" && e.Row > 0) // Name field
            {
                if (grid.GetData(e.Row, "Name") != null)
                {
                    if (grid.GetData(e.Row, "Name").ToString().Length < 1)
                    {
                        e.ErrorText = "name to short";
                        bInputError = true;
                        // return;
                    }
                    else
                    {
                        e.ErrorText = "";
                    }
                }
                else { e.ErrorText = "name is null"; bInputError = true; }
            }

            if (grid.Cols[e.Col].Name == "Station" && e.Row > 0) // station field
            {
                int nStation_ID = -1;
                Int32.TryParse(grid.GetData(e.Row, "Station").ToString(), out nStation_ID);
                if (nStation_ID < 1)
                {
                    e.ErrorText = "name to short";
                    bInputError = true;
                    //return;
                }
                else
                {
                    e.ErrorText = "";
                }
            }
            string t = bInputError? "True":"False";
            Console.WriteLine(t);
        }