public FrmRptPatientInfo()
        {
            InitializeComponent();

            //string sPwd = Des.Decrypt(ClsFrmMng.KEY, ConfigurationManager.AppSettings["DbPwd"]);
            db = new Database("XE");
        }
Exemplo n.º 2
0
 public ActionResult Index(int page = 1)
 {
     var db = new PetaPoco.Database("MonoCMS");
     var categories = db.Fetch<Category>("SELECT category_name FROM category");
     return View(categories);
     //return View();
 }
Exemplo n.º 3
0
 private void InitializeDatabase()
 {
     _db = new Database(_connectionStringName);
     _db.EnableAutoSelect = false;
     _db.EnableNamedParams = false;
     _db.ForceDateTimesToUtc = false;
 }
        public FrmNewCaseHis(bool isAdd, Int64 base_id, Int64 reg_id)
        {
            InitializeComponent();

            //string sPwd = Des.Decrypt(ClsFrmMng.KEY, ConfigurationManager.AppSettings["DbPwd"]);
            db = new Database("XE");

            _reg_id = reg_id;
            _isAdd = isAdd;
            _baseID = base_id;

            //ConditionValidationRule ruleNoEmpty = new ConditionValidationRule();
            //ruleNoEmpty.ConditionOperator = ConditionOperator.IsNotBlank;
            //ruleNoEmpty.ErrorText = "该项不能为空。";
            //dxValidationProvider1.SetValidationRule(MEMOMemoEdit, ruleNoEmpty);
            //dxValidationProvider1.SetValidationRule(DOSE_MEMOMemoEdit, ruleNoEmpty);

            caseHis.REG_ID = _reg_id;
            caseHis.BASE_INFO_ID = _baseID;
            caseHis.OPERATOR = ClsFrmMng.WorkerID;
            cASEHISTORYBindingSource.DataSource = caseHis;

            lookUpEdit1.Properties.DataSource = db.Fetch<VALUE_CODE>("where GROUPNAME = @0", new object[] { 11 });
            lookUpEdit1.Properties.DisplayMember = "DSP_MEMBER";
            lookUpEdit1.Properties.ValueMember = "VALUE_MEMBER";

            vALUECODEBindingSource.DataSource = db.Fetch<VALUE_CODE>("where GROUPNAME = @0", new object[] { 181 });
        }
        private void ProcessStats(IList<FeatureStatistics> stats)
        {
            try
            {
                Logger.Debug("Adding Stats to database");
                using (var database = new PetaPoco.Database(_connectionStringName))
                {
                    using (ITransaction transaction = database.GetTransaction())
                    {
                        foreach (var stat in stats)
                        {

                            foreach (var reading in stat.Readings)
                            {
                                var data = new FeatureData()
                                {
                                    Reading = reading.Name,
                                    Timestamp = DateTime.Now,
                                    Name = stat.Name,
                                    Group = stat.Group
                                };
                                data.ValueType = reading.GetType().Name;
                                SetValue(data, reading);
                                database.Insert("FeatureData", "Id", true, data);
                            }
                        }
                        transaction.Complete();
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.Error("Error saving stats to the database", ex);
            }
        }
        public FrmDefaultDocAdvice_Cfg()
        {
            InitializeComponent();

            //string sPwd = Des.Decrypt(ClsFrmMng.KEY, ConfigurationManager.AppSettings["DbPwd"]);
            db = new Database("XE");
        }
 private static List<Comment> GetAllComments()
 {
     using (var db = new Database("umbracoDbDSN"))
     {
         return db.Fetch<Comment>("SELECT * FROM forumComments WHERE isSpam = 1 ORDER BY id DESC");
     }
 }
 public DBPetapocoComparer(DbObject dbAssert, DbObject dbTarget)
 {
     _dbAssert = new Database(string.Format("Data Source={0};Version=3;Read Only=True;", dbAssert.Value),
                              new SQLiteFactory());
     _dbTarget = new Database(string.Format("Data Source={0};Version=3;Read Only=True;", dbTarget.Value),
                              new SQLiteFactory());
 }
Exemplo n.º 9
0
        //[RequireBasicAuthentication("AppHarbor")]
        public ActionResult Create(ProvisioningRequest provisionRequest)
        {
            if (provisionRequest == null || string.IsNullOrEmpty(provisionRequest.plan)) provisionRequest = new ProvisioningRequest() { callback_url = "/Response", heroku_id = Guid.NewGuid().ToString(), plan = "Free" };
            var db = new Database("DefaultConnection");
            Plan plan;
            if (!Enum.TryParse<Plan>(provisionRequest.plan, true, out plan))
            {
                throw new ArgumentException(string.Format("Plan \"{0}\" is not a valid plan", provisionRequest.plan));
            }

            var purchase = new Purchase()
            {
                CreatedBy = string.Format("{0};{1}", Request.GetForwardedHostAddress(), User.Identity.Name),
                UniqueId = Guid.NewGuid().ToString(),
                Plan = plan,
                ProviderId = provisionRequest.heroku_id,
                ProvisionStatus = ProvisionStatus.Provisioning,
                ApiKey = Guid.NewGuid().ToString(),
                ApiSecretKey = Guid.NewGuid().ToString()
            };
            // TODO: Provision the resource
            purchase.ProvisionStatus = ProvisionStatus.Provisioned;
            Purchase.Save(db, purchase);
            var output = new
            {
                id = purchase.UniqueId,
                config = new
                {
                    CONFIG_ApiKey = purchase.ApiKey,
                    CONFIG_ApiSecretKey = purchase.ApiSecretKey
                }
            };

            return Json(output, JsonRequestBehavior.AllowGet);
        }
Exemplo n.º 10
0
        public void Delete(long id)
        {
            if (id <= 0)
            {
                return;
            }

            ApiAccessPolicy policy = new ApiAccessPolicy(typeof(MixERP.Net.Entities.Core.Account), "DELETE");
            policy.Authorize();

            if (!policy.IsAuthorized)
            {
                throw new HttpResponseException(HttpStatusCode.Forbidden);
            }

            try
            {
                using (Database db = new Database(Factory.GetConnectionString(), "Npgsql"))
                {
                    db.Delete("core.accounts", "account_id", null, id);
                }
            }
            catch
            {
                throw new HttpResponseException(HttpStatusCode.InternalServerError);
            }
        }
        public bool DeleteABSAMember(BSAMemberViewModel item)
        {
            //Connect to the Umbraco DB
            var db = new PetaPoco.Database(sConnectString);

            BSAMember oModel = new BSAMember();

            oModel.BSAMemberId      = item.BSAMemberId;
            oModel.BSAMemberType    = item.BSAMemberType;
            oModel.FirstName        = item.FirstName;
            oModel.LastName         = item.LastName;
            oModel.StreetAddress    = item.StreetAddress;
            oModel.City             = item.City;
            oModel.State            = item.State;
            oModel.ZipCode          = item.ZipCode;
            oModel.District         = item.District;
            oModel.Council          = item.Council;
            oModel.Troop            = item.Troop;
            oModel.Crew             = item.Crew;
            oModel.Telephone        = item.Telephone;
            oModel.BirthDate        = item.BirthDate;
            oModel.EmailAddress     = item.EmailAddress;
            oModel.ScoutMasterId    = item.ScoutMasterId;
            oModel.BackGroundCheck  = item.BackGroundCheck;
            oModel.DeleteRecordFlag = true;

            db.Update(oModel);

            //Return the view with our model and comments
            return(true);
        }
        public FrmNewPatientBaseInfo()
        {
            InitializeComponent();

            ////string sPwd = Des.Decrypt(ClsFrmMng.KEY, ConfigurationManager.AppSettings["DbPwd"]);
            db = new Database("XE");
            ConditionValidationRule ruleNoEmpty = new ConditionValidationRule();
            ruleNoEmpty.ConditionOperator = ConditionOperator.IsNotBlank;
            ruleNoEmpty.ErrorText = "该项不能为空。";
            dxValidationProvider1.SetValidationRule(NAMETextEdit, ruleNoEmpty);
            dxValidationProvider1.SetValidationRule(ID_CODETextEdit, ruleNoEmpty);

            pATIENTBASEINFOBindingSource.DataSource = patientBase;

            MEDICARE_TYPETextEdit.Properties.DataSource = db.Fetch<VALUE_CODE>("select DSP_MEMBER, VALUE_MEMBER from VALUE_CODE where GROUPNAME = @0", new object[] { 10 });
            MEDICARE_TYPETextEdit.Properties.DisplayMember = "DSP_MEMBER";
            MEDICARE_TYPETextEdit.Properties.ValueMember = "VALUE_MEMBER";

            EDUCATIONAL_LEVELTextEdit.Properties.DataSource = db.Fetch<VALUE_CODE>("where GROUPNAME = @0", new object[] { 8 });
            EDUCATIONAL_LEVELTextEdit.Properties.DisplayMember = "DSP_MEMBER";
            EDUCATIONAL_LEVELTextEdit.Properties.ValueMember = "VALUE_MEMBER";

            MARITAL_STATUSTextEdit.Properties.DataSource = db.Fetch<VALUE_CODE>("where GROUPNAME = @0", new object[] { 9 });
            MARITAL_STATUSTextEdit.Properties.DisplayMember = "DSP_MEMBER";
            MARITAL_STATUSTextEdit.Properties.ValueMember = "VALUE_MEMBER";

            vALUECODEBindingSource.DataSource = db.Fetch<VALUE_CODE>("where groupname = 42");
            vALUECODEBindingSource1.DataSource = db.Fetch<VALUE_CODE>("where groupname = 41");
            vALUECODEBindingSource2.DataSource = db.Fetch<VALUE_CODE>("where groupname = 62");
            vALUECODEBindingSource3.DataSource = db.Fetch<VALUE_CODE>("where groupname = 63");
        }
Exemplo n.º 13
0
 public List <WorkOrder> GetWorkOrdersWithProduct()
 {
     using (var db = new PetaPoco.Database("AdventureWorks2014"))
     {
         return(GetWorkOrdersWithProduct(db));
     }
 }
        public ActionResult GetLeases()
        {
            var db = new PetaPoco.Database("umbracoDbDSN");
            var listOfLeases = db.Fetch<Lease>(new Sql().Select("*").From("_sg_Lease"));

            return Json(listOfLeases);
        }
Exemplo n.º 15
0
     public static List<Route> getRoutes()
     {
         using (Database db = new PetaPoco.Database(ModelConfig.connectionStringName("bikes")))
         {
             return db.Fetch<Route>("WHERE deleted = FALSE");
         }
 }
Exemplo n.º 16
0
        public FrmNewRegist()
        {
            InitializeComponent();
            //string sPwd = Des.Decrypt(ClsFrmMng.KEY, ConfigurationManager.AppSettings["DbPwd"]);
            db = new Database("XE");

            //db.OpenSharedConnection();
            lstOutpatientCategory = db.Fetch<OUTPATIENT_CATEGORY>("");
            OUTPATIENT_CATEGORYTextEdit.Properties.TextEditStyle = DevExpress.XtraEditors.Controls.TextEditStyles.DisableTextEditor;
            OUTPATIENT_CATEGORYTextEdit.Properties.Columns.Add(new DevExpress.XtraEditors.Controls.LookUpColumnInfo("CATEGORY_ID"));
            OUTPATIENT_CATEGORYTextEdit.Properties.Columns.Add(new DevExpress.XtraEditors.Controls.LookUpColumnInfo("CATEGORY_NAME"));
            OUTPATIENT_CATEGORYTextEdit.Properties.DataSource = lstOutpatientCategory;

            OUTPATIENT_CATEGORYTextEdit.Properties.ValueMember = "CATEGORY_ID";         // 对应ID
            OUTPATIENT_CATEGORYTextEdit.Properties.DisplayMember = "CATEGORY_NAME";     // 显示内容

            patientReg.STATUS = 0;
            patientReg.OPERATOR = ClsFrmMng.WorkerID;

            pATIENTREGISTBindingSource.DataSource = patientReg;
            //db.CloseSharedConnection();

            ConditionValidationRule ruleNoEmpty = new ConditionValidationRule();
            ruleNoEmpty.ConditionOperator = ConditionOperator.IsNotBlank;
            ruleNoEmpty.ErrorText = "该项不能为空。";
            dxValidationProvider1.SetValidationRule(NAMETextEdit, ruleNoEmpty);
            dxValidationProvider1.SetValidationRule(OUTPATIENT_CATEGORYTextEdit, ruleNoEmpty);

            pATIENTBASEINFOBindingSource.DataSource = db.Fetch<PATIENT_BASEINFO>("");
            NAMETextEdit.Properties.EditValueChanged += Properties_EditValueChanged;
        }
Exemplo n.º 17
0
 public void CreateTables()
 {
     using (var db = new Database("DataSource=\"test.sdf\"; Password=\"chrissiespassword\"", "System.Data.SqlServerCe.4.0")) {
         db.Execute("CREATE TABLE Person (Id int IDENTITY(1,1) PRIMARY KEY, LastName nvarchar (40) NOT NULL, FirstName nvarchar (40), AddressId int NOT NULL);");
         db.Execute("CREATE TABLE Address (Id int IDENTITY(1,1) PRIMARY KEY, Street nvarchar (40) NOT NULL, HouseNumber nvarchar (10));");
     }
 }
 public FrmQueryCheckInfo(string strPatName, decimal id)
 {
     InitializeComponent();
     _strPatName = strPatName;
     _id = id;
     exdb = new Database("XE");
 }
Exemplo n.º 19
0
 public static void UpdateCampaign(Campaign campaign)
 {
     using (IDatabase db = new PetaPoco.Database(Settings.ConnectionString, providerName: "SqlServer"))
     {
         db.Update(campaign);
     }
 }
Exemplo n.º 20
0
 private void GetItem(string SuppBatchGuid)
 {
     List<V_ERP_SuppOrder> items = null;
     using (var db = new Database(SQLCONN.Conn))
     {
         if (!string.IsNullOrEmpty(UserName) && UserName != "admin")
         {
             items = db.Fetch<V_ERP_SuppOrder>("select * from V_ERP_SuppOrder where SuppBatchGuid=@0  and SuppName =@1", SuppBatchGuid, UserName);
         }
         else
         {
             items = db.Fetch<V_ERP_SuppOrder>("select * from V_ERP_SuppOrder where SuppBatchGuid=@0", SuppBatchGuid);
         }
         items.ForEach(j =>
         {
             j.Reserved2 = KyGYS.Controls.CommonUtil.GetItemImgFileName(j.Reserved2);
             j.CusSavedFileName = j.CusSavedFileName!=null?KyGYS.Controls.CommonUtil.GetItemImgFileName(j.CusSavedFileName):null;
             j.CtmSavedFileName = j.CtmSavedFileName != null ? KyGYS.Controls.CommonUtil.GetItemImgFileName(j.CtmSavedFileName) : null;
         });
         var grd = new EasyGridData<V_ERP_SuppOrder>();
         grd.total = items.Count().ToString();
         grd.rows = items;
         string data = Newtonsoft.Json.JsonConvert.SerializeObject(grd);
         Response.Write(data);
         Response.End();
     }
 }
Exemplo n.º 21
0
 public static void deleteRoute(int id)
 {
     using (Database db = new PetaPoco.Database(ModelConfig.connectionStringName("bikes")))
     {
         db.Execute("UPDATE route SET deleted = TRUE WHERE id = @0", id);
     }
 }
Exemplo n.º 22
0
        public FrmNewInduce(Int64  base_id, Int64 reg_id)
        {
            InitializeComponent();

            //string sPwd = Des.Decrypt(ClsFrmMng.KEY, ConfigurationManager.AppSettings["DbPwd"]);
            db = new Database("XE");

            _reg_id = reg_id;
            _baseID = base_id;

            //ConditionValidationRule ruleNoEmpty = new ConditionValidationRule();
            //ruleNoEmpty.ConditionOperator = ConditionOperator.IsNotBlank;
            //ruleNoEmpty.ErrorText = "该项不能为空。";
            //dxValidationProvider1.SetValidationRule(MEMOMemoEdit, ruleNoEmpty);
            //dxValidationProvider1.SetValidationRule(DOSE_MEMOMemoEdit, ruleNoEmpty);

            induceMent.REG_ID = _reg_id;
            induceMent.BASE_INFO_ID = _baseID;
            induceMent.OPERATOR = ClsFrmMng.WorkerID;
            iNDUCEMENTHISTORYBindingSource.DataSource = induceMent;

            //INDUCEMENTTextEdit.Properties.TextEditStyle = DevExpress.XtraEditors.Controls.TextEditStyles.Standard;
            INDUCEMENTTextEdit.Properties.DataSource = ClsFrmMng.lstIndecumentCode;
            INDUCEMENTTextEdit.Properties.DisplayMember = "INDUCEMENT_MEMO";
            INDUCEMENTTextEdit.Properties.ValueMember = "INDUCEMENT_MEMO";
        }
Exemplo n.º 23
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="base_id"></param>
        /// <param name="reg_id"></param>
        /// <param name="isTemp">0:长期, 1:临时</param>
        public FrmNewDav(Int64 base_id, Int64 reg_id, int isTemp)
        {
            InitializeComponent();
            if (isTemp == 0)
                this.Text = "新建长期医嘱";
            else
                this.Text = "新建临时医嘱";

            //string sPwd = Des.Decrypt(ClsFrmMng.KEY, ConfigurationManager.AppSettings["DbPwd"]);
            db = new Database("XE");

            _regID = reg_id;
            _baseID = base_id;
            _isTemp = isTemp;

            docAdv.REG_ID = _regID;
            docAdv.BASE_INFO_ID = _baseID;
            docAdv.OPERATOR = ClsFrmMng.WorkerID;
            docAdv.ADVICE_TYPE = _isTemp;
            docAdv.IS_DEL = 0;
            dOCADVICEBindingSource.DataSource = docAdv;

            vALUECODEBindingSource.DataSource = db.Fetch<VALUE_CODE>("");

            M_UNITLookUpEdit.Properties.DataSource = db.Fetch<VALUE_CODE>("where GROUPNAME = @0", new object[] { 14 });
            M_UNITLookUpEdit.Properties.DisplayMember = "DSP_MEMBER";
            M_UNITLookUpEdit.Properties.ValueMember = "VALUE_MEMBER";

            M_ACTIONLookUpEdit.Properties.DataSource = db.Fetch<VALUE_CODE>("where GROUPNAME = @0", new object[] { 13 });
            M_ACTIONLookUpEdit.Properties.DisplayMember = "DSP_MEMBER";
            M_ACTIONLookUpEdit.Properties.ValueMember = "VALUE_MEMBER";
        }
Exemplo n.º 24
0
 public static Route getRoute(int id)
 {
     using (Database db = new PetaPoco.Database(ModelConfig.connectionStringName("bikes")))
     {
         return db.FirstOrDefault<Route>("WHERE id = @0", id);
     }
 }
Exemplo n.º 25
0
 public static Campaign GetById(int id)
 {
     using (IDatabase db = new PetaPoco.Database(Settings.ConnectionString, providerName: "SqlServer"))
     {
         return(db.Single <Campaign>("WHERE Id = @0", id));
     }
 }
Exemplo n.º 26
0
 void barBtnRefresh_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
 {
     using (var db = new Database()) {
         this.gridControlEx1.DataSource = db.Fetch<t_role>("select * from t_role where IsUsing=1");
         this.gridControlEx1.ReleaseFocusedRow();
     }
 }
        public FrmBloodCleanup_Drugs()
        {
            InitializeComponent();

            ////string sPwd = Des.Decrypt(ClsFrmMng.KEY, ConfigurationManager.AppSettings["DbPwd"]);
            db = new Database("XE");
        }
Exemplo n.º 28
0
        public Contato Find(int id)
        {
            Database db      = new PetaPoco.Database("PRWDEV");
            var      contato = db.First <Contato>("Select * from contatosbandre where ID=@0", id);

            return(contato);
        }
Exemplo n.º 29
0
        public void SetPoints(int trackId, TrackPoint[] points)
        {
            var sb = new StringBuilder();
            for (int i = 0; i < points.Length; i++)
            {
                if (i % 1000 == 0)
                {
                    if(sb.Length>0) sb.Remove(sb.Length - 1, 1);
                    sb.AppendLine(";").AppendLine("insert into MR.tTrackPoint (TrackId, Idx, Lat, Lon, Elevation, PointTime) values ");
                }

                var p = points[i];
                sb.AppendLine().Append("(")
                    .Append(trackId).Append(",")
                    .Append(i).Append(",")
                    .Append(p.Lat.ToString(CultureInfo.InvariantCulture)).Append(",")
                    .Append(p.Lon.ToString(CultureInfo.InvariantCulture)).Append(",")
                    .Append(p.Elevation.ToString(CultureInfo.InvariantCulture)).Append(",")
                    .Append("'").Append(p.PointTime.ToString("o",CultureInfo.InvariantCulture)).Append("'")
                    .Append("),");

            }
            var sql = sb.ToString().TrimEnd(',');
            var db = new Database(_config.ConnectionString, "System.Data.SqlClient");

            try
            {
                db.Execute(sql);
            }
            catch (SqlException ex)
            {
                throw new Exception(sql, ex);
            }
        }
Exemplo n.º 30
0
        private void btnOK_Click(object sender, EventArgs ea)
        {
            var k = roleGridEdit1.GetSelectedValue();
            if (null == k) return;
            List<MenuCtlData> lst = new List<MenuCtlData>(100);
            foreach (TreeListNode td in treeCtl1.Nodes)
            {
                var mnugrp = td.GetValue(0).ToString();
                foreach (TreeListNode tds in td.Nodes)
                {
                    var mnuname = tds.GetValue(0).ToString();
                    foreach (TreeListNode tmd in tds.Nodes)
                    {
                        var mcd = tmd.Tag as MenuCtlData;
                        if (null != mcd)
                        {
                            mcd.IsEnabled = tmd.Checked;
                            mcd.MenuGrpName = mnugrp;
                            mcd.MenuName = mnuname;
                            lst.Add(mcd);
                        }
                        foreach (TreeListNode tkd in tmd.Nodes)
                        {
                            var md = tkd.Tag as MenuCtlData;
                            if (null == md) continue;
                            md.IsEnabled = tkd.Checked;
                            md.MenuGrpName = mnugrp; md.MenuName = mnuname;
                            lst.Add(md);
                        }
                    }
                }
            }
            var usr = GetCurUser<t_user>();
            using (var db = new Database())
            {

                var et = db.FirstOrDefault<t_roleset>("select * from t_roleset where RoleId=@0", k.Id);

                var roleset = et;
                if (et != null)
                {
                    roleset.RoleSetTree = Ultra.Web.Core.Common.ObjectHelper.SerializeJson(lst);
                }
                else
                {
                    roleset = new t_roleset
                    {
                        RoleSetTree = Ultra.Web.Core.Common.ObjectHelper.SerializeJson(lst),
                        RoleId = k.Id,
                        IsUsing = true,
                        RoleName = k.Name,
                        Guid = Guid.NewGuid(),
                        Creator =this.CurUser,
                        CreateDate = TimeSync.Default.CurrentSyncTime
                    };
                }
                db.Save(roleset);
            }
            MsgBox.ShowMessage(null, "保存成功!");
        }
Exemplo n.º 31
0
 public static IEnumerable <Campaign> GetAll()
 {
     using (IDatabase db = new PetaPoco.Database(Settings.ConnectionString, providerName: "SqlServer"))
     {
         return(db.Query <Campaign>(Settings.CampaignsQuery));
     }
 }
Exemplo n.º 32
0
 private static List<Topic> GetAllTopics()
 {
     using (var db = new Database("umbracoDbDSN"))
     {
         return db.Fetch<Topic>("SELECT * FROM forumTopics WHERE isSpam = 1 ORDER BY id DESC");
     }
 }
Exemplo n.º 33
0
        //public static Payment recordPayment(Rider rider, double amount, string branch, string username, string account)
        //{
        //    Payment payment = new Payment();

        //    payment.rider = rider.name;
        //    payment.amount = amount;
        //    payment.paid_date = DateTime.Now;
        //    payment.bank_branch = branch;
        //    payment.bank_username = username;
        //    payment.bank_account = account;

        //    Database db = new PetaPoco.Database(ModelConfig.connectionStringName("bikes"));
        //    db.Insert(payment);

        //    return payment;
        //}

        //public static void deletePayment(int id)
        //{
        //    Database db = new PetaPoco.Database("bikes-clunie");
        //    db.Execute("DELETE FROM payment WHERE id = @0", id);
        //}

        internal void save()
        {
            using (Database db = new PetaPoco.Database(ModelConfig.connectionStringName("bikes")))
            {
                db.Save(this);
            }
        }
Exemplo n.º 34
0
        public FrmUserLogin()
        {
            InitializeComponent();
            try
            {
                txtUserID.Text = ConfigurationManager.AppSettings["UserID"];
                if (!string.IsNullOrEmpty(ConfigurationManager.AppSettings["ShowCommTestToolsLink"]))
                {
                    try
                    {
                        linkLabel1.Visible = Convert.ToBoolean(ConfigurationManager.AppSettings["ShowCommTestToolsLink"]);
                    }
                    catch { }
                }
            }
            catch { txtUserID.Text = ""; }

            try
            {
                //string sPwd = Des.Decrypt(ClsFrmMng.KEY, ConfigurationManager.AppSettings["DbPwd"]);
                db = new Database("XE");
            }
            catch (Exception err)
            {
                XtraMessageBox.Show(err.Message, "错误提示");
            }
        }
Exemplo n.º 35
0
        ////utility function to build the sql statement to perform the join
        //private static Sql sql()
        //{
        //    return Sql
        //        .Builder
        //        .Append("SELECT a.id, a.bike_id, a.rider_id, a.route_id, a.ride_date, a.notes,")
        //        .Append("a.reward, a.distance, a.paid, a.payment_id,")
        //        .Append("b.name AS route, c.name AS rider, d.name AS bike")
        //        .Append("FROM ride a, route b, rider c, bike d")
        //        .Append("WHERE a.route_id = b.id AND a.rider_id = c.id AND a.bike_id = d.id");
        //}

        public static List<Ride> getRides()
        {
            using (Database db = new PetaPoco.Database(ModelConfig.connectionStringName("bikes")))
            {
                return db.Fetch<Ride>("");
            }
        }
Exemplo n.º 36
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            if (!dxValidationProvider1.Validate())
                return;
            var odrs = gcOrder.GetDataSource<t_order>();
            if (odrs == null || odrs.Count < 1) {
                MsgBox.ShowMessage("提示", "没有添加商品不能保存!");
                return;
            }
            if (EditMode == Ultra.Web.Core.Enums.EnViewEditMode.New) {
                var trdnew = new t_trade() {
                    Guid = GuidKey,
                    ReceiverName = Trade.ReceiverName,
                    ReceiverMobile = Trade.ReceiverMobile,
                    ReceiverAddress = Trade.ReceiverAddress,
                    MemberGuid = Trade.Guid,
                    DeliveryDate = dateDeliveryDate.DateTime,
                    CreateDate = TimeSync.Default.CurrentSyncTime,
                    Creator = this.CurUser,
                };

                using (var db = new Database()) {
                    try {
                        db.BeginTransaction();
                        db.Save(trdnew);
                        odrs.ForEach(k => db.Save(k));
                        db.CompleteTransaction();
                    } catch (Exception) {
                        db.AbortTransaction();
                        throw;
                    }
                }
            } else if (EditMode == Ultra.Web.Core.Enums.EnViewEditMode.Edit) {
                using (var db = new Database()) {
                    var trd = db.FirstOrDefault<t_trade>(" where guid=@0", GuidKey);
                    trd.ReceiverName = Trade.ReceiverName;
                    trd.ReceiverMobile = txtMobile.Text;
                    trd.ReceiverAddress = txtReceiverAddress.Text;
                    trd.MemberGuid = Trade.Guid;
                    trd.DeliveryDate = TimeSync.Default.CurrentSyncTime;
                    trd.DeliveryDate = dateDeliveryDate.DateTime;
                    try {
                        db.BeginTransaction();
                        db.Save(trd);
                        db.Execute("delete t_order where tradeguid=@0", trd.Guid);
                        odrs.ForEach(k => {
                            k.Id = 0;
                            db.Save(k);
                        });
                        db.CompleteTransaction();
                    } catch (Exception) {
                        db.AbortTransaction();
                        throw;
                    }
                }
            }
            DialogResult = System.Windows.Forms.DialogResult.OK;
            Close();
        }
Exemplo n.º 37
0
 public ContactRepository(IOptions <ConnectionConfig> options, AutoMapper.IMapper mapper)
 {
     _mapper   = mapper ?? throw new ArgumentNullException(nameof(mapper));
     ConnecStr = options.Value.ConnectionStr;
     Provider  = options.Value.Priovder;
     //Db = new PetaPoco.Database(ConnecStr, Provider, null);
     Db = new PetaPoco.Database("server = .;database = ContactInformation;uid = sa; pwd = 123", "System.Data.SqlClient", null);
 }
Exemplo n.º 38
0
 public List <Orders> GetOrders()
 {
     using (var db = new PetaPoco.Database("AdventureWorks2014"))
     {
         return(db.Query <Orders>(@"SELECT TOP 500 [WorkOrderID] AS Id, P.Name AS ProductName, [OrderQty] AS Quantity, [DueDate] AS Date
                                  FROM [AdventureWorks2014].[Production].[WorkOrder] AS WO 
                                  INNER JOIN[Production].[Product] AS P ON P.ProductID = WO.ProductID").ToList());
     }
 }
Exemplo n.º 39
0
        protected void Button4_Click(object sender, EventArgs e)
        {
            var db = new PetaPoco.Database("myConnectionString");

            string queryBooks = "SELECT * FROM Responses order by date_created desc";
            var    result     = db.Query <pixResponses>(queryBooks);
            //  GridView1.DataSource = result;
            // GridView1.DataBind();
        }
Exemplo n.º 40
0
        static void Main(string[] args)
        {
            var db = new PetaPoco.Database(connectionString: "server=.;database=orderdb;uid=sa;pwd=1;", providerName: "sqlservers");

            foreach (var order in db.Query <Orders>("select * from orders"))
            {
                Console.WriteLine(order);
            }
        }
Exemplo n.º 41
0
        public static List <PersonalProject> GetOrgProjects(string projectId, OrganizationType organizationType)
        {
            var db  = new PetaPoco.Database("DefaultConnection");
            var sql = new Sql(@"select op.*,o.OrganizationName,op.StudysiteNo, o.SubDomain  from sms_orgProject  op
            left join cts_organization o on op.organizationId=o.id
            where op.projectid=@0 and o.OrganizationType=@1 and isnull(op.isdeleted,0)<>1 and isnull(o.isdeleted,0)<>1", projectId, organizationType);

            return(db.Fetch <PersonalProject>(sql));
        }
Exemplo n.º 42
0
        /// <summary>
        /// Fetches the complete set of elements and returns this set as an IEnumerable.
        /// </summary>
        /// <returns>the set fetched</returns>
        public override IEnumerable <SalesOrderHeader> FetchSet()
        {
            var headers   = new List <SalesOrderHeader>();
            var dbFactory = new PetaPoco.Database(ConnectionStringToUse, "System.Data.SqlClient");

            dbFactory.OpenSharedConnection();
            headers = dbFactory.Fetch <SalesOrderHeader>(CommandText);
            dbFactory.CloseSharedConnection();
            return(headers);
        }
Exemplo n.º 43
0
    public string getAllMarkers()
    {
        using (var db = new PetaPoco.Database("linkSTEM"))
        {
            var SQL = Sql.Builder.Append("SELECT *")
                      .Append("FROM [dbo].[Markers]");

            return(JsonConvert.SerializeObject(db.Fetch <Marker>(SQL)));
        }
    }
Exemplo n.º 44
0
        /// <summary>
        /// 查询所有参与这个项目的项目信息--返回SQL字符串
        /// </summary>
        /// <param name="projectId"></param>
        /// <returns></returns>
        public static string GetOrgProjectsString(string projectId, OrganizationType organizationType)
        {
            var db  = new PetaPoco.Database("DefaultConnection");
            var sql = @"select op.Id  from sms_orgProject  op
            left join cts_organization o on op.organizationId=o.id
            where op.projectid='{0}' and o.OrganizationType={1} and isnull(op.isdeleted,0)<>1 and isnull(o.isdeleted,0)<>1";
            var sss = string.Format(sql, projectId, (int)organizationType);

            return(string.Format(sql, projectId, (int)organizationType));
        }
        private BSAMemberViewModel GetABSAMemberInternal(int iID)
        {
            //Connect to the Umbraco DB
            var db = new PetaPoco.Database(sConnectString);

            //Get an IENumberable of MeritBadges objects to iterate over
            var item = db.Single <BSAMember>(iID);

            return(FillViewModelBSAMember(item, true));
        }
Exemplo n.º 46
0
    public string getProvider(string username, string password)
    {
        using (var db = new PetaPoco.Database("linkSTEM"))
        {
            var SQL = Sql.Builder.Append("SELECT *")
                      .Append("FROM [dbo].[Providers]")
                      .Append("WHERE [provider_Username] = @0 AND [provider_Password] = @1", username, password);

            return(JsonConvert.SerializeObject(db.FirstOrDefault <Provider>(SQL)));
        }
    }
Exemplo n.º 47
0
        /// <summary>
        /// Fetches the individual element
        /// </summary>
        /// <param name="key">The key of the element to fetch.</param>
        /// <returns>The fetched element, or null if not found</returns>
        public override SalesOrderHeader FetchIndividual(int key)
        {
            SalesOrderHeader toReturn = null;

            var dbFactory = new PetaPoco.Database(ConnectionStringToUse, "System.Data.SqlClient");

            dbFactory.OpenSharedConnection();
            toReturn = dbFactory.First <SalesOrderHeader>(CommandText + " where SalesOrderId=@0", key);
            dbFactory.CloseSharedConnection();
            return(toReturn);
        }
Exemplo n.º 48
0
    public string getProviderMarkers(int providerID)
    {
        using (var db = new PetaPoco.Database("linkSTEM"))
        {
            var SQL = Sql.Builder.Append("SELECT *")
                      .Append("FROM [dbo].[Markers]")
                      .Append("WHERE [provider_ID] = @0", providerID);

            return(JsonConvert.SerializeObject(db.Fetch <Marker>(SQL)));
        }
    }
Exemplo n.º 49
0
 private void ShowSpeciesListView(PetaPoco.Database database)
 {
     View.SpeciesListView           speciesListView      = new View.SpeciesListView();
     ViewModel.SpeciesListViewModel speciesListViewModel = new ViewModel.SpeciesListViewModel(this);
     speciesListView.DataContext = speciesListViewModel;
     speciesListViewModel.Load();
     speciesListView.WindowStartupLocation = WindowStartupLocation.CenterOwner;
     speciesListView.Owner = this;
     speciesListView.ShowDialog();
     speciesListView._datagrid.Columns[0].Visibility = Visibility.Collapsed;
 }
Exemplo n.º 50
0
        public static void Xoa(string id, sanpham sp)
        {
            var db = new PetaPoco.Database("DienThoaiShopConnection");

            //db.Delete<sanpham>("where MaSanPham=@0", id);
            sp       = ChiTietSanPham(id);
            sp.BiXoa = 1;
            db.Update("sanpham", "MaSanPham", sp);
            //var a = new sanpham();
            //var db = new PetaPoco.Database("DienThoaiShopConnection");
            //db.Delete("sanpham", "MaSanPham", null, a);
        }
Exemplo n.º 51
0
        public ActionResult Index()
        {
            var db = new PetaPoco.Database("DefaultConnection");
            //var  sql1 = new Sql("CREATE TABLE #tb1(Id   varchar(50)     not null)");

            //db.Execute(sql1);

            var sql2 = new Sql(@"select op.*,o.OrganizationName,op.StudysiteNo, o.SubDomain  from sms_orgProject  op
            left join cts_organization o on op.organizationId=o.id
            where op.projectid =@0 and o.OrganizationType=@1 and isnull(op.isdeleted,0)<>1 and isnull(o.isdeleted,0)<>1", "593169721116912623", 2);
            var kk   = db.Fetch <PersonalProject>(sql2);
            var ssj  = db.LastArgs;
            var ks   = db.LastCommand;
            var s    = db.LastSQL;

            var k12 = GetOrgProjects("593079586929400170", OrganizationType.StudySite);
            var k2  = GetOrgProjectsString("593079586929400170", OrganizationType.StudySite);


            //(!input.isSiteDataCollection && input.SubjectVisitIds != null&& input.SubjectVisitIdsString == null ? " and #subjectVisit.Id in " + string.Format("('{0}')", string.Join("','", input.SubjectVisitIds)) : (!input.isSiteDataCollection && input.SubjectVisitIds != null ? " and #subjectVisit.Id in " + string.Format("({0})", string.Join("','", input.SubjectVisitIds)) : ""))
            //(!input.isSiteDataCollection && input.SubjectVisitIds != null ? " and #subjectVisit.Id in " + string.Format("('{0}')", string.Join("','", input.SubjectVisitIds)) : "")
            //    // Create the article
            //    var a = new test();

            //    a.name = "我的标题";
            //    a.type = 4;

            //    db.Insert("test", "id", a);



            //    var result = db.Page<test>(1, 2, // <-- page number and items per page
            //"SELECT * FROM test WHERE type=@0 ORDER BY id DESC", 3);



            //    var ssd = db.Query<test>("SELECT * FROM test");
            //    // 查询所有数据
            //    foreach (var aaa in db.Query<test>("SELECT * FROM test"))
            //    {
            //        //var ss = aa;
            //        Response.Write(aaa.name);
            //        //Console.WriteLine("{0} - {1}", a.article_id, a.title);
            //    }
            //    //查询标量
            //    long count = db.ExecuteScalar<long>("SELECT Count(*) FROM test");
            //    Response.Write(count);
            //    //查询单条数据
            //    var aa = db.SingleOrDefault<test>("SELECT * FROM test WHERE id=@0", 1);
            //    Response.Write(aa.name);
            return(View());
        }
        /// <summary>
        /// Fetches the complete set of elements and returns this set as an IEnumerable.
        /// </summary>
        /// <returns>the set fetched</returns>
        public override IEnumerable <SalesOrderHeader> FetchSet()
        {
            var headers   = new List <SalesOrderHeader>();
            var dbFactory = new PetaPoco.Database(ConnectionStringToUse, "System.Data.SqlClient");

            dbFactory.OpenSharedConnection();
            dbFactory.EnableAutoSelect    = false;
            dbFactory.EnableNamedParams   = false;
            dbFactory.ForceDateTimesToUtc = false;
            headers = dbFactory.Fetch <SalesOrderHeader>(CommandText);
            dbFactory.CloseSharedConnection();
            return(headers);
        }
        /// <summary>
        /// Fetches the individual element
        /// </summary>
        /// <param name="key">The key of the element to fetch.</param>
        /// <returns>The fetched element, or null if not found</returns>
        public override SalesOrderHeader FetchIndividual(int key)
        {
            SalesOrderHeader toReturn = null;
            var dbFactory             = new PetaPoco.Database(ConnectionStringToUse, "System.Data.SqlClient");

            dbFactory.OpenSharedConnection();
            dbFactory.EnableAutoSelect    = false;
            dbFactory.EnableNamedParams   = false;
            dbFactory.ForceDateTimesToUtc = false;
            toReturn = dbFactory.First <SalesOrderHeader>(CommandText + " where SalesOrderId=@0 ", key);
            dbFactory.CloseSharedConnection();
            return(toReturn);
        }
Exemplo n.º 54
0
        public IList <Contato> PesquisaAll(string query)
        {
            Database db = new PetaPoco.Database("PRWDEV");

            if (query == null)
            {
                return(db.Fetch <Contato>("Select * FROM contatosbandre"));
            }
            else
            {
                return(db.Fetch <Contato>("Select * FROM contatosbandre WHERE nome like '%' + @query + '%' or cpf like '%' + @query + '%' or estadoid = @query", new { query }));
            }
        }
Exemplo n.º 55
0
        public List <User> GetUsers()
        {
            // TODO: Need to make it generic
            var dbConnectionString = appSettings.Value.DefaultConnection;
            NpgsqlConnection conn  = new NpgsqlConnection(dbConnectionString.ToString());

            conn.Open();
            PetaPoco.Database db = new PetaPoco.Database(conn);

            List <User> userslst = db.Query <User>(strGetUsersQuery).ToList();

            conn.Close();
            return(userslst);
        }
Exemplo n.º 56
0
 private static void ExecuteSQL(string sql, PetaPoco.Database db = null)
 {
     if (db == null)
     {
         using (db = new Database(Environments.Current.Connection, "System.Data.SqlClient"))
         {
             db.Execute(sql);
         }
     }
     else
     {
         db.Execute(sql);
     }
 }
Exemplo n.º 57
0
        public List <Orders> GetOrders(int iteration)
        {
            var listOrders = new List <Orders>();

            using (var db = new PetaPoco.Database("AdventureWorks2014"))
            {
                for (int i = 1; i <= iteration; i++)
                {
                    listOrders.Add(GetOrder(db, i));
                }
            }

            return(listOrders);
        }
Exemplo n.º 58
0
        /// <summary>
        /// 获取员工信息集合(简要信息)
        /// 区别:这是简要的员工信息,用来做任务分配
        /// </summary>
        /// <param name="LoginGuid">登入者GUID</param>
        /// <returns></returns>
        public List <MEmployee> GetEmployeeList(string LoginGuid)
        {
            List <MEmployee> employees;

            using (SqlConnection sqlConnection = new SqlConnection(SystemSqlConn))
            {
                sqlConnection.Open();
                using (Database db = new PetaPoco.Database(sqlConnection))
                {
                    employees = db.Fetch <MEmployee>(@"SELECT EmployeeGuid,EmployeeCode,EmployeeNickName,EmployeeSex,EmployeeTel,TelOperator FROM Tb_Employee WHERE BelongToUser = @0 AND EmployeeIsLocked = 0", LoginGuid);
                }
                return(employees);
            }
        }
Exemplo n.º 59
0
 public bool addProvider(Provider provider)
 {
     try
     {
         using (var db = new PetaPoco.Database("linkSTEM"))
         {
             db.Insert("Providers", "provider_ID", provider);
             return(true);
         }
     }
     catch (Exception)
     {
         return(false);
     }
 }
Exemplo n.º 60
0
        public IHttpActionResult GetStory(string id)
        {
            var db = new PetaPoco.Database("AGSoftware");

            Entities.Storytime storytime = db.SingleOrDefault <Entities.Storytime>("Select * From StoryTime Where StorytimeId = @0", id);

            if (storytime != null)
            {
                return(Ok(storytime));
            }
            else
            {
                return(NotFound());
            }
        }