Exemple #1
0
        /// <summary>
        /// 更新密码
        /// </summary>
        /// <param name="db"></param>
        /// <param name="id"></param>
        /// <param name="password"></param>
        /// <returns></returns>
        public static async Task <bool> UpdatePassword(DBHelper db, int id, string password)
        {
            string salt = MakeCommon.MakeSalt(id.ToString());
            string p    = MakeCommon.MakeMD5(salt + id + password + id + salt);
            string pwd  = ConcealCommon.EncryptDES(salt + p + salt);

            string sql = @"UPDATE t_user set `password`=@password, `salt`=@salt WHERE `id`=@id";

            return(await db.ExecAsync(sql, new { password = pwd, salt = salt, id = id }) > 0);
        }
        public async Task <Result> AddProcurement(In <ApplyOrderIn> inData)
        {
            Result result = VerifyAddProcurement(inData.data);

            if (!result.result)
            {
                return(result);
            }
            string   order_sn;
            DBHelper db = new DBHelper();

            do
            {
                order_sn = MakeCommon.MakeOrder("IN");
            } while (await ProcurementDao.IsExist(db, order_sn));

            try
            {
                db.BeginTransaction();
                //添加订单
                int order_id = await ProcurementDao.AddProcurement(db, order_sn, inData.user);

                if (order_id <= 0)
                {
                    db.Rollback();
                    result.msg = "操作失败[1]";
                    return(result);
                }

                bool add_product_flag = await ProcurementProductPreDao.AddProcurementProduct(db, order_sn, inData.data.product_list);

                if (!add_product_flag)
                {
                    db.Rollback();
                    result.msg = "操作失败[2]";
                    return(result);
                }

                db.Commit();
                result.result = true;
                result.msg    = "操作成功";
            }
            catch (Exception e)
            {
                db.Rollback();
                result.msg = e.Message;
            }
            return(result);
        }