示例#1
0
        public Tables.tblCustomer_Record GetOne_tblCustomer_Record(Int32 id)
        {
            Params.spS_tblCustomer param = new Params.spS_tblCustomer(true);

            param.SetUpConnection(string.Empty);

            param.Param_Cus_LngID = id;

            using (SPs.spS_tblCustomer sp = new SPs.spS_tblCustomer(true)) {
                System.Data.SqlClient.SqlDataReader sqlDataReader = null;
                sp.Execute(ref param, out sqlDataReader);
                param.Dispose();

                if (sqlDataReader.Read())
                {
                    Tables.tblCustomer_Record record = new Tables.tblCustomer_Record();

                    record.Col_Cus_LngID.UseNull = sqlDataReader.IsDBNull(SPs.spS_tblCustomer.Resultset1.Fields.Column_Cus_LngID.ColumnIndex);
                    if (!record.Col_Cus_LngID.UseNull)
                    {
                        record.Col_Cus_LngID.Value = sqlDataReader.GetSqlInt32(SPs.spS_tblCustomer.Resultset1.Fields.Column_Cus_LngID.ColumnIndex).Value;
                    }

                    record.Customer_Surname.UseNull = sqlDataReader.IsDBNull(SPs.spS_tblCustomer.Resultset1.Fields.Column_Cus_StrLastName.ColumnIndex);
                    if (!record.Customer_Surname.UseNull)
                    {
                        record.Customer_Surname.Value = sqlDataReader.GetSqlString(SPs.spS_tblCustomer.Resultset1.Fields.Column_Cus_StrLastName.ColumnIndex).Value;
                    }

                    record.Col_Cus_StrFirstName.UseNull = sqlDataReader.IsDBNull(SPs.spS_tblCustomer.Resultset1.Fields.Column_Cus_StrFirstName.ColumnIndex);
                    if (!record.Col_Cus_StrFirstName.UseNull)
                    {
                        record.Col_Cus_StrFirstName.Value = sqlDataReader.GetSqlString(SPs.spS_tblCustomer.Resultset1.Fields.Column_Cus_StrFirstName.ColumnIndex).Value;
                    }

                    record.Col_Cus_StrEmail.UseNull = sqlDataReader.IsDBNull(SPs.spS_tblCustomer.Resultset1.Fields.Column_Cus_StrEmail.ColumnIndex);
                    if (!record.Col_Cus_StrEmail.UseNull)
                    {
                        record.Col_Cus_StrEmail.Value = sqlDataReader.GetSqlString(SPs.spS_tblCustomer.Resultset1.Fields.Column_Cus_StrEmail.ColumnIndex).Value;
                    }


                    sqlDataReader.Close();
                    sp.Connection.Close();

                    return(record);
                }
                else
                {
                    sqlDataReader.Close();
                    sp.Connection.Close();

                    return(null);
                }
            }
        }
示例#2
0
        public void Edit_tblCustomer_Record(Tables.tblCustomer_Record record)
        {
            Params.spU_tblCustomer param = new Params.spU_tblCustomer(false);

            param.SetUpConnection(string.Empty);

            param.Param_Cus_LngID = record.Col_Cus_LngID.Value;

            if (record.Customer_Surname == null || record.Customer_Surname.UseNull)
            {
                param.Param_ConsiderNull_Cus_StrLastName = true;
                param.Param_Cus_StrLastName = SqlString.Null;
            }
            else if (!record.Customer_Surname.UseDefault)
            {
                param.Param_Cus_StrLastName = record.Customer_Surname.Value;
            }

            if (record.Col_Cus_StrFirstName == null || record.Col_Cus_StrFirstName.UseNull)
            {
                param.Param_ConsiderNull_Cus_StrFirstName = true;
                param.Param_Cus_StrFirstName = SqlString.Null;
            }
            else if (!record.Col_Cus_StrFirstName.UseDefault)
            {
                param.Param_Cus_StrFirstName = record.Col_Cus_StrFirstName.Value;
            }

            if (record.Col_Cus_StrEmail == null || record.Col_Cus_StrEmail.UseNull)
            {
                param.Param_ConsiderNull_Cus_StrEmail = true;
                param.Param_Cus_StrEmail = SqlString.Null;
            }
            else if (!record.Col_Cus_StrEmail.UseDefault)
            {
                param.Param_Cus_StrEmail = record.Col_Cus_StrEmail.Value;
            }


            using (SPs.spU_tblCustomer sp = new SPs.spU_tblCustomer(true)) {
                sp.Execute(ref param);
                param.Dispose();
            }
        }