コード例 #1
0
        public bool Fetch(int CID)
        {
            // declare reader

            SqlDataReader dr;

            SqlParameter[] arrParams = new SqlParameter[1];

            arrParams[0] = new SqlParameter("@CID", CID);

            dr = SqlHelper.ExecuteReader(conn, CommandType.StoredProcedure, "app_Code_GetByID", arrParams);

            if (dr.Read())
            {
                // declare return value

                Codes result = new Codes();

                //DateTime _datetime;

                int _int;

                //decimal _decimal;

                if (int.TryParse(dr["CID"].ToString(), out _int))
                {
                    this.CID = _int;
                }
                if (int.TryParse(dr["CTID"].ToString(), out _int))
                {
                    this.CTID = _int;
                }
                this.Code        = dr["Code"].ToString();
                this.Description = dr["Description"].ToString();

                if (int.TryParse(dr["TenID"].ToString(), out _int))
                {
                    this.TenID = _int;
                }
                if (int.TryParse(dr["FldInt1"].ToString(), out _int))
                {
                    this.FldInt1 = _int;
                }
                if (int.TryParse(dr["FldInt2"].ToString(), out _int))
                {
                    this.FldInt2 = _int;
                }
                if (int.TryParse(dr["FldInt3"].ToString(), out _int))
                {
                    this.FldInt3 = _int;
                }
                this.FldBit1  = bool.Parse(dr["FldBit1"].ToString());
                this.FldBit2  = bool.Parse(dr["FldBit2"].ToString());
                this.FldBit3  = bool.Parse(dr["FldBit3"].ToString());
                this.FldText1 = dr["FldText1"].ToString();
                this.FldText2 = dr["FldText2"].ToString();
                this.FldText3 = dr["FldText3"].ToString();

                dr.Close();

                return(true);
            }

            dr.Close();

            return(false);
        }
コード例 #2
0
        public static int Delete(Codes o)
        {

            int iReturn = -1; //assume the worst

            SqlParameter[] arrParams = new SqlParameter[1];

            arrParams[0] = new SqlParameter("@CID", GlobalUtilities.DBSafeValue(o.CID, o.CID.GetTypeCode()));

            try
            {

                iReturn = SqlHelper.ExecuteNonQuery(conn, CommandType.StoredProcedure, "app_Code_Delete", arrParams);

            }

            catch (SqlException exx)
            {

                System.Diagnostics.Debug.Write(exx.Message);

            }

            return iReturn;

        }
コード例 #3
0
        public static int Insert(Codes o)
        {

            SqlParameter[] arrParams = new SqlParameter[14];

            arrParams[0] = new SqlParameter("@CTID", GlobalUtilities.DBSafeValue(o.CTID, o.CTID.GetTypeCode()));
            arrParams[1] = new SqlParameter("@Code", GlobalUtilities.DBSafeValue(o.Code, o.Code.GetTypeCode()));
            arrParams[2] = new SqlParameter("@Description", GlobalUtilities.DBSafeValue(o.Description, o.Description.GetTypeCode()));
            arrParams[3] = new SqlParameter("@TenID", GlobalUtilities.DBSafeValue(o.TenID, o.TenID.GetTypeCode()));
            arrParams[4] = new SqlParameter("@FldInt1", GlobalUtilities.DBSafeValue(o.FldInt1, o.FldInt1.GetTypeCode()));
            arrParams[5] = new SqlParameter("@FldInt2", GlobalUtilities.DBSafeValue(o.FldInt2, o.FldInt2.GetTypeCode()));
            arrParams[6] = new SqlParameter("@FldInt3", GlobalUtilities.DBSafeValue(o.FldInt3, o.FldInt3.GetTypeCode()));
            arrParams[7] = new SqlParameter("@FldBit1", GlobalUtilities.DBSafeValue(o.FldBit1, o.FldBit1.GetTypeCode()));
            arrParams[8] = new SqlParameter("@FldBit2", GlobalUtilities.DBSafeValue(o.FldBit2, o.FldBit2.GetTypeCode()));
            arrParams[9] = new SqlParameter("@FldBit3", GlobalUtilities.DBSafeValue(o.FldBit3, o.FldBit3.GetTypeCode()));
            arrParams[10] = new SqlParameter("@FldText1", GlobalUtilities.DBSafeValue(o.FldText1, o.FldText1.GetTypeCode()));
            arrParams[11] = new SqlParameter("@FldText2", GlobalUtilities.DBSafeValue(o.FldText2, o.FldText2.GetTypeCode()));
            arrParams[12] = new SqlParameter("@FldText3", GlobalUtilities.DBSafeValue(o.FldText3, o.FldText3.GetTypeCode()));

            arrParams[13] = new SqlParameter("@CID", GlobalUtilities.DBSafeValue(o.CID, o.CID.GetTypeCode()));
            arrParams[13].Direction = ParameterDirection.Output;

            SqlHelper.ExecuteNonQuery(conn, CommandType.StoredProcedure, "app_Code_Insert", arrParams);

            o.CID = int.Parse(arrParams[13].Value.ToString());

            return o.CID;

        }
コード例 #4
0
        public static int Update(Codes o)
        {

            int iReturn = -1; //assume the worst

            SqlParameter[] arrParams = new SqlParameter[14];

            arrParams[0] = new SqlParameter("@CID", GlobalUtilities.DBSafeValue(o.CID, o.CID.GetTypeCode()));
            arrParams[1] = new SqlParameter("@CTID", GlobalUtilities.DBSafeValue(o.CTID, o.CTID.GetTypeCode()));
            arrParams[2] = new SqlParameter("@Code", GlobalUtilities.DBSafeValue(o.Code, o.Code.GetTypeCode()));
            arrParams[3] = new SqlParameter("@Description", GlobalUtilities.DBSafeValue(o.Description, o.Description.GetTypeCode()));

            arrParams[4] = new SqlParameter("@TenID", GlobalUtilities.DBSafeValue(o.TenID, o.TenID.GetTypeCode()));
            arrParams[5] = new SqlParameter("@FldInt1", GlobalUtilities.DBSafeValue(o.FldInt1, o.FldInt1.GetTypeCode()));
            arrParams[6] = new SqlParameter("@FldInt2", GlobalUtilities.DBSafeValue(o.FldInt2, o.FldInt2.GetTypeCode()));
            arrParams[7] = new SqlParameter("@FldInt3", GlobalUtilities.DBSafeValue(o.FldInt3, o.FldInt3.GetTypeCode()));
            arrParams[8] = new SqlParameter("@FldBit1", GlobalUtilities.DBSafeValue(o.FldBit1, o.FldBit1.GetTypeCode()));
            arrParams[9] = new SqlParameter("@FldBit2", GlobalUtilities.DBSafeValue(o.FldBit2, o.FldBit2.GetTypeCode()));
            arrParams[10] = new SqlParameter("@FldBit3", GlobalUtilities.DBSafeValue(o.FldBit3, o.FldBit3.GetTypeCode()));
            arrParams[11] = new SqlParameter("@FldText1", GlobalUtilities.DBSafeValue(o.FldText1, o.FldText1.GetTypeCode()));
            arrParams[12] = new SqlParameter("@FldText2", GlobalUtilities.DBSafeValue(o.FldText2, o.FldText2.GetTypeCode()));
            arrParams[13] = new SqlParameter("@FldText3", GlobalUtilities.DBSafeValue(o.FldText3, o.FldText3.GetTypeCode()));

            try
            {

                iReturn = SqlHelper.ExecuteNonQuery(conn, CommandType.StoredProcedure, "app_Code_Update", arrParams);

            }

            catch (SqlException exx)
            {

                System.Diagnostics.Debug.Write(exx.Message);

            }

            return iReturn;

        }
コード例 #5
0
        public bool Fetch(int CID)
        {

            // declare reader

            SqlDataReader dr;

            SqlParameter[] arrParams = new SqlParameter[1];

            arrParams[0] = new SqlParameter("@CID", CID);

            dr = SqlHelper.ExecuteReader(conn, CommandType.StoredProcedure, "app_Code_GetByID", arrParams);

            if (dr.Read())
            {

                // declare return value

                Codes result = new Codes();

                //DateTime _datetime;

                int _int;

                //decimal _decimal;

                if (int.TryParse(dr["CID"].ToString(), out _int)) this.CID = _int;
                if (int.TryParse(dr["CTID"].ToString(), out _int)) this.CTID = _int;
                this.Code = dr["Code"].ToString();
                this.Description = dr["Description"].ToString();

                if (int.TryParse(dr["TenID"].ToString(), out _int)) this.TenID = _int;
                if (int.TryParse(dr["FldInt1"].ToString(), out _int)) this.FldInt1 = _int;
                if (int.TryParse(dr["FldInt2"].ToString(), out _int)) this.FldInt2 = _int;
                if (int.TryParse(dr["FldInt3"].ToString(), out _int)) this.FldInt3 = _int;
                this.FldBit1 = bool.Parse(dr["FldBit1"].ToString());
                this.FldBit2 = bool.Parse(dr["FldBit2"].ToString());
                this.FldBit3 = bool.Parse(dr["FldBit3"].ToString());
                this.FldText1 = dr["FldText1"].ToString();
                this.FldText2 = dr["FldText2"].ToString();
                this.FldText3 = dr["FldText3"].ToString();

                dr.Close();

                return true;

            }

            dr.Close();

            return false;

        }