Пример #1
0
        public ClientInsurance InsertInsuranceAuthorizations(ClientInsurance ins, int clientID)
        {
            for (int insAuth = 0; insAuth < ins.insuranceAuthorization.Count; insAuth++)
            {
                DbCommand ins_InsuranceAuthorization = db.GetStoredProcCommand("ins_InsuranceAuthorization");
                db.AddInParameter(ins_InsuranceAuthorization, "@clientID", DbType.Int32, clientID);
                db.AddInParameter(ins_InsuranceAuthorization, "@insuranceID", DbType.Int32, ins.insuranceID);
                db.AddInParameter(ins_InsuranceAuthorization, "@authorized_From", DbType.Boolean, ins.insuranceAuthorization[insAuth].authorizedFrom);
                db.AddInParameter(ins_InsuranceAuthorization, "@authorized_To", DbType.Boolean, ins.insuranceAuthorization[insAuth].authorizedTo);
                db.AddInParameter(ins_InsuranceAuthorization, "@insuranceAuthorizationType", DbType.String, ins.insuranceAuthorization[insAuth].insuranceAuthorizationType);

                db.AddOutParameter(ins_InsuranceAuthorization, "@success", DbType.Boolean, 1);
                db.AddOutParameter(ins_InsuranceAuthorization, "@insuranceAuthorizationID", DbType.Int32, sizeof(int));

                bool success;
                try
                {
                    db.ExecuteNonQuery(ins_InsuranceAuthorization);
                    success = Convert.ToBoolean(db.GetParameterValue(ins_InsuranceAuthorization, "@success"));
                    ins.insuranceAuthorization[insAuth].insuranceAuthID = Convert.ToInt32(db.GetParameterValue(ins_InsuranceAuthorization, "@insuranceAuthorizationID"));
                }
                catch (Exception e)
                {
                    Debug.WriteLine("InsertClientInsuranceAuthorization failed, exception: {0}.", e);
                    success = false;
                    throw;
                }
            }

            return(ins);
        }
Пример #2
0
        public ClientInsurance InsertClientInsurance(ClientInsurance createdInsurance, int clientID)
        {
            DbCommand ins_ClientInsurance = db.GetStoredProcCommand("ins_ClientInsurance");

            db.AddInParameter(ins_ClientInsurance, "@clientID", DbType.Int32, clientID);
            db.AddInParameter(ins_ClientInsurance, "@insuranceID", DbType.Int32, createdInsurance.insuranceID);
            db.AddInParameter(ins_ClientInsurance, "@insurancePolicyID", DbType.String, createdInsurance.insurancePolicyID);
            db.AddInParameter(ins_ClientInsurance, "@insurancePolicyName", DbType.String, createdInsurance.insuranceName);
            db.AddInParameter(ins_ClientInsurance, "@insuranceMedPreAuthNumber", DbType.Int32, createdInsurance.medPreAuthNumber);

            db.AddOutParameter(ins_ClientInsurance, "@success", DbType.Boolean, 1);
            db.AddOutParameter(ins_ClientInsurance, "@insuranceID", DbType.Int32, sizeof(int));

            bool success;

            try
            {
                db.ExecuteNonQuery(ins_ClientInsurance);
                success = Convert.ToBoolean(db.GetParameterValue(ins_ClientInsurance, "@success"));

                if (createdInsurance.insuranceAuthorization.Count > 0)
                {
                    createdInsurance = InsertInsuranceAuthorizations(createdInsurance, clientID);
                }
            }
            catch (Exception e)
            {
                Debug.WriteLine("InsertClientInsurance failed, exception: {0}.", e);
                success = false;
                throw;
            }

            return(createdInsurance);
        }