コード例 #1
0
        /// <summary>
        /// 从预交金表中查询一个数据
        /// </summary>
        /// <param name="prepaidpayment"></param>
        /// <returns></returns>
        public DataTable FindPrepaidPaymentByPID(PrepaidPayment prepaidpayment)
        {
            this.prepaidpayment = prepaidpayment;
            Sqlhelper sqlhelper = new Sqlhelper();
            DataTable datatable = sqlhelper.Exesql("SELECT * FROM dbo.PrepaidPayment WHERE  PatientID='" + prepaidpayment.PatientID + "' ");

            return(datatable);
        }
コード例 #2
0
        /// <summary>
        /// 缴费操作
        /// <input>
        /// PrepaidPayment
        /// </input>
        /// </summary>
        /// <param name="prepaidpayment"></param>
        /// <returns></returns>
        public Boolean Pay(PrepaidPayment prepaidpayment)
        {
            this.prepaidpayment = prepaidpayment;
            Sqlhelper sqlhelper = new Sqlhelper();
            DataTable datatable = new DataTable();

            datatable = sqlhelper.Exesql("SELECT * from PrepaidPayment WHERE  PatientID = '" + prepaidpayment.PatientID + "' AND Time='" + prepaidpayment.Time + "'");
            if (datatable.Rows.Count > 0)//检查是否有同一日期同一用户的数据,有则更新
            {
                int resualt = sqlhelper.ExecuteNonQuery("update PrepaidPayment set Prepay=Prepay+'" + prepaidpayment.Prepay + "' where PatientID = '" + prepaidpayment.PatientID + "'");
                if (resualt > 0)
                {
                    Balance balance = new Balance();
                    balance.PatientID    = prepaidpayment.PatientID;
                    balance.BalanceMoney = prepaidpayment.Prepay;
                    updateBalance(balance);
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            else
            {
                //先检查是否有此用户
                Patientinfo patientinfo = new Patientinfo();
                Patients    patient     = new Patients();
                patient.PatientID = prepaidpayment.PatientID;
                if (patientinfo.FindPatient(patient))//若存在此用户,则插入新的数据
                {
                    int resualt = sqlhelper.ExecuteNonQuery("INSERT INTO PrepaidPayment( PatientID,Time,Prepay) VAlUES('" + prepaidpayment.PatientID + "', '" + prepaidpayment.Time + "','" + prepaidpayment.Prepay + "') ");
                    if (resualt > 0)//插入成功,则修改Balance中的值
                    {
                        Balance balance = new Balance();
                        balance.PatientID    = prepaidpayment.PatientID;
                        balance.BalanceMoney = prepaidpayment.Prepay;
                        if (FindBalance(balance))//Balance中有此数据,则更新数据
                        {
                            updateBalance(balance);
                        }
                        else//Balance 中无此数据,则插入;
                        {
                            insertBalance(balance);
                        }
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
                else
                {
                    return(false);
                }
            }
        }