Example #1
0
 public string SelectSingle(string id)
 {
     try
     {
         using (var db = SugarDao.GetInstance())
         {
             int     i      = int.Parse(id);
             Student single = db.Queryable <Student>().Single(x => x.id == i);
             if (single != null)
             {
                 string msg = string.Format("ID号:{0},名字:{1},学校号:{2}", single.id, single.name, single.sch_id);
                 return(retMsg("查询单条数据", msg));
             }
             else
             {
                 return(retMsg("查询单条数据", "没报错--没找到对应数据"));
             }
         }
     }
     catch (Exception e)
     {
         Console.WriteLine(e);
         return(retMsg("查询单条数据", "后台报错--没找到对应数据"));
     }
 }
Example #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            using (SqlSugarClient db = SugarDao.GetInstance())
            {
                //-----单个-------//
                var list = db.Queryable <V_Student>("Student").ToList();//查询的是 select * from student 而我的实体名称为V_Student



                //-----全局多个设置-------//

                //设置 Mapping Table 如果没这方面需求可以传NULL
                List <KeyValue> mappingTableList = new List <KeyValue>()
                {
                    new KeyValue()
                    {
                        Key = "FormAttr", Value = "Flow_FormAttr"
                    },
                    new KeyValue()
                    {
                        Key = "Student3", Value = "Student"
                    }
                };
                db.SetMappingTables(mappingTableList);
            }
        }
Example #3
0
        private void MedicineDetail_Load(object sender, EventArgs e)
        {
            InitLookUpEdit(lue_ssjyfw, 2);   //所属经营范围
            InitLookUpEdit(lue_unit, 4);     //药品单位
            InitLookUpEdit(lue_type, 5);     //药剂分类
            InitLookUpEdit(lue_jgfl, 6);     //监管分类
            InitLookUpEdit(lue_gys, 7);      //供应商
            InitLookUpEdit(lue_sccj, 8);     //生产厂家

            if (detailId > 0)
            {
                using (var db = SugarDao.GetInstance())
                {
                    var entity = db.Queryable <Domain.Model.Medicine>().Single(t => t.Id == detailId);
                    if (entity != null && entity.Id > 0)
                    {
                        txt_name.Text              = entity.Name;
                        txt_commonName.Text        = entity.CommonName;
                        lue_ssjyfw.EditValue       = entity.JYFWId;
                        txt_bzgg.Text              = entity.BZGG;
                        lue_unit.EditValue         = entity.UnitId;
                        lue_type.EditValue         = entity.TypeId;
                        lue_jgfl.EditValue         = entity.JGFLId;
                        lue_gys.EditValue          = entity.SupplierId;
                        lue_sccj.EditValue         = entity.SCCJId;
                        txt_cpzc.Text              = entity.CPZC;
                        date_pzwh.Text             = entity.PZWH;
                        ckb_isPrescription.Checked = entity.IsPrescription;
                    }
                }
            }
        }
        /// <summary>
        ///  获取信息
        /// </summary>
        /// <param name="pageIndex"></param>
        /// <param name="pageSize"></param>
        /// <param name="count"></param>
        /// <param name="wh_id"></param>
        /// <param name="locat_code"></param>
        /// <returns></returns>
        public List <StorageBinModel> GetStorageBinList(int pagenum, int onepagecount, out int totil, out int totilpage, out string exmsg, long?wh_id, string locat_code)
        {
            using (var db = SugarDao.GetInstance(LoginUser.GetConstr()))
            {
                try
                {
                    var sql1 = db.Queryable <base_location>()
                               .JoinTable <base_wh_warehouse>((s1, s2) => s1.wh_id == s2.wh_id)
                               .Where("s1.del_flag=1 and s2.del_flag=1")
                               .OrderBy("s1.locat_id DESC");
                    if (!string.IsNullOrWhiteSpace(locat_code))
                    {
                        sql1 = sql1.Where(s1 => s1.locat_code.Contains(locat_code));
                    }
                    if (wh_id > 0)
                    {
                        sql1 = sql1.Where(s1 => s1.wh_id == wh_id);
                    }
                    totil = sql1.Count();
                    var jList = sql1.Skip(onepagecount * (pagenum - 1)).Take(onepagecount)
                                .Select <StorageBinModel>("s1.locat_id,s1.wh_id,s1.locat_code,s1.create_time,s2.wh_name")
                                .ToList();
                    if (jList.Count > 0)
                    {
                        foreach (var item in jList)
                        {
                            var sql = db.Queryable <base_wh_stock>()
                                      .Where(" del_flag=1 and location_id=" + item.locat_id + " and wh_id=" + item.wh_id + "")
                                      .GroupBy("location_id,wh_id")
                                      .Select <StorageBinModel>("location_id,wh_id, SUM(stock_qty) AS stock_qty")
                                      .SingleOrDefault();
                            if (sql != null)
                            {
                                item.stock_qty = sql.stock_qty;
                            }
                            else
                            {
                                item.stock_qty = 0;
                            }
                            item.create_timeE = item.create_time.ToString("yyyy-MM-dd");
                        }
                    }

                    totilpage = totil / onepagecount;
                    exmsg     = "";
                    if (totil % onepagecount > 0)
                    {
                        totilpage++;
                    }
                    return(jList.ToList());
                }
                catch (Exception ex)
                {
                    exmsg     = ex.ToString();
                    totil     = 0;
                    totilpage = 0;
                    return(null);
                }
            }
        }
Example #5
0
        /// <summary>
        /// 基于原生Sql的查询
        /// </summary>
        private void SqlQuery()
        {
            using (var db = SugarDao.GetInstance())
            {
                //转成list
                List <Student> list1 = db.SqlQuery <Student>("select * from Student");
                //转成list带参
                List <Student> list2 = db.SqlQuery <Student>("select * from Student where id=@id", new { id = 1 });
                //转成dynamic
                dynamic list3 = db.SqlQueryDynamic("select * from student");
                //转成json
                string list4 = db.SqlQueryJson("select * from student");
                //返回int
                var list5 = db.SqlQuery <int>("select top 1 id from Student").SingleOrDefault();
                //反回键值
                Dictionary <string, string> list6 = db.SqlQuery <KeyValuePair <string, string> >("select id,name from Student").ToDictionary(it => it.Key, it => it.Value);
                //反回List<string[]>
                var list7 = db.SqlQuery <string[]>("select top 1 id,name from Student").SingleOrDefault();
                //存储过程
                var spResult = db.SqlQuery <School>("exec sp_school @p1,@p2", new { p1 = 1, p2 = 2 });

                //获取第一行第一列的值
                string  v1 = db.GetString("select '张三' as name");
                int     v2 = db.GetInt("select 1 as name");
                double  v3 = db.GetDouble("select 1 as name");
                decimal v4 = db.GetDecimal("select 1 as name");
                //....
            }
        }
Example #6
0
        /// <summary>
        /// 根据类型获取订单列表
        /// </summary>
        /// <param name="type">1入库 2出库</param>
        /// <param name="strWhere">查询sql</param>
        /// <param name="orderCount">列表总数</param>
        /// <returns></returns>
        public List <OrderListDto> GetOrderListByType(int type, string strWhere, int pageIndex, int pageSize, out int orderCount)
        {
            var list = new List <OrderListDto>();

            try
            {
                using (var db = SugarDao.GetInstance())
                {
                    list = db.Queryable <Domain.Model.Order>()
                           .JoinTable <BasicDictionary>((o, gys) => o.SupplierId == gys.Id)
                           .JoinTable <Sys_User>((o, u) => o.CreateUserId == u.Account)
                           .Where($" Status>=0 and  Type={type} {strWhere}")
                           .Select <OrderListDto>("o.Id,o.OrderNum,o.SupplierId,gys.Name SupplierName,u.Name CreateUserName,o.CreateTime,o.Status")
                           .OrderBy(o => o.Status, OrderByType.Asc)
                           .OrderBy(o => o.Id, OrderByType.Desc)
                           .ToPageList(pageIndex, pageSize);

                    orderCount = db.Queryable <Domain.Model.Order>()
                                 .JoinTable <BasicDictionary>((o, gys) => o.SupplierId == gys.Id)
                                 .JoinTable <Sys_User>((o, u) => o.CreateUserId == u.Account)
                                 .Where($" Status>=0 and Type={type} {strWhere}").Count();
                }

                return(list);
            }
            catch (Exception)
            {
                throw;
            }

            return(list);
        }
Example #7
0
        private void SetExtraMoney_Load(object sender, EventArgs e)
        {
            textBox_msg.Text = "请选择附加费用类型";
            textBox_money.Focus();

            using (var db = SugarDao.GetInstance())
            {
                var model = db.Queryable <JobExtra>().FirstOrDefault();
                if (model == null)
                {
                    return;
                }
                _gluing = model.ExtraGluing;
                SetBtnStyle(button_gluing, _gluing);
                _typesetting = model.ExtraTypesetting;
                SetBtnStyle(button_typesetting, _typesetting);
                _copy = model.ExtraCopy;
                SetBtnStyle(button_copy, _copy);
                _scan = model.ExtraScan;
                SetBtnStyle(button_scan, _scan);
                _other = model.ExtraOther;
                SetBtnStyle(button_other, _other);
                textBox_money.Text = model.ExtraPrice > 0?model.ExtraPrice.ToString(CultureInfo.InvariantCulture):"";
            }
        }
Example #8
0
        public void Init()
        {
            Console.WriteLine("启动SqlPageModel.Init");
            using (var db = SugarDao.GetInstance())
            {
                try
                {
                    db.PageModel = PageModel.Offset;  //启用Sql2012的方式进行分页(默认:RowNumber)

                    var list  = db.Queryable <Student>().OrderBy("id").Skip(0).Take(2).ToList();
                    var list1 = db.Sqlable().From <Student>("t").SelectToPageList <Student>("*", "id", 1, 2);


                    List <School> dataPageList = db.Sqlable()
                                                 .From("school", "s")
                                                 .Join("student", "st", "st.id", "s.id", JoinType.Inner)
                                                 .Join("student", "st2", "st2.id", "st.id", JoinType.Left)
                                                 .Where("s.id>100 and s.id<100")
                                                 .SelectToPageList <School>("st.*", "s.id", 1, 10);

                    db.PageModel = PageModel.RowNumber;
                    var list2  = db.Queryable <Student>().OrderBy("id").Skip(0).Take(2).ToList();
                    var list22 = db.Sqlable().From <Student>("t").SelectToPageList <Student>("*", "id", 1, 2);
                }
                catch (Exception ex)
                {
                    throw new Exception("该Demo要求SqlSever版本为2012及以上版本,错误信息:" + ex.Message);
                }
            }
        }
Example #9
0
 protected void btnCreateClassCode_Click(object sender, EventArgs e)
 {
     using (var db = SugarDao.GetInstance())
     {
         txtResult.Value = db.ClassGenerating.SqlToClass(db, txtSql.Text, txtClassName.Text);
     }
 }
Example #10
0
 public string SelectSinglePk(string num)
 {
     try
     {
         using (var db = SugarDao.GetInstance())
         {
             int     i          = int.Parse(num);
             Student singleByPk = db.Queryable <Student>().InSingle(i);
             if (singleByPk != null)
             {
                 string msg = string.Format("ID号:{0},名字:{1},学校号:{2}", singleByPk.id, singleByPk.name, singleByPk.sch_id);
                 return(retMsg("查询单条根据主键", msg));
             }
             else
             {
                 return(retMsg("查询单条根据主键", "没报错--没找到对应数据"));
             }
         }
     }
     catch (Exception e)
     {
         Console.WriteLine(e);
         return(retMsg("查询单条根据主键", "报错--没找到对应数据"));
     }
 }
Example #11
0
 public string Single2(string num)
 {
     try
     {
         using (var db = SugarDao.GetInstance())
         {
             int     i          = int.Parse(num);
             Student singleByPk = db.Queryable <Student>().Where(c => c.id == i).SingleOrDefault();
             if (singleByPk != null)
             {
                 string msg = string.Format("ID号:{0},名字:{1},学校号:{2}", singleByPk.id, singleByPk.name, singleByPk.sch_id);
                 return(retMsg("查询单条没有记录返回空对象2", msg));
             }
             else
             {
                 return(retMsg("查询单条没有记录返回空对象2", "没报错--返回空对象"));
             }
         }
     }
     catch (Exception e)
     {
         Console.WriteLine(e);
         return(retMsg("查询单条没有记录返回空对象2", "报错--没找到对应数据"));
     }
 }
Example #12
0
 public string InSelect(string textBox5Text)
 {
     try
     {
         using (var db = SugarDao.GetInstance())
         {
             var    intArray = new[] { "4", "2", "3" };
             var    intList  = intArray.ToList();
             var    listNew  = db.Queryable <Student>().Where(x => intArray.Contains(x.name)).ToJson();
             var    list0    = db.Queryable <Student>().In(it => it.id, 1, 2, 3).ToJson();
             var    list1    = db.Queryable <Student>().In(it => it.id, intArray).ToJson();
             var    list2    = db.Queryable <Student>().In("id", intArray).ToJson();
             var    list3    = db.Queryable <Student>().In(it => it.id, intList).ToJson();
             var    list4    = db.Queryable <Student>().In("id", intList).ToJson();
             var    list6    = db.Queryable <Student>().In(intList).ToJson();//不设置字段默认主键
             string msg      = string.Format("\nlistNew :\r\n{0}\n list0\r\n{1} \nlist1\r\n{2}\nlist2\r\n{3}\nlist3\r\n{4}\nlist4\r\n{5}\nlist6\r\n{6}", listNew, list0, list1, list2, list3, list4, list6);
             return(retMsg("in操作", msg));
         }
     }
     catch (Exception e)
     {
         Console.WriteLine(e);
         return(retMsg("in操作", "报错了!!!!"));
     }
 }
Example #13
0
 public string SoftData(string textBox4Text)
 {
     try
     {
         using (var db = SugarDao.GetInstance())
         {
             string msg       = "";
             var    orderList = db.Queryable <Student>().OrderBy(textBox4Text).ToList();                                       //字符串支持多个排序
                                                                                                                               //可以多个order by表达示
             var order2List = db.Queryable <Student>().OrderBy(it => it.name).OrderBy(it => it.id, OrderByType.Desc).ToList(); // order by name as ,order by id desc
             foreach (Student student in orderList)
             {
                 msg += string.Format("  ID号:{0},名字:{1},学校号:{2} \r\n", student.id, student.name, student.sch_id);
             }
             string msg2 = "";
             foreach (Student student in order2List)
             {
                 msg2 += string.Format("  ID号:{0},名字:{1},学校号:{2} \r\n", student.id, student.name, student.sch_id);
             }
             return(retMsg("排序", "正序" + msg + "\r\n" + "倒序" + msg2));
         }
     }
     catch (Exception e)
     {
         Console.WriteLine(e);
         return(retMsg("排序", "报错了!!!!"));
     }
 }
Example #14
0
 public string LikeAnUnlike(string text)
 {
     try
     {
         using (var db = SugarDao.GetInstance())
         {
             string         msg     = "";
             List <Student> notLike = db.Queryable <Student>().Where(c => !c.name.Contains(text)).ToList();
             foreach (Student student in notLike)
             {
                 msg += string.Format("  ID号:{0},名字:{1},学校号:{2} \r\n", student.id, student.name, student.sch_id);
             }
             string         msg2 = "";
             List <Student> like = db.Queryable <Student>().Where(c => c.name.Contains(text)).ToList();
             foreach (Student student in like)
             {
                 msg2 += string.Format("  ID号:{0},名字:{1},学校号:{2} \r\n", student.id, student.name, student.sch_id);
             }
             return(retMsg("Not like", msg) + "\r\n" + retMsg("Like", msg2));
         }
     }
     catch (Exception e)
     {
         Console.WriteLine(e);
         return(retMsg("取前X条", "报错了!!!!"));
     }
 }
Example #15
0
 /// <summary>
 /// 获取用户列表
 /// </summary>
 /// <param name="total">结果总条数</param>
 /// <param name="take">每页条数</param>
 /// <param name="skip">页数</param>
 /// <param name="searchParams">查询条件</param>
 /// <returns>用户列表</returns>
 public IEnumerable <IEntityBase> GetList(ref int total, int take, int skip, Dictionary <string, string> searchParams)
 {
     using (var db = SugarDao.GetInstance())
     {
         return(null);
     }
 }
Example #16
0
 /// <summary>
 /// 判断扫描的包裹号在系统中是否存在且未删除
 /// </summary>
 /// <param name="packgecode"></param>
 /// <returns></returns>
 public static int CheckPackge(string packgecode)
 {
     using (var db = SugarDao.GetInstance(Getconnstring.Getmyconnstring()))
     {
         try
         {
             busi_sendorder packge = db.Queryable <busi_sendorder>().Where(s => s.order_code == packgecode).FirstOrDefault();
             if (null == packge)
             {
                 return(1);//代表包裹不存在系统中
             }
             else
             {
                 busi_sendorder packge2 = db.Queryable <busi_sendorder>().Where(s => s.order_code == packgecode).Where(s => s.del_flag == true).FirstOrDefault();
                 if (null == packge2)
                 {
                     return(2); //代表包裹被删除
                 }
                 else
                 {
                     return(3); //包裹存在,正常
                 }
             }
         }
         catch (Exception ex)
         {
             throw ex;
         }
     }
 }
Example #17
0
        /// <summary>
        /// 使用用户名获取用户
        /// </summary>
        /// <param name="userId">用户名</param>
        /// <param name="accId">账套Id</param>
        /// <returns>用户</returns>
        public M_User GetUserById(string userId, string accId)
        {
            try
            {
                var db = SugarDao.GetInstance();

                var id = new Guid(accId);

                var queryable = db.Queryable <M_User, M_UserAcc>((s1, s2) => new object[]
                {
                    JoinType.Inner, s1.UserName == s2.UserId
                });

                queryable = queryable.Where((s1, s2) =>
                                            s1.UserName == userId && s2.AccId == id && s1.DelFlg != false && s2.DelFlg != false);

                var result = queryable.SingleAsync();

                result.Wait();

                return(result.Result);
            }
            catch (Exception ex)
            {
                LogHelper.Error(ex);
                return(null);
            }
        }
Example #18
0
        public static List <PackgePrintInfo> GetPckgePrintInfo(string packgecode)
        {
            using (var db = SugarDao.GetInstance(Getconnstring.Getmyconnstring()))
            {
                try
                {
                    List <PackgePrintInfo> packinfo = db.Queryable <busi_sendorder_detail>().JoinTable <busi_sendorder>((s1, s2) => s1.order_id == s2.order_id)
                                                      .JoinTable <base_prod_code>((s1, s3) => s1.code_id == s3.code_id)
                                                      .Where <busi_sendorder>((s1, s2) => s2.order_code == packgecode)
                                                      .Select <busi_sendorder, base_prod_code, PackgePrintInfo>((s1, s2, s3) =>
                                                                                                                new PackgePrintInfo()
                    {
                        expressid = s2.express_id,
                        ExpCode   = s2.exp_code,
                        zipcode   = s2.receive_zip,
                        mobile    = s2.receive_mobile,
                        phone     = s2.receive_phone,
                        address   = s2.receive_address,
                        name      = s2.receive_name,
                        count     = s2.prod_num,
                        skucode   = s3.sku_code,
                        skunum    = s1.prod_num.ObjToInt()
                    }).ToList();

                    return(packinfo);
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
        }
Example #19
0
 private void button_no_Click(object sender, EventArgs e)
 {
     _gluing = false;
     SetBtnStyle(button_gluing, _gluing);
     _typesetting = false;
     SetBtnStyle(button_typesetting, _typesetting);
     _copy = false;
     SetBtnStyle(button_copy, _copy);
     _scan = false;
     SetBtnStyle(button_scan, _scan);
     _other = false;
     SetBtnStyle(button_other, _other);
     textBox_money.Text = "";
     using (var db = SugarDao.GetInstance())
     {
         var model = db.Queryable <JobExtra>().FirstOrDefault();
         if (model == null)
         {
             return;
         }
         db.Update <JobExtra>(new
         {
             ExtraGluing      = false,
             ExtraTypesetting = false,
             ExtraCopy        = false,
             ExtraScan        = false,
             ExtraOther       = false,
             ExtraPrice       = 0
         }, it => it.Id == model.Id);
     }
 }
        /// <summary>
        /// 更新信息
        /// </summary>
        /// <param name="purch_id"></param>
        /// <param name="express_id"></param>
        /// <param name="express_code"></param>
        /// <param name="express_name"></param>
        /// <param name="OrderCode"></param>
        /// <returns></returns>
        public MaterialReceiptResult Modify(Int64?purch_id, Int64?express_id, string express_code, string express_name, string OrderCode)
        {
            bool rstNum = false;
            MaterialReceiptResult result = new MaterialReceiptResult();

            using (var db = SugarDao.GetInstance(LoginUser.GetConstr()))
            {
                db.BeginTran();
                var list = db.Queryable <busi_purchase>().Where(s => s.del_flag).InSingle(purch_id.Value);
                if (list == null)
                {
                    db.RollbackTran();
                    result.success = false;
                    result.Msg     = "无效的采购信息,操作失败!";
                    return(result);
                }

                rstNum = db.Update <busi_purchase>(new { purch_status = 3, express_id = express_id, express_code = express_code, express_name = express_name, OrderCode = OrderCode }, a => a.purch_id == purch_id && a.purch_status == 3);

                if (rstNum)
                {
                    db.CommitTran();
                    result.success = true;
                    result.Msg     = "操作成功";
                    return(result);
                }
                else
                {
                    db.RollbackTran();
                    result.success = false;
                    result.Msg     = "操作失败";
                    return(result);
                }
            }
        }
Example #21
0
        /// <summary>
        /// 获取库存详情
        /// </summary>
        /// <param name="pageIndex"></param>
        /// <param name="pageSize"></param>
        /// <param name="count"></param>
        /// <param name="locat_id"></param>
        /// <returns></returns>
        public List <StorageBinModel> GetStorageBinEList(out string exmsg, long?wh_id, long?locat_id)
        {
            using (var db = SugarDao.GetInstance(LoginUser.GetConstr()))
            {
                if (wh_id == 0 || locat_id == 0)
                {
                    exmsg = "参数错误!";
                    return(null);
                }

                try
                {
                    var sql = db.Queryable <base_wh_stock>()
                              .JoinTable <base_wh_warehouse>((s1, s2) => s1.wh_id == s2.wh_id)
                              .JoinTable <base_product>((s1, s3) => s3.prod_id == s1.prod_id)
                              .JoinTable <base_location>((s1, s5) => s1.location_id == s5.locat_id)
                              .JoinTable <base_prod_code>((s1, s6) => s6.code_id == s1.code_id)
                              .Where("s1.del_flag=1 and s2.del_flag=1 and s3.del_flag=1 and s5.del_flag=1 and s6.del_flag=1 and s1.wh_id=" + wh_id + " and s1.location_id=" + locat_id + "")
                              .GroupBy(" s1.code_id, s1.wh_id, s1.location_id, s6.sku_code, s1.stock_qty, s2.wh_name, s3.prod_title, s5.locat_code")
                              .Select <StorageBinModel>(" s6.sku_code, s1.stock_qty, s2.wh_name, s3.prod_title, s5.locat_code").ToList();
                    exmsg = "";
                    return(sql.ToList());
                }
                catch (Exception ex)
                {
                    exmsg = ex.ToString();
                    return(null);
                }
            }
        }
Example #22
0
        public void OldMethod()
        {
            //请在页面加上参数id=1

            using (SqlSugarClient db = SugarDao.GetInstance())    //开启数据库连接
            {
                db.IsGetPageParas = true;                         //使用无参模式直接将Requst中的ID传给@id无需在代码中写出来
                var kvs  = SqlSugarTool.GetParameterDictionary(); //获取QqueryString和Form参数集合
                var list = db.Queryable <Student>();

                if (!string.IsNullOrEmpty(Request["id"]))
                {
                    list = list.Where(it => it.id == Convert.ToInt32(kvs["name"]));
                }
                //if (!string.IsNullOrEmpty(Request["id"]))
                //{
                //    list = list.Where(it => it.Sex == Convert.ToInt32(kvs["Sex"]));
                //}
                //if (!string.IsNullOrEmpty(Request["id"]))
                //{
                //    list = list.Where(it => it.xxx == Convert.ToInt32(kvs["xxx"]));
                //}
                //if (!string.IsNullOrEmpty(Request["id"]))
                //{
                //    list = list = list.Where(it => it.xxxx == Convert.ToInt32(kvs["xxxxx"]));
                //}

                //获取页面所有参数到键值对
                //var kvs= SqlSugarTool.GetParameterDictionary();
            }
        }
Example #23
0
        /// <summary>
        /// 获取商品信息
        /// </summary>
        /// <returns></returns>
        public ShopResult GetShopList()
        {
            ShopResult result = new ShopResult();

            using (var db = SugarDao.GetInstance(LoginUser.GetConstr()))
            {
                try
                {
                    var list = db.Queryable <base_shop>().Where(a => a.del_flag).OrderBy("shop_id DESC").ToList();
                    if (list.Count <= 0)
                    {
                        result.success = false;
                        result.Msg     = "暂无店铺信息!";
                        return(result);
                    }
                    var list1 = "<option value=\"0\">请选择...</option>";
                    foreach (var item in list)
                    {
                        list1 += "<option value=\"" + item.shop_id + "\">" + item.shop_name + "</option>";
                    }

                    result.success = true;
                    result.Msg     = list1;
                    return(result);
                }
                catch (Exception ex)
                {
                    result.success = false;
                    result.Msg     = "获取店铺信息失败!";
                    return(result);
                }
            }
        }
Example #24
0
        /// <summary>
        /// 打印插件信息
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void label5_DoubleClick(object sender, EventArgs e)
        {
            NewXmlControl xmlfile2 = new NewXmlControl(Comm.StartupPath + "//config//regedit.xml", false, "Passport");
            string        ID       = xmlfile2.ReadNodeInnerText("/Passport/ID[1]");

            using (var db = SugarDao.GetInstance(Getconnstring.Getmyconnstring()))
            {
                try
                {
                    //获取配置的插件信息
                    var obj = db.Queryable <base_print>().Where(s => s.p_id == Convert.ToInt32(ID)).FirstOrDefault();
                    if (null == obj)
                    {
                        MessageBox.Show("此打印插件在系统中不存在");
                        return;
                    }
                    else
                    {
                        MessageBox.Show("打印插件名称:" + obj.p_name, "提示");
                        return;
                    }
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
        }
Example #25
0
        public void Init()
        {
            Console.WriteLine("启动Inset.Init");
            using (var db = SugarDao.GetInstance())
            {
                db.Insert(GetInsertItem()); //插入一条记录 (有主键也好,没主键也好,有自增列也好都可以插进去)


                db.InsertRange(GetInsertList()); //批量插入 支持(别名表等功能)


                db.SqlBulkCopy(GetInsertList()); //批量插入 适合海量数据插入



                //设置不插入列
                db.DisableInsertColumns = new string[] { "sex" };//sex列将不会插入值
                Student s = new Student()
                {
                    name = "张" + new Random().Next(1, int.MaxValue),
                    sex  = "gril"
                };

                var id = db.Insert(s); //插入

                //查询刚插入的sex是否有值
                var sex  = db.Queryable <Student>().Single(it => it.id == id.ObjToInt()).sex;  //无值
                var name = db.Queryable <Student>().Single(it => it.id == id.ObjToInt()).name; //有值


                //SqlBulkCopy同样支持不挺入列设置
                db.SqlBulkCopy(GetInsertList());
            }
        }
Example #26
0
        /// <summary>
        /// 设置打印插件在线状态
        /// </summary>
        /// <returns></returns>
        private int online(int on) //on=0,离线,on=1,在线
        {
            NewXmlControl xmlfile2 = new NewXmlControl(Comm.StartupPath + "//config//regedit.xml", false, "Passport");
            string        ID       = xmlfile2.ReadNodeInnerText("/Passport/ID[1]");
            int           p_id     = Convert.ToInt32(ID);

            using (var db = SugarDao.GetInstance(Getconnstring.Getmyconnstring()))
            {
                try
                {
                    //获取配置的插件信息
                    var obj = db.Queryable <base_print>().Where(s => s.del_flag == 0).Where(s => s.p_id == p_id).FirstOrDefault();
                    if (null == obj)
                    {
                        return(0); //"打印插件未在系统中注册或者被删除了!";
                    }
                    else
                    {
                        var isok = db.Update <base_print>(new { isonline = on }, s => s.p_id == p_id);
                        if (isok)
                        {
                            return(1);//"启动成功";
                        }
                        else
                        {
                            return(2);//"启动失败";
                        }
                    }
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
        }
Example #27
0
        private void btn_save_Click(object sender, EventArgs e)
        {
            try
            {
                if (string.IsNullOrWhiteSpace(txt_name.Text.Trim()))
                {
                    XtraMessageBox.Show("请您输入药品名称!");
                    return;
                }

                var entity = new Domain.Model.Medicine()
                {
                    Id             = detailId,
                    Name           = txt_name.Text.Trim(),
                    NameCode       = Pinyin.GetInitials(Pinyin.ConvertEncoding(txt_name.Text.Trim(), Encoding.UTF8, Encoding.GetEncoding("GB2312")), Encoding.GetEncoding("GB2312"))?.ToLower(),
                    CommonName     = txt_commonName.Text.Trim(),
                    CommonNameCode = string.IsNullOrWhiteSpace(txt_commonName.Text.Trim()) ? "" : Pinyin.GetInitials(Pinyin.ConvertEncoding(txt_commonName.Text.Trim(), Encoding.UTF8, Encoding.GetEncoding("GB2312")), Encoding.GetEncoding("GB2312"))?.ToLower(),
                    JYFWId         = lue_ssjyfw.EditValue == null ? 0 : int.Parse(lue_ssjyfw.EditValue.ToString()),
                    BZGG           = txt_bzgg.Text.Trim(),
                    UnitId         = lue_unit.EditValue == null ? 0 : int.Parse(lue_unit.EditValue.ToString()),
                    TypeId         = lue_type.EditValue == null ? 0 : int.Parse(lue_type.EditValue.ToString()),
                    JGFLId         = lue_jgfl.EditValue == null ? 0 : int.Parse(lue_jgfl.EditValue.ToString()),
                    SupplierId     = lue_gys.EditValue == null ? 0 : int.Parse(lue_gys.EditValue.ToString()),
                    SCCJId         = lue_sccj.EditValue == null ? 0 : int.Parse(lue_sccj.EditValue.ToString()),
                    CPZC           = txt_cpzc.Text.Trim(),
                    PZWH           = date_pzwh.Text.Trim(),
                    IsPrescription = ckb_isPrescription.Checked,
                    Status         = 1,
                };

                using (var db = SugarDao.GetInstance())
                {
                    if (Convert.ToBoolean(db.InsertOrUpdate(entity)))
                    {
                        string msg = detailId > 0 ? $"【修改成功】 " : $"【新增成功】";

                        Log.Info(new LoggerInfo()
                        {
                            LogType      = LogType.药品信息.ToString(),
                            CreateUserId = UserInfo.Account,
                            Message      = msg + $"药品Id:{entity.Id},药品名称:{entity.Name},药品简写:{entity.NameCode},药品通用名称:{entity.CommonName}" +
                                           $",药品通用名称简写:{entity.CommonNameCode},经营范围:{lue_ssjyfw.Text},药品规格:{txt_bzgg.Text},药品单位:{lue_unit.Text}" +
                                           $",药剂分类:{lue_type.Text},监管分类:{lue_jgfl.Text},供应商:{lue_gys.Text},生产厂家:{lue_sccj.Text},产品注册证批件号:{txt_cpzc.Text.Trim()}" +
                                           $",批准文号有效期:{ date_pzwh.Text.Trim()},是否处方药:{(entity.IsPrescription ? "是" : "否")}"
                        });

                        DialogResult = DialogResult.OK;
                        this.Close();
                    }
                    else
                    {
                        DialogResult = DialogResult.Cancel;
                    }
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
Example #28
0
        public void Init()
        {
            Console.WriteLine("启动Deletes.Init");
            using (var db = SugarDao.GetInstance())
            {
                //删除根据主键
                db.Delete <School, int>(10);

                //删除根据表达示
                db.Delete <School>(it => it.id > 100);//支持it=>array.contains(it.id)

                //主键批量删除
                db.Delete <School, string>(new string[] { "100", "101", "102" });

                //非主键批量删除
                db.Delete <School, string>(it => it.name, new string[] { "" });
                db.Delete <School, int>(it => it.id, new int[] { 20, 22 });


                //根据实体赋值实体一定要有主键,并且要有值。
                db.Delete(new School()
                {
                    id = 200
                });

                //根据字符串删除
                db.Delete <School>("id=@id", new { id = 100 });

                //假删除
                //db.FalseDelete<school>("is_del", 100);
                //等同于 update school set is_del=1 where id in(100)
                //db.FalseDelete<school>("is_del", it=>it.id==100);
            }
        }
Example #29
0
        public void Init()
        {
            Student2 p = new Student2()
            {
                id = 2, name = "张表", isOk = true
            };

            Console.WriteLine("启动Test.Init");
            using (var db = SugarDao.GetInstance())
            {
                //初始化数据
                InitData(db);

                //查询测试
                Select(p, db);

                //拉姆达测试
                Exp(p, db);

                //新容器转换测试
                SelectNew(p, db);

                //更新测试
                Update(p, db);

                //删除测试
                Delete(p, db);
            }
        }
Example #30
0
 public string SingleFieldList()
 {
     try
     {
         using (var db = SugarDao.GetInstance())
         {
             List <int> list = db.Queryable <Student>().Select <int>(x => x.id).ToList();
             if (list.Count > 0)
             {
                 string msg = "";
                 foreach (int li in list)
                 {
                     msg += "ID:" + li + "\t";
                 }
                 return(retMsg("查询所有的Id", msg));
             }
             else
             {
                 return(retMsg("查询所有的Id", "数组为0"));
             }
         }
     }
     catch (Exception e)
     {
         Console.WriteLine(e);
         return(retMsg("查询所有的Id", "报错了!!!!"));
     }
 }