public bool CheckCarTag(string cardId)
        {
            DataSet ds = new DataSet();

            try
            {
                stm = "SELECT * FROM tbOperator WHERE CarTag=@CarTag AND IsActive='ACTIVE'";
                DbCallback.SetCommandText(stm);
                DbCallback.AddInputParameter("@CarTag", SqlDbType.NVarChar, cardId);
                ds = DbCallback.ExecuteToDataSet();
                if (ds != null)
                {
                    if (ds.Tables != null)
                    {
                        if (ds.Tables.Count > 0)
                        {
                            if (ds.Tables[0].Rows != null)
                            {
                                if (ds.Tables[0].Rows.Count > 0)
                                {
                                    return(true);
                                }
                            }
                        }
                    }
                }
                return(false);
            }
            catch (Exception ex)
            {
                DbCallback.CloseConnection();
                throw ex;
            }
        }
        public DataTable GetData(string cardId)
        {
            DataSet ds = new DataSet();

            try
            {
                stm = "SELECT [OID] AS [ID], [RFIDCode] AS [RFID],[CarTag] AS [ทะเบียนรถ],[CreatedDate] AS [วันที่บันทึก],[ExpiryDate] AS [วันที่หมดอายุ],[IsActive] AS [สถานะ] FROM tbOperator WHERE RFIDCode=@RFIDCode";
                DbCallback.SetCommandText(stm);
                DbCallback.AddInputParameter("@RFIDCode", SqlDbType.NVarChar, cardId);
                ds = DbCallback.ExecuteToDataSet();
                if (ds != null)
                {
                    if (ds.Tables != null)
                    {
                        if (ds.Tables.Count > 0)
                        {
                            if (ds.Tables[0].Rows != null)
                            {
                                if (ds.Tables[0].Rows.Count > 0)
                                {
                                    return(ds.Tables[0]);
                                }
                            }
                        }
                    }
                }
                return(null);
            }
            catch (Exception ex)
            {
                DbCallback.CloseConnection();
                throw ex;
            }
        }
 public long GetMaxID()
 {
     try
     {
         DataSet ds = new DataSet();
         stm = string.Format("SELECT TOP 1 * FROM {0} ORDER BY VIS_ID DESC", _tbName);
         DbCallback.SetCommandText(stm);
         ds = DbCallback.ExecuteToDataSet();
         if (ds != null)
         {
             if (ds.Tables != null)
             {
                 if (ds.Tables.Count > 0)
                 {
                     if (0 < ds.Tables[0].Rows.Count)
                     {
                         if (!DBNull.Value.Equals(ds.Tables[0].Rows[0]["VIS_ID"]))
                         {
                             return((long)ds.Tables[0].Rows[0]["VIS_ID"]);
                         }
                     }
                 }
             }
         }
         throw new Exception("Get maximum id failed!");
     }
     catch (Exception ex)
     {
         DbCallback.CloseConnection();
         throw ex;
     }
 }
 public DataTable Select(long vis_id)
 {
     try
     {
         DataSet ds = new DataSet();
         stm = string.Format("SELECT * FROM {0} WHERE VIS_ID=@VIS_ID", _tbName);
         DbCallback.SetCommandText(stm);
         DbCallback.AddInputParameter("@VIS_ID", SqlDbType.BigInt, vis_id);
         ds = DbCallback.ExecuteToDataSet();
         if (ds != null)
         {
             if (ds.Tables != null)
             {
                 if (ds.Tables.Count > 0)
                 {
                     return(ds.Tables[0]);
                 }
             }
         }
         return(null);
     }
     catch (Exception ex)
     {
         DbCallback.CloseConnection();
         throw ex;
     }
 }
 public string GetCharValue(string name)
 {
     try
     {
         DataSet ds = new DataSet();
         stm = "SELECT * FROM tbConfig WHERE Name=@Name";
         DbCallback.SetCommandText(stm);
         DbCallback.AddInputParameter("@Name", SqlDbType.NVarChar, name);
         ds = DbCallback.ExecuteToDataSet();
         if (ds != null)
         {
             if (ds.Tables != null)
             {
                 if (ds.Tables.Count > 0)
                 {
                     if (ds.Tables[0].Rows != null)
                     {
                         if (ds.Tables[0].Rows.Count > 0)
                         {
                             return((string)(ds.Tables[0].Rows[0]["CharVal"]));
                         }
                     }
                 }
             }
         }
         return(string.Empty);
     }
     catch (Exception ex)
     {
         DbCallback.CloseConnection();
         throw ex;
     }
 }
        public DataSet GetBO23(string carTag)
        {
            DataSet ds = new DataSet();

            try
            {
                //stm = "SELECT TOP 100 [BO23],[BoDate] AS [วันที่],[B_Type] AS [ชนิด],[B_Name] AS [ชื่อชนิด],[B_Number] AS [จำนวน] FROM tbBo23Test ";
                //stm += "WHERE CarTag=@CarTag";
                stm  = "SELECT TOP 100 * FROM tbBo23Test ";
                stm += "WHERE CarTag=@CarTag";
                DbCallback.SetCommandText(stm);
                DbCallback.AddInputParameter("@CarTag", SqlDbType.NVarChar, carTag);
                return(DbCallback.ExecuteToDataSet());
            }
            catch (Exception ex)
            {
                DbCallback.CloseConnection();
                throw ex;
            }
        }
Exemple #7
0
 public void GetData(int id, out string message, out int number)
 {
     {
         message = "NG";
         number  = 0;
     }
     try
     {
         DataSet ds = new DataSet();
         stm = "SELECT * FROM tbVisionTest WHERE ID=@ID";
         DbCallback.SetCommandText(stm);
         DbCallback.AddInputParameter("@ID", SqlDbType.NVarChar, id);
         ds = DbCallback.ExecuteToDataSet();
         if (ds != null)
         {
             if (ds.Tables != null)
             {
                 if (ds.Tables.Count > 0)
                 {
                     if (ds.Tables[0].Rows != null)
                     {
                         if (ds.Tables[0].Rows.Count > 0)
                         {
                             message = (string)(ds.Tables[0].Rows[0]["Message"]);
                             try { number = (int)(ds.Tables[0].Rows[0]["GoodBasket"]); }
                             catch { number = 0; }
                         }
                     }
                 }
             }
         }
     }
     catch (Exception ex)
     {
         DbCallback.CloseConnection();
         throw ex;
     }
 }
        public bool GetCarTag(string cardId, out string carTag)
        {
            DataSet ds = new DataSet();

            try
            {
                stm = "SELECT * FROM tbOperator WHERE RFIDCode=@RFIDCode AND IsActive='ACTIVE'";
                DbCallback.SetCommandText(stm);
                DbCallback.AddInputParameter("@RFIDCode", SqlDbType.NVarChar, cardId);
                ds = DbCallback.ExecuteToDataSet();
                if (ds != null)
                {
                    if (ds.Tables != null)
                    {
                        if (ds.Tables.Count > 0)
                        {
                            if (ds.Tables[0].Rows != null)
                            {
                                if (ds.Tables[0].Rows.Count > 0)
                                {
                                    carTag = Convert.ToString(ds.Tables[0].Rows[0]["CarTag"]);
                                    return(true);
                                }
                            }
                        }
                    }
                }
                carTag = string.Empty;
                return(false);
            }
            catch (Exception ex)
            {
                DbCallback.CloseConnection();
                throw ex;
            }
        }
        public bool Login(string userName, string pwd, out int currentAuthentication)
        {
            try
            {
                stm = "SELECT * FROM tbUser WHERE (UserName=@UserName) AND (Password=@Password) AND (IsActive='Y')";

                DbCallback.SetCommandText(stm);
                DbCallback.AddInputParameter("@UserName", SqlDbType.NVarChar, userName);
                DbCallback.AddInputParameter("@Password", SqlDbType.NVarChar, pwd);
                DataSet ds = DbCallback.ExecuteToDataSet();
                if (ds != null)
                {
                    if (ds.Tables != null)
                    {
                        if (ds.Tables.Count > 0)
                        {
                            if (ds.Tables[0].Rows != null)
                            {
                                if (ds.Tables[0].Rows.Count > 0)
                                {
                                    currentAuthentication = Convert.ToInt32(ds.Tables[0].Rows[0]["Auth"]);
                                    return(true);
                                }
                            }
                        }
                    }
                }
                currentAuthentication = 0;
                return(false);
            }
            catch (Exception ex)
            {
                DbCallback.CloseConnection();
                throw ex;
            }
        }
 public long GetIntValue(string name)
 {
     try
     {
         DataSet ds = new DataSet();
         stm = "SELECT * FROM tbConfig WHERE Name=@Name";
         DbCallback.SetCommandText(stm);
         DbCallback.AddInputParameter("@Name", SqlDbType.NVarChar, name);
         ds = DbCallback.ExecuteToDataSet();
         if (ds != null)
         {
             if (ds.Tables != null)
             {
                 if (ds.Tables.Count > 0)
                 {
                     if (ds.Tables[0].Rows != null)
                     {
                         if (ds.Tables[0].Rows.Count > 0)
                         {
                             if (!DBNull.Value.Equals(ds.Tables[0].Rows[0]["IntVal"]))
                             {
                                 return(Convert.ToInt32(ds.Tables[0].Rows[0]["IntVal"]));
                             }
                         }
                     }
                 }
             }
         }
         throw new Exception("GetIntValue error!");
     }
     catch (Exception ex)
     {
         DbCallback.CloseConnection();
         throw ex;
     }
 }
Exemple #11
0
        public DataSet ExecuteToDataSet(string sprocName, Dictionary <string, ParameterStructure> inputs, out int returnValue, ref Dictionary <string, ParameterStructure> output)
        {
            try
            {
                returnValue = -99;
                DataSet ds = new DataSet();

                // -------------------------------------------
                // Store procedure
                // -------------------------------------------
                DbCallback.SetCommandStoredProcedure(sprocName); // all parameters cleared

                // -------------------------------------------
                // input parameters
                // -------------------------------------------
                if (inputs != null)
                {
                    foreach (KeyValuePair <string, ParameterStructure> param in inputs)
                    {
                        DbCallback.AddInputParameter(param.Value.Name, param.Value.sqlDbType, param.Value.dbValue);
                    }
                }

                // -------------------------------------------
                // output parameters
                // -------------------------------------------
                if (output != null)
                {
                    foreach (KeyValuePair <string, ParameterStructure> param in output)
                    {
                        if (param.Value.Size <= 0)
                        {
                            DbCallback.AddOutputParameter(param.Value.Name, param.Value.sqlDbType);
                        }
                        else
                        {
                            DbCallback.AddOutputParameter(param.Value.Name, param.Value.sqlDbType, param.Value.Size);
                        }
                    }
                }

                // -------------------------------------------
                // Set return
                // -------------------------------------------
                DbCallback.SetReturnValue();

                // -------------------------------------------
                // Execute
                // -------------------------------------------
                ds = DbCallback.ExecuteToDataSet();

                // -------------------------------------------
                // Get output parameters
                // -------------------------------------------
                if (output != null)
                {
                    foreach (KeyValuePair <string, ParameterStructure> param in output)
                    {
                        param.Value.dbValue = DbCallback.OutputParameterToObject(param.Value.Name);
                    }
                }

                // -------------------------------------------
                // Return value
                // -------------------------------------------
                returnValue = DbCallback.GetReturnValue();

                // -------------------------------------------
                // Return DataSet
                // -------------------------------------------
                if (ds != null)
                {
                    return(ds);
                }

                // -------------------------------------------
                // safety
                // -------------------------------------------
                return(null);
            }
            catch (Exception ex)
            {
                DbCallback.CloseConnection();
                throw ex;
            }
        }