Exemplo n.º 1
0
 /// <summary>
 /// 修改
 /// </summary>
 /// <param name="lifingCost"></param>
 /// <returns></returns>
 public String Update(LifingCost lifingCost)
 {
     try
     {
         int result = new BLLifingCost().Update(lifingCost);
         if (result > 0)
         {
             return(JsonConvert.JavaScriptSerializer(new ExtResult()
             {
                 success = true, msg = "修改成功"
             }));
         }
         else
         {
             return(JsonConvert.JavaScriptSerializer(new ExtResult()
             {
                 success = false, msg = "修改失败"
             }));
         }
     }
     catch (Exception ex)
     {
         return(JsonConvert.JavaScriptSerializer(new ExtResult()
         {
             success = false, msg = "修改失败,失败原因:" + ex.Message
         }));
     }
 }
Exemplo n.º 2
0
 /// <summary>
 /// 新增
 /// </summary>
 /// <param name="lifingCost"></param>
 /// <returns></returns>
 public String Add(LifingCost lifingCost)
 {
     try
     {
         lifingCost.Id = Guid.NewGuid().ToString();
         int result = new BLLifingCost().Add(lifingCost);
         if (result > 0)
         {
             return(JsonConvert.JavaScriptSerializer(new ExtResult()
             {
                 success = true, msg = "新增成功"
             }));
         }
         else
         {
             return(JsonConvert.JavaScriptSerializer(new ExtResult()
             {
                 success = false, msg = "新增失败"
             }));
         }
     }
     catch (Exception ex)
     {
         return(JsonConvert.JavaScriptSerializer(new ExtResult()
         {
             success = false, msg = "新增失败,失败原因:" + ex.Message
         }));
     }
 }
Exemplo n.º 3
0
        /// <summary>
        /// 同时向支出表和收入表中写入数据
        /// </summary>
        /// <param name="outUser">支出用户</param>
        /// <param name="outPrice">支出金额</param>
        /// <param name="inUser">收入用户</param>
        /// <param name="remark">备注</param>
        /// <returns></returns>
        public String OutIn(string time, string outUser, string outPrice, string inUser, string remark)
        {
            if (outUser == inUser)
            {
                return(JsonConvert.JavaScriptSerializer(new ExtResult()
                {
                    success = false, msg = "操作失败,支出和收入用户不能一样"
                }));
            }

            //组装数据
            LifingCost life = new LifingCost();

            life.Id         = Guid.NewGuid().ToString();
            life.Time       = time.GetDateTime();
            life.Reason     = remark;
            life.Price      = outPrice.GetDouble();
            life.CostTypeId = 1000300010;
            life.FamilyPay  = true;
            life.Notes      = remark + " 快速新增";
            life.CreateBy   = outUser;
            life.UpdateBy   = CurrentUser.Id;
            life.CreateTime = DateTime.Now;
            life.UpdateTime = DateTime.Now;

            Income income = new Income();

            income.Id           = Guid.NewGuid().ToString();
            income.Time         = time.GetDateTime();
            income.Price        = outPrice.GetDouble();
            income.Note         = remark;
            income.FamilyIncome = true;
            income.CreateBy     = inUser;
            income.CreateTime   = DateTime.Now;
            income.UpdateBy     = CurrentUser.Id;
            income.UpdateTime   = DateTime.Now;

            //写入数据库
            try
            {
                new BLLifingCost().Add(life);
                new BLIncome().Add(income);
                return(JsonConvert.JavaScriptSerializer(new ExtResult()
                {
                    success = true, msg = "操作成功"
                }));
            }
            catch (Exception ex)
            {
                return(JsonConvert.JavaScriptSerializer(new ExtResult()
                {
                    success = true, msg = "操作失败,失败原因:" + ex.Message
                }));
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// 查询生活费的所有消费名称
        /// </summary>
        /// <param name="key"></param>
        /// <returns></returns>
        public List <LifingCost> GetReasons(string key)
        {
            List <LifingCost> list = new List <LifingCost>();
            string            sql  = "select Reason from Lifing_Cost group by Reason having Reason like '%@key%'";

            SQLiteParameter[] parm = new SQLiteParameter[] {
                new SQLiteParameter("@key", key)
            };

            DataTable dt = SqlLiteHelper.GetTable(sql, CommandType.Text, parm);

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                LifingCost index = new LifingCost();
                index.Reason = dt.Rows[i]["Reason"].GetString();
                list.Add(index);
            }
            return(list);
        }
Exemplo n.º 5
0
        /// <summary>
        /// 保存
        /// </summary>
        /// <param name="lifingCost"></param>
        /// <returns></returns>
        public String Save(LifingCost lifingCost)
        {
            //判断Request中是否有接收Files文件
            if (Request.Files.Count != 0 && !String.IsNullOrEmpty(lifingCost.ImgUrl))
            {
                //HttpPostedFileBase类,提供对用户上载的单独文件的访问
                //获取到用户上传的文件
                HttpPostedFileBase file     = Request.Files[0];
                String             fileName = this.Upload(file, "/File/Life/");
                lifingCost.ImgUrl = fileName;
            }

            //创建人和修改者赋值
            Users user = Session["user"] as Users;

            if (string.IsNullOrEmpty(lifingCost.Id))
            {
                lifingCost.CreateTime = DateTime.Now;
                lifingCost.CreateBy   = user.Id;
                return(Add(lifingCost));
            }
            else
            {
                lifingCost.UpdateTime = DateTime.Now;
                lifingCost.UpdateBy   = user.Id;
                if (String.IsNullOrEmpty(lifingCost.ImgUrl))
                {
                    lifingCost.ImgUrl = new BLLifingCost().Select(lifingCost.Id).ImgUrl;
                }
                else
                {
                    var imgUrl = new BLLifingCost().Select(lifingCost.Id).ImgUrl;
                    if (!String.IsNullOrEmpty(imgUrl))
                    {
                        System.IO.File.Delete(Server.MapPath(imgUrl));
                    }
                }
                return(Update(lifingCost));
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// 修改生活费操作管理
        /// </summary>
        /// <param name="index">生活费操作管理对象</param>
        /// <returns></returns>
        public int Update(LifingCost index)
        {
            string sql = "update Lifing_Cost set Id=@Id,TIME=@TIME,Reason=@Reason,Price=@Price,Cost_Type_Id=@Cost_Type_Id,Notes=@Notes,Img_Url=@Img_Url,Create_By=@Create_By,Create_Time=@Create_Time,UpDate_By=@UpDate_By,UpDate_Time=@UpDate_Time,IsMark=@IsMark,FamilyPay=@FamilyPay,CusGroup=@CusGroup where Id=@Id";

            SQLiteParameter[] parm = new SQLiteParameter[] {
                new SQLiteParameter("@Id", index.Id),
                new SQLiteParameter("@TIME", index.Time),
                new SQLiteParameter("@Reason", index.Reason),
                new SQLiteParameter("@Price", index.Price),
                new SQLiteParameter("@Cost_Type_Id", index.CostTypeId),
                new SQLiteParameter("@Notes", index.Notes),
                new SQLiteParameter("@Img_Url", index.ImgUrl),
                new SQLiteParameter("@Create_By", index.CreateBy),
                new SQLiteParameter("@Create_Time", index.CreateTime),
                new SQLiteParameter("@UpDate_By", index.UpdateBy),
                new SQLiteParameter("@UpDate_Time", index.UpdateTime),
                new SQLiteParameter("@IsMark", index.IsMark),
                new SQLiteParameter("@FamilyPay", index.FamilyPay),
                new SQLiteParameter("@CusGroup", index.CusGroup)
            };
            return(SqlLiteHelper.ExecuteNonQuery(sql, CommandType.Text, parm));
        }
Exemplo n.º 7
0
        /// <summary>
        /// 增加生活费操作管理
        /// </summary>
        /// <param name="index">生活费操作管理对象</param>
        /// <returns></returns>
        public int Add(LifingCost index)
        {
            string sql = string.Format(@"insert into Lifing_Cost(Id,TIME,Reason,Price,Cost_Type_Id,Notes,Img_Url,Create_By,Create_Time,UpDate_By,UpDate_Time,IsMark,FamilyPay,CusGroup) 
                values(@Id,@TIME,@Reason,@Price,@Cost_Type_Id,@Notes,@Img_Url,@Create_By,@Create_Time,@UpDate_By,@UpDate_Time,@IsMark,@FamilyPay,@CusGroup)");

            SQLiteParameter[] parm = new SQLiteParameter[] {
                new SQLiteParameter("@Id", index.Id),
                new SQLiteParameter("@TIME", index.Time),
                new SQLiteParameter("@Reason", index.Reason),
                new SQLiteParameter("@Price", index.Price),
                new SQLiteParameter("@Cost_Type_Id", index.CostTypeId),
                new SQLiteParameter("@Notes", index.Notes),
                new SQLiteParameter("@Img_Url", index.ImgUrl),
                new SQLiteParameter("@Create_By", index.CreateBy),
                new SQLiteParameter("@Create_Time", index.CreateTime),
                new SQLiteParameter("@UpDate_By", index.UpdateBy),
                new SQLiteParameter("@UpDate_Time", index.UpdateTime),
                new SQLiteParameter("@IsMark", index.IsMark),
                new SQLiteParameter("@FamilyPay", index.FamilyPay),
                new SQLiteParameter("@CusGroup", index.CusGroup)
            };
            return(SqlLiteHelper.ExecuteNonQuery(sql, CommandType.Text, parm));
        }
Exemplo n.º 8
0
 /// <summary>
 /// 修改
 /// </summary>
 /// <returns>影响的行数</returns>
 public int Update(LifingCost lifingCost)
 {
     return(dLLifingCost.Update(lifingCost));
 }
Exemplo n.º 9
0
 /// <summary>
 /// 新增
 /// </summary>
 /// <returns>影响的行数</returns>
 public int Add(LifingCost lifingCost)
 {
     return(dLLifingCost.Add(lifingCost));
 }
Exemplo n.º 10
0
        /// <summary>
        /// 将dataTable保存到数据库
        /// </summary>
        /// <param name="dt"></param>
        /// <returns></returns>
        public String SaveData(DataTable dt, String userId)
        {
            List <LifingCost> list = new List <LifingCost>();
            String            msg  = "";

            foreach (DataRow row in dt.Rows)
            {
                LifingCost index = new LifingCost();
                String     type  = row["消费类型"].ToString();
                //判断类型是否存在
                HashTableExp hash = new HashTableExp("Name", type);
                hash.Add("ParentId", "1000300000");
                List <Diction> dictions = new BLDiction().Select(hash);
                if (dictions.Count <= 0)
                {
                    msg += "<br/>" + type + "不存在";
                    continue;
                }

                DateTime time;
                //判断时间是否正确
                if (!DateTime.TryParse(row["消费时间"].ToString(), out time))
                {
                    msg += "<br/>" + row["消费时间"] + "不是时间类型";
                    continue;
                }
                else
                {
                    index.Time = time;
                }

                double price;

                //判断金额是否正确
                if (!double.TryParse(row["消费金额"].ToString(), out price))
                {
                    msg += "<br/>" + row["消费金额"] + "不是数字类型";
                    continue;
                }
                else
                {
                    index.Price = price;
                }

                index.Id         = Guid.NewGuid().ToString();
                index.Reason     = row["消费名称"].ToString();
                index.CostTypeId = dictions[0].Id;
                index.Notes      = row["备注"].ToString();
                index.CreateBy   = userId;
                index.CreateTime = DateTime.Now;
                list.Add(index);
            }

            int result = dLLifingCost.Add(list);

            if (result > 0)
            {
                return("成功保存" + result + "条数据." + msg);
            }
            else
            {
                return(msg);
            }
        }
Exemplo n.º 11
0
 /// <summary>
 /// 新增
 /// </summary>
 /// <param name="bankCard"></param>
 /// <returns></returns>
 public String Add(BankCard bankCard)
 {
     try
     {
         bankCard.Id = Guid.NewGuid().ToString();
         int result = new BLBankCard().Add(bankCard);
         if (bankCard.SaveType == 1000200001 && Request["Income"] == "true")
         {
             //纯收入
             Income income = new Income()
             {
                 Id           = Guid.NewGuid().ToString(),
                 Time         = bankCard.Time,
                 Note         = bankCard.Note,
                 Price        = bankCard.Price,
                 CreateBy     = bankCard.CreateBy,
                 CreateTime   = bankCard.CreateTime,
                 IsMark       = Request["IsMark"].GetBoolean(),
                 FamilyIncome = Request["FamilyPay"].GetBoolean()
             };
             new BLIncome().Add(income);
         }
         if (bankCard.SaveType == 1000200002 && Request["Cost"] == "true")
         {
             //消费信息
             LifingCost cost = new LifingCost()
             {
                 Id         = Guid.NewGuid().ToString(),
                 Time       = bankCard.Time,
                 Reason     = bankCard.Note,
                 Price      = bankCard.Price,
                 CostTypeId = Request["CostTypeId"].GetDecimal(),
                 Notes      = bankCard.Note,
                 CreateBy   = bankCard.CreateBy,
                 CreateTime = bankCard.CreateTime,
                 IsMark     = Request["IsMark"].GetBoolean(),
                 FamilyPay  = Request["FamilyPay"].GetBoolean()
             };
             new BLLifingCost().Add(cost);
         }
         if (result > 0)
         {
             return(JsonConvert.JavaScriptSerializer(new ExtResult()
             {
                 success = true, msg = "新增成功"
             }));
         }
         else
         {
             return(JsonConvert.JavaScriptSerializer(new ExtResult()
             {
                 success = false, msg = "新增失败"
             }));
         }
     }
     catch (Exception ex)
     {
         return(JsonConvert.JavaScriptSerializer(new ExtResult()
         {
             success = false, msg = "新增失败,失败原因:" + ex.Message
         }));
     }
 }