예제 #1
0
        IList <InjectionMessage> IInjectionMessageManager.GetInjectionMessageList(
            IInjectionMessageStorage pStorage,
            QueryInjectionMessage pQueryInjectionMessage)
        {
            IList <InjectionMessage> response = null;

            try
            {
                #region Verify argument

                Verify.ArgumentNotNull(pStorage, "pStorage");
                Verify.ArgumentNotNull(pQueryInjectionMessage, "pQueryInjectionMessage");

                #endregion

                response =
                    pStorage.ListInjectionMessage(pQueryInjectionMessage);
            }
            catch (Exception ex)
            {
                ExceptionHandler.DealWithException(ex);
            }

            return(response);
        }
        private void btnSelect_Click(object sender, EventArgs e)
        {
            IList <InjectionMessage> injectionMessageList = new List <InjectionMessage>();

            IInjectionMessageStorage injectionMessageStorage = new InjectionMessageStorage();

            IInjectorStorage injectorStorage = new InjectorStorage();

            IVaccineStorage vaccineStorage = new VaccineStorage();

            QueryInjectionMessage queryInjectionMessage = new QueryInjectionMessage();

            #region pspselect
            if (cmbInjectorName.Text.Trim() != "" && cmbVaccineName.Text.Trim() != "")
            {
                queryInjectionMessage.InjectorID             = Convert.ToInt32(cmbInjectorName.SelectedValue.ToString());
                queryInjectionMessage.VaccineID              = Convert.ToInt32(cmbVaccineName.SelectedValue.ToString());
                queryInjectionMessage.InjectionMessageSite   = textInjectionMessageSite.Text.Trim();
                queryInjectionMessage.InjectionMessageDoctor = textInjectionMessageDoctor.Text.Trim();
            }
            else if (cmbInjectorName.Text.Trim() == "" && cmbVaccineName.Text.Trim() != "")
            {
                queryInjectionMessage.VaccineID              = Convert.ToInt32(cmbVaccineName.SelectedValue.ToString());
                queryInjectionMessage.InjectionMessageSite   = textInjectionMessageSite.Text.Trim();
                queryInjectionMessage.InjectionMessageDoctor = textInjectionMessageDoctor.Text.Trim();
            }
            else if (cmbInjectorName.Text.Trim() != "" && cmbVaccineName.Text.Trim() == "")
            {
                queryInjectionMessage.InjectorID             = Convert.ToInt32(cmbInjectorName.SelectedValue.ToString());
                queryInjectionMessage.InjectionMessageSite   = textInjectionMessageSite.Text.Trim();
                queryInjectionMessage.InjectionMessageDoctor = textInjectionMessageDoctor.Text.Trim();
            }
            else
            {
                queryInjectionMessage.InjectionMessageSite   = textInjectionMessageSite.Text.Trim();
                queryInjectionMessage.InjectionMessageDoctor = textInjectionMessageDoctor.Text.Trim();
            }
            #endregion

            injectionMessageList = injectionMessageStorage.ListInjectionMessage(queryInjectionMessage);

            foreach (InjectionMessage injectionMessage in injectionMessageList)                 //对injectionMessageList数组遍历
            {
                injectionMessage.InjectorName = (injectorStorage.ReadInjector(injectionMessage.InjectorID)).InjectorName;
                injectionMessage.VaccineName  = (vaccineStorage.ReadVaccine(injectionMessage.VaccineID)).VaccineName;
            }

            dgvInjectionMessage.AutoGenerateColumns = true;
            dgvInjectionMessage.DataSource          = injectionMessageList;

            dgvInjectionMessage.Columns[0].Visible = false;
            dgvInjectionMessage.Columns[1].Visible = false;
            dgvInjectionMessage.Columns[3].Visible = false;

            dgvInjectionMessage.Columns[2].Width = 130;
            dgvInjectionMessage.Columns[4].Width = 130;
            dgvInjectionMessage.Columns[5].Width = 130;
            dgvInjectionMessage.Columns[6].Width = 130;
            dgvInjectionMessage.Columns[7].Width = 130;
        }
예제 #3
0
        IList <InjectionMessage> IInjectionMessageStorage.ListInjectionMessage(QueryInjectionMessage pQueryInjectionMessage)
        {
            List <InjectionMessage> injectionMessageList = null;
            SqlConnection           conn;
            IDataReader             reader;

            try
            {
                Verify.ArgumentNotNull(pQueryInjectionMessage, "pQueryInjectionMessage");

                conn = new SqlConnection(
                    ConfigurationManager
                    .ConnectionStrings["DEFAULT"].ToString());

                conn.Open();

                reader = InjectionMessageSelectWrapper.ExecuteReader(
                    conn,
                    pQueryInjectionMessage);

                if (reader != null)
                {
                    injectionMessageList = new List <InjectionMessage>();

                    while (reader.Read())
                    {
                        InjectionMessage myInjectionMessage = DAUtil.ReadInjectionMessage(
                            reader);

                        injectionMessageList.Add(myInjectionMessage);
                    }
                }

                conn.Close();
            }
            catch (Exception ex)
            {
                ExceptionHandler.DealWithException(ex);
                //switch (ex.GetType().FullName)
                //{
                //    case "System.ArgumentNullException":
                //        {
                //            throw new ArgumentNullException(ex.Message);
                //        }
                //    case "System.ArgumentException":
                //        {
                //            throw new ArgumentException(ex.Message);
                //        }
                //    default:
                //        throw new Exception(ex.Message);
                //}
            }

            return(injectionMessageList);
        }
예제 #4
0
        public static SqlDataReader ExecuteReader(
            SqlConnection connection,
            QueryInjectionMessage pQueryInjectionMessage)
        {
            SqlDataReader reader;
            SqlCommand    cmd = null;
            SqlParameter  p;

            try
            {
                cmd = new SqlCommand();

                cmd.CommandText = "spInjectionMessageSelect";

                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Connection  = connection;

                //*******     InjectionMessageID     *******
                object val;
                if (pQueryInjectionMessage.InjectionMessageID == null)
                {
                    val = DBNull.Value;
                }
                else
                {
                    val = pQueryInjectionMessage.InjectionMessageID;
                }

                p = new SqlParameter("@pInjectionMessageID", SqlDbType.Int);

                p.Direction = ParameterDirection.Input;
                p.Value     = val;
                cmd.Parameters.Add(p);

                //*******     InjectorID     *******
                if (pQueryInjectionMessage.InjectorID == null)
                {
                    val = DBNull.Value;
                }
                else
                {
                    val = pQueryInjectionMessage.InjectorID;
                }

                p           = new SqlParameter("@pInjectorID", SqlDbType.Int);
                p.Direction = ParameterDirection.Input;
                p.Value     = val;
                cmd.Parameters.Add(p);

                //*******     InjectorName     *******
                if (pQueryInjectionMessage.InjectorName == null ||
                    pQueryInjectionMessage.InjectorName == "")
                {
                    val = DBNull.Value;
                }
                else
                {
                    val = pQueryInjectionMessage.InjectorName;
                }

                p           = new SqlParameter("@pInjectorName", SqlDbType.VarChar, 50);
                p.Direction = ParameterDirection.Input;
                p.Value     = val;
                cmd.Parameters.Add(p);

                //*******     VaccineID     *******
                if (pQueryInjectionMessage.VaccineID == null)
                {
                    val = DBNull.Value;
                }
                else
                {
                    val = pQueryInjectionMessage.VaccineID;
                }

                p           = new SqlParameter("@pVaccineID", SqlDbType.Int);
                p.Direction = ParameterDirection.Input;
                p.Value     = val;
                cmd.Parameters.Add(p);

                //*******     VaccineName     *******
                if (pQueryInjectionMessage.VaccineName == null ||
                    pQueryInjectionMessage.VaccineName == "")
                {
                    val = DBNull.Value;
                }
                else
                {
                    val = pQueryInjectionMessage.VaccineName;
                }

                p           = new SqlParameter("@pVaccineName", SqlDbType.VarChar, 50);
                p.Direction = ParameterDirection.Input;
                p.Value     = val;
                cmd.Parameters.Add(p);

                //*******     InjectionMessageSite     *******
                if (pQueryInjectionMessage.InjectionMessageSite == null ||
                    pQueryInjectionMessage.InjectionMessageSite == "")
                {
                    val = DBNull.Value;
                }
                else
                {
                    val = pQueryInjectionMessage.InjectionMessageSite;
                }

                p           = new SqlParameter("@pInjectionMessageSite", SqlDbType.VarChar, 50);
                p.Direction = ParameterDirection.Input;
                p.Value     = val;
                cmd.Parameters.Add(p);

                //*******     VaccineName     *******
                if (pQueryInjectionMessage.InjectionMessageTime == null)
                {
                    val = DBNull.Value;
                }
                else
                {
                    val = pQueryInjectionMessage.InjectionMessageTime;
                }

                p           = new SqlParameter("@pInjectionMessageTime", SqlDbType.DateTime);
                p.Direction = ParameterDirection.Input;
                p.Value     = val;
                cmd.Parameters.Add(p);

                //*******     InjectionMessageDoctor     *******
                if (pQueryInjectionMessage.InjectionMessageDoctor == null ||
                    pQueryInjectionMessage.InjectionMessageDoctor == "")
                {
                    val = DBNull.Value;
                }
                else
                {
                    val = pQueryInjectionMessage.InjectionMessageDoctor;
                }

                p           = new SqlParameter("@pInjectionMessageDoctor", SqlDbType.VarChar, 50);
                p.Direction = ParameterDirection.Input;
                p.Value     = val;
                cmd.Parameters.Add(p);



                reader = cmd.ExecuteReader();
            }

            finally
            {
                if (cmd != null)
                {
                    cmd.Dispose();
                }
            }
            return(reader);
        }
        public void InjectionMessageListSuccess()
        {
            List <InjectionMessage> injectionMessageList = new List <InjectionMessage>();

            IInjectionMessageStorage pInjectionMessageStorage = new InjectionMessageStorage();
            IInjectorStorage         pInjectorStorage         = new InjectorStorage();
            IVaccineStorage          pVaccineStorage          = new VaccineStorage();

            int pgetInjectorID = getInjectorID();
            int pgetVaccineID  = getVaccineID();

            InjectionMessage myInjectionMessage = CreateInjectionMessageForTest(
                pgetInjectorID,
                pInjectorStorage.ReadInjector(pgetInjectorID).InjectorName,
                pgetVaccineID,
                pVaccineStorage.ReadVaccine(pgetVaccineID).VaccineName,
                "某某人民医院",
                "2016-03-30",
                "陈医生");

            InjectionMessage createdInjectionMessage =
                pInjectionMessageStorage.CreateInjectionMessage(myInjectionMessage);

            injectionMessageList.Add(createdInjectionMessage);

            pgetInjectorID = getInjectorID();

            myInjectionMessage = CreateInjectionMessageForTest(
                pgetInjectorID,
                pInjectorStorage.ReadInjector(pgetInjectorID).InjectorName,
                createdInjectionMessage.VaccineID,
                pVaccineStorage.ReadVaccine(createdInjectionMessage.VaccineID).VaccineName,
                "某某人民医院",
                "2016-03-30",
                "陈医生");

            createdInjectionMessage =
                pInjectionMessageStorage.CreateInjectionMessage(myInjectionMessage);

            injectionMessageList.Add(createdInjectionMessage);

            pgetVaccineID = getVaccineID();

            myInjectionMessage = CreateInjectionMessageForTest(
                createdInjectionMessage.InjectorID,
                pInjectorStorage.ReadInjector(createdInjectionMessage.InjectorID).InjectorName,
                pgetVaccineID,
                pVaccineStorage.ReadVaccine(pgetVaccineID).VaccineName,
                "某某人民医院",
                "2016-03-30",
                "陈医生");

            createdInjectionMessage =
                pInjectionMessageStorage.CreateInjectionMessage(myInjectionMessage);

            injectionMessageList.Add(createdInjectionMessage);

            myInjectionMessage = CreateInjectionMessageForTest(
                createdInjectionMessage.InjectorID,
                pInjectorStorage.ReadInjector(createdInjectionMessage.InjectorID).InjectorName,
                createdInjectionMessage.VaccineID,
                pVaccineStorage.ReadVaccine(createdInjectionMessage.VaccineID).VaccineName,
                "海口市中医院",
                "2016-03-30",
                "陈医生");

            createdInjectionMessage =
                pInjectionMessageStorage.CreateInjectionMessage(myInjectionMessage);

            injectionMessageList.Add(createdInjectionMessage);

            myInjectionMessage = CreateInjectionMessageForTest(
                createdInjectionMessage.InjectorID,
                pInjectorStorage.ReadInjector(createdInjectionMessage.InjectorID).InjectorName,
                createdInjectionMessage.VaccineID,
                pVaccineStorage.ReadVaccine(createdInjectionMessage.VaccineID).VaccineName,
                "海口市中医院",
                "2016-04-25",
                "陈医生");

            createdInjectionMessage =
                pInjectionMessageStorage.CreateInjectionMessage(myInjectionMessage);

            injectionMessageList.Add(createdInjectionMessage);

            myInjectionMessage = CreateInjectionMessageForTest(
                createdInjectionMessage.InjectorID,
                pInjectorStorage.ReadInjector(createdInjectionMessage.InjectorID).InjectorName,
                createdInjectionMessage.VaccineID,
                pVaccineStorage.ReadVaccine(createdInjectionMessage.VaccineID).VaccineName,
                "海口市中医院",
                "2016-04-25",
                "欧阳医生");

            createdInjectionMessage =
                pInjectionMessageStorage.CreateInjectionMessage(myInjectionMessage);

            injectionMessageList.Add(createdInjectionMessage);

            QueryInjectionMessage queryInjectionMessage = new QueryInjectionMessage();

            queryInjectionMessage.InjectionMessageID     = null;
            queryInjectionMessage.InjectorID             = null;
            queryInjectionMessage.VaccineID              = null;
            queryInjectionMessage.InjectionMessageSite   = null;
            queryInjectionMessage.InjectionMessageTime   = null;
            queryInjectionMessage.InjectionMessageDoctor = null;

            IList <InjectionMessage> readedInjectionMessageList =
                pInjectionMessageStorage.ListInjectionMessage(queryInjectionMessage);

            AssertInjectionMessageListsEqual(injectionMessageList, readedInjectionMessageList);

            injectionMessageList.RemoveAt(0);

            queryInjectionMessage = new QueryInjectionMessage();

            queryInjectionMessage.InjectionMessageID     = null;
            queryInjectionMessage.InjectorID             = createdInjectionMessage.InjectorID;
            queryInjectionMessage.VaccineID              = null;
            queryInjectionMessage.InjectionMessageSite   = null;
            queryInjectionMessage.InjectionMessageTime   = null;
            queryInjectionMessage.InjectionMessageDoctor = null;

            readedInjectionMessageList =
                pInjectionMessageStorage.ListInjectionMessage(queryInjectionMessage);

            AssertInjectionMessageListsEqual(injectionMessageList, readedInjectionMessageList);

            injectionMessageList.RemoveAt(0);

            queryInjectionMessage = new QueryInjectionMessage();

            queryInjectionMessage.InjectionMessageID     = null;
            queryInjectionMessage.InjectorID             = null;
            queryInjectionMessage.VaccineID              = createdInjectionMessage.VaccineID;
            queryInjectionMessage.InjectionMessageSite   = null;
            queryInjectionMessage.InjectionMessageTime   = null;
            queryInjectionMessage.InjectionMessageDoctor = null;

            readedInjectionMessageList =
                pInjectionMessageStorage.ListInjectionMessage(queryInjectionMessage);

            AssertInjectionMessageListsEqual(injectionMessageList, readedInjectionMessageList);

            injectionMessageList.RemoveAt(0);

            queryInjectionMessage = new QueryInjectionMessage();

            queryInjectionMessage.InjectionMessageID     = null;
            queryInjectionMessage.InjectorID             = null;
            queryInjectionMessage.VaccineID              = null;
            queryInjectionMessage.InjectionMessageSite   = "海口市中医院";
            queryInjectionMessage.InjectionMessageTime   = null;
            queryInjectionMessage.InjectionMessageDoctor = null;

            readedInjectionMessageList =
                pInjectionMessageStorage.ListInjectionMessage(queryInjectionMessage);

            AssertInjectionMessageListsEqual(injectionMessageList, readedInjectionMessageList);

            injectionMessageList.RemoveAt(0);

            queryInjectionMessage = new QueryInjectionMessage();

            queryInjectionMessage.InjectionMessageID     = null;
            queryInjectionMessage.InjectorID             = null;
            queryInjectionMessage.VaccineID              = null;
            queryInjectionMessage.InjectionMessageSite   = null;
            queryInjectionMessage.InjectionMessageTime   = Convert.ToDateTime("2016-04-25");
            queryInjectionMessage.InjectionMessageDoctor = null;

            readedInjectionMessageList =
                pInjectionMessageStorage.ListInjectionMessage(queryInjectionMessage);

            AssertInjectionMessageListsEqual(injectionMessageList, readedInjectionMessageList);

            injectionMessageList.RemoveAt(0);

            queryInjectionMessage = new QueryInjectionMessage();

            queryInjectionMessage.InjectionMessageID     = null;
            queryInjectionMessage.InjectorID             = null;
            queryInjectionMessage.VaccineID              = null;
            queryInjectionMessage.InjectionMessageSite   = null;
            queryInjectionMessage.InjectionMessageTime   = null;
            queryInjectionMessage.InjectionMessageDoctor = "欧阳医生";

            readedInjectionMessageList =
                pInjectionMessageStorage.ListInjectionMessage(queryInjectionMessage);

            AssertInjectionMessageListsEqual(injectionMessageList, readedInjectionMessageList);
        }