Example #1
0
        //添加员工分组
        public ActionResult AddGroup(string groupName, string desc)
        {
            APIDataDataContext db = APIDataContextProxy.APIDB;
            {
                try
                {
                    TStaffGroup group = new TStaffGroup();
                    group.CreateTime = DateTime.Now;
                    group.GroupName = groupName;
                    group.Descriptions = desc;
                    db.TStaffGroup.InsertOnSubmit(group);
                    db.SubmitChanges();

                    TOperationLog OLog = new TOperationLog();

                    OLog.BeforeValue = "";
                    OLog.UpdateValue = ObjectToJson.ModelToJson(group);
                    //写入操作日志
                    OLog.UserID = Convert.ToInt32(Session["ID"]);
                    OLog.UserType = 2;//0 用户 1 会员 2 员工
                    OLog.CreateDate = DateTime.Now;
                    OLog.PageName = "新增员工分组";
                    Converter.InsertOperationLog(OLog);
                    return Json(group.ID);//添加成功
                }
                catch (Exception)
                {
                    return Json(0);//添加失败
                }

            }
        }
Example #2
0
        public ActionResult PostCurrency()
        {
            int Id = 0;  //Id
            string name = ""; //登陆名
            string Type = "";  //type
            string msg = "";  //提示信息
            bool fruit = false;  //结果
            TOperationLog OLog = new TOperationLog();
            try
            {
                int id = Converter.ToInt(Request["id"], 0);
                double curr = Convert.ToDouble(Converter.ToFloat(Request["currency"], 0).ToString("f5"));
                APIDataDataContext db = APIDataContextProxy.APIDB;
                var currency = (from c in db.TProductName where c.ID == id select c).FirstOrDefault();
                OLog.BeforeValue = ObjectToJson.ModelToJson(currency);
                if (currency != null)
                {
                    currency.CurrencyNum = curr;
                    db.SubmitChanges();

                    Id = Convert.ToInt32(Session["ID"]); //id
                    Type = Session["Type"].ToString();  //类型
                    msg = "修改汇率成功";
                    fruit = true;
                    Converter.InsertLog(Id, name, Type, msg, fruit);
                    OLog.UpdateValue = ObjectToJson.ModelToJson(currency);
                    //写入操作日志
                    OLog.UserID = Convert.ToInt32(Session["ID"]);
                    OLog.UserType = 2;//0 用户 1 会员 2 员工
                    OLog.CreateDate = DateTime.Now;
                    OLog.PageName = "修改汇率";
                    Converter.InsertOperationLog(OLog);
                    return Content("true");
                }
                else
                {
                    Id = Convert.ToInt32(Session["ID"]); //id
                    Type = Session["Type"].ToString();  //类型
                    msg = "修改汇率失败";
                    fruit = false;
                    Converter.InsertLog(Id, name, Type, msg, fruit);

                    return Content("false");
                }
            }
            catch
            {
                Id = Convert.ToInt32(Session["ID"]); //id
                Type = Session["Type"].ToString();  //类型
                msg = "修改汇率失败";
                fruit = false;
                Converter.InsertLog(Id, name, Type, msg, fruit);

                return Content("false");
            }
        }
Example #3
0
        public ActionResult Edit()
        {
            string name = ""; //登陆名
            string Type = "";  //type
            string msg = "";  //提示信息
            bool fruit = false;  //结果

            int ID = Converter.ToInt(Request.Form["id"], 0);//主键id
            string Name = Converter.ToString(Request.Form["Name"], "", null);//帐号名称
            string Phone = Converter.ToString(Request.Form["Phone"], "", null);//联系方式
            string Email = Converter.ToString(Request.Form["Email"], "", null);//联系邮箱
            string CityCode = Converter.ToString(Request.Form["CityCode"], "", null);//地区
            string Address = Converter.ToString(Request.Form["Address"], "", null);//地址
            int AllowTrade = Converter.ToInt(Request.Form["AllowTrade"], 0);//交易操作
            int AllowFinance = Converter.ToInt(Request.Form["AllowFinance"], 0);//资金操作
            int GroupID = Converter.ToInt(Request.Form["GroupID"], 0);//用户分组
            string password = Converter.ToString(Request["password"], "");   //密码
            double AccountMoney = (double)Converter.ToFloat(Request.Form["AccountMoney"], 0);    //帐户余额
            int agentid = Converter.ToInt(Request.Form["agentid"], 0);
            string IDCardNo = Converter.ToString(Request.Form["IDCardNo"], "", null);
            string SavingsAccount = Converter.ToString(Request.Form["SavingsAccount"], "", null);
            int Bankid = Converter.ToInt(Request.Form["Bankid"], 0);
            string Branch = Converter.ToString(Request["Branch"], "");

            if (ID == 0)
                Json(new { result = "fail", msg = "用户不存在!" });
            #region 数据校验
            bool isValid = true;
            int i = 0;
            if (string.IsNullOrEmpty(Name))
            {
                msg += (++i).ToString() + "、客户名称不能为空!<br />";
                isValid = false;
            }
            APIDataDataContext db = APIDataContextProxy.APIDB;
            {
                TRealAccounts account = null;
                if (!string.IsNullOrEmpty(Phone))
                {
                    account = db.TRealAccounts.Where(t => t.Phone == Phone).FirstOrDefault();
                    if (account != null)
                    {
                        if (account.ID != ID)
                        {
                            msg += (++i).ToString() + "、该联系方式已经存在!<br />";
                            isValid = false;
                        }
                    }
                }
                if (!string.IsNullOrEmpty(Email))
                {
                    account = db.TRealAccounts.Where(t => t.Email == Email).FirstOrDefault();
                    if (account != null)
                    {
                        if (account.ID != ID)
                        {
                            msg += (++i).ToString() + "、该联系邮箱已经存在!<br />";
                            isValid = false;
                        }
                    }
                }
            }
            if (string.IsNullOrEmpty(password))
            {
                msg += (++i).ToString() + "、密码不能为空!<br />";
                isValid = false;
            }
            if (string.IsNullOrEmpty(IDCardNo))
            {
                msg += (++i).ToString() + "、身份证号不能为空!<br />";
                isValid = false;
            }
            if (Bankid <= 0)
            {
                msg += (++i).ToString() + "、开户银行不能为空!<br />";
            }
            if (string.IsNullOrEmpty(SavingsAccount))
            {
                msg += (++i).ToString() + "、储蓄卡号不能为空!<br />";
                isValid = false;
            }
            if (string.IsNullOrEmpty(CityCode))
            {
                msg += (++i).ToString() + "、开户行所在地不能为空!<br />";
                isValid = false;
            }
            if (string.IsNullOrEmpty(Branch))
            {
                msg += (++i).ToString() + "、开户支行不能为空!<br />";
                isValid = false;
            }
            //if (AccountMoney <= 0)
            //{
            //    msg += (++i).ToString()+"、账户余额必须大于0!<br />";
            //    isValid = false;
            //}
            if (!isValid)
            {
                return Json(new { result = "fail", msg = msg });
            }
            #endregion
            try
            {
                    TOperationLog OLog = new TOperationLog();
                    var cityid = (from c in db.TCities where c.CityCode == CityCode select c.ID).FirstOrDefault();
                    TRealAccounts accounts = (from c in db.TRealAccounts where c.ID == ID select c).FirstOrDefault();
                    OLog.BeforeValue = ObjectToJson.ModelToJson(accounts);//修改前数据
                    accounts.Name = Name;
                    accounts.Phone = Phone;
                    accounts.Email = Email;
                    accounts.CityID = cityid;
                    accounts.Address = Address;
                    accounts.AllowTrade = (AllowTrade == 1);
                    accounts.AllowFinance = (AllowFinance == 1);
                    accounts.GroupID = GroupID;
                    if (agentid>0)
                        accounts.AgendID = agentid;
                    accounts.IDCardNo = IDCardNo;
                    accounts.BankID = Bankid;
                    accounts.SavingsAccount = SavingsAccount;
                    accounts.Branch = Branch;
                    if (!string.IsNullOrEmpty(password))
                    {
                        if (password != "******")
                        {
                            accounts.PassWord = password;
                        }
                    }

                    accounts.AccountMoney = AccountMoney;
                    db.SubmitChanges();

                    OLog.UpdateValue = ObjectToJson.ModelToJson(accounts);
                    //写入操作日志
                    OLog.UserID = Convert.ToInt32(Session["ID"]);
                    OLog.UserType = 2;//0 用户 1 会员 2 员工
                    OLog.CreateDate = DateTime.Now;
                    OLog.PageName = "修改用户";
                    Converter.InsertOperationLog(OLog);
                    //存入日志
                    ID = Convert.ToInt32(Session["ID"]); //id
                    Type = Session["Type"].ToString();  //类型
                    msg = "修改用户成功";
                    fruit = true;
                    Converter.InsertLog(ID, name, Type, msg, fruit);
                    return Json(new { result = "success", msg = msg });
            }
            catch
            {
                //存入日志
                ID = Convert.ToInt32(Session["ID"]); //id
                Type = Session["Type"].ToString();  //类型
                msg = "修改用户失败";
                fruit = false;
                Converter.InsertLog(ID, name, Type, msg, fruit);
                return Json(new { result = "fail", msg = msg });
            }
        }
Example #4
0
        public ActionResult PostEditPosition()
        {
            int id = 0;  //Id
            string name = ""; //登陆名
            string Type = "";  //type
            string msg = "";  //提示信息
            bool fruit = false;  //结果

            if (!Request.IsAjaxRequest())
                return Content("{result:'fail',msg:'非法请求!'}");
            int orderid = Converter.ToInt(Request.Form["orderid"], 0);
            if (orderid <= 0)
                return Content("{result:'fail',msg:'订单号错误!'}");
            string type = Request.Form["type"];
            TOperationLog OLog = new TOperationLog();

            if (type == "1")//删除
            {
                try
                {
                    APIDataDataContext db = APIDataContextProxy.APIDB;
                    {
                        var res = (from p in db.TOrders where p.ID == orderid select p).FirstOrDefault();
                        OLog.BeforeValue = ObjectToJson.ModelToJson(res);
                        if (res == null)
                            return Content("{result:'fail',msg:'订单不存在!'}");
                        else
                            db.TOrders.DeleteOnSubmit(res);
                        db.SubmitChanges();

                        OLog.UpdateValue = "";
                        //写入操作日志
                        OLog.UserID = Convert.ToInt32(Session["ID"]);
                        OLog.UserType = 2;//0 用户 1 会员 2 员工
                        OLog.CreateDate = DateTime.Now;
                        OLog.PageName = "删除委托订单";
                        Converter.InsertOperationLog(OLog);
                        //存入日志
                        id = Convert.ToInt32(Session["ID"]); //id
                        Type = Session["Type"].ToString();  //类型
                        msg = "删除订单成功";
                        fruit = true;
                        Converter.InsertLog(id, name, Type, msg, fruit);

                        return Content("{result:'success',msg:'删除成功!'}");
                    }
                }
                catch
                {
                    //存入日志
                    id = Convert.ToInt32(Session["ID"]); //id
                    Type = Session["Type"].ToString();  //类型
                    msg = "删除订单失败";
                    fruit = false;
                    Converter.InsertLog(id, name, Type, msg, fruit);

                    return Content("{result:'fail',msg:'服务器出错,删除失败!'}");
                }
            }

            int enType = Converter.ToInt(Request.Form["enType"], -1);
            if (!(enType >= 0 && enType <= 3))
                return Content("{result:'fail',msg:'订单类型错误!'}");
            bool deal = false;
            int entrust = 1;
            if (enType == 0)
            {
                deal = false;
                entrust = 1;
            }

            else if (enType == 1)
            {
                deal = true;
                entrust = 1;
            }

            else if (enType == 2)
            {
                deal = false;
                entrust = 0;
            }

            else
            {
                deal = true;
                entrust = 0;
            }
            double ordercount = Converter.ToFloat(Request.Form["ordercount"], 0);
            if (ordercount <= 0)
                return Content("{result:'fail',msg:'交易数量错误!'}");
            DateTime dt = DateTime.Now;
            if (!DateTime.TryParse(Request.Form["opentime"], out dt))
                return Content("{result:'fail',msg:'截止日期错误!'}");
            if (dt <= DateTime.Now)
                return Content("{result:'fail',msg:'截止日期不能小于当前时间!'}");
            double price = Converter.ToFloat(Request.Form["openprice"], 0);
            if (price <= 0)
                return Content("{result:'fail',msg:'价格错误!'}");
            string pro = (Request.Form["profit"] + "").Trim();
            float profit = 0f;
            if (pro != "" && !float.TryParse(pro, out profit))
                return Content("{result:'fail',msg:'止盈距离必须为数值类型!'}");
            string los = (Request.Form["profit"] + "").Trim();
            float loss = 0f;
            if (pro != "" && !float.TryParse(los, out loss))
                return Content("{result:'fail',msg:'止损距离必须为数值类型!'}");

            if (type == "0")
            {
                try
                {
                    APIDataDataContext db = APIDataContextProxy.APIDB;
                    {
                        var res = (from p in db.TOrders where p.ID == orderid select p).FirstOrDefault();
                        OLog.BeforeValue = ObjectToJson.ModelToJson(res);
                        if (res == null)
                            return Content("{result:'fail',msg:'订单不存在!'}");
                        else
                        {
                            res.Deal = deal;
                            res.EntrustType = entrust;
                            res.OrderCount = (double)ordercount;
                            res.OpenTime = dt;
                            res.OpenPrice = (double)price;
                            res.Profit = (double)profit;
                            res.Loss = (double)loss;
                        }
                        db.SubmitChanges();

                        OLog.UpdateValue = ObjectToJson.ModelToJson(res);
                        //写入操作日志
                        OLog.UserID = Convert.ToInt32(Session["ID"]);
                        OLog.UserType = 2;//0 用户 1 会员 2 员工
                        OLog.CreateDate = DateTime.Now;
                        OLog.PageName = "修改委托订单";
                        Converter.InsertOperationLog(OLog);
                        //存入日志
                        id = Convert.ToInt32(Session["ID"]); //id
                        Type = Session["Type"].ToString();  //类型
                        msg = "修改订单成功";
                        fruit = true;
                        Converter.InsertLog(id, name, Type, msg, fruit);

                        return Content("{result:'success',msg:'修改成功!'}");
                    }
                }
                catch
                {
                    //存入日志
                    id = Convert.ToInt32(Session["ID"]); //id
                    Type = Session["Type"].ToString();  //类型
                    msg = "修改订单失败";
                    fruit = false;
                    Converter.InsertLog(id, name, Type, msg, fruit);

                    return Content("{result:'fail',msg:'服务器出错,修改失败!'}");
                }
            }
            //委托单转开仓单,待做
            else if (type == "2")
            {
                return Content("{result:'fail',msg:'功能待做!'}");
            }
            return Content("{result:'fail',msg:'操作类型有误!'}");
        }
Example #5
0
        public ActionResult PostStaffInfo()
        {
            int Id = 0;  //Id
            string Name = ""; //登陆名
            string Type = "";  //type
            string msg = "";  //提示信息
            bool fruit = false;  //结果
            TOperationLog OLog = new TOperationLog();

            int uid = 1;
            try
            {
                if (!Request.IsAjaxRequest())
                    return Content("{result:'success',msg:'非法提交数据,信息修改失败!'}");
                int id = Converter.ToInt(Request.Form["ID"], 0);
                if (id == 0)
                    return Content("{result:'fail',msg:'员工不存在!'}");
                string staffName = Converter.ToString(Request.Form["StaffName"]).Trim();
                string telePhone = Converter.ToString(Request.Form["TelePhone"]).Trim();
                int groupid = Converter.ToInt(Request.Form["GroupID"], 0);
                string Account = Converter.ToString(Request.Form["Account"], "");
                string email = Converter.ToString(Request.Form["Email"]).Trim().ToLower();
                string password = Converter.ToString(Request["Password"]);
                string errMsg = "";
                #region 数据校验
                int i = 0;
                bool isValid = true;
                if (staffName == "")
                {
                    errMsg += (++i).ToString() + "、员工姓名不能为空;<br />";
                    isValid = false;
                }
                if (Account == "")
                {
                    errMsg += (++i).ToString() + "、员工帐号不能为空;<br />";
                    isValid = false;
                }

                if (string.IsNullOrEmpty(password))
                {
                    errMsg += (++i).ToString() + "、员工密码不能为空;<br />";
                    isValid = false;
                }
                APIDataDataContext db = APIDataContextProxy.APIDB;
                {
                    if (!string.IsNullOrEmpty(Account))
                    {
                        TStaffs staff = db.TStaffs.Where(t => t.Account == Account).FirstOrDefault();
                        if (staff != null)
                        {
                            if (staff.ID != id)
                            {
                                errMsg += (++i).ToString() + "、员工帐号已经存在;<br />";
                                isValid = false;
                            }
                        }
                    }
                    if (!string.IsNullOrEmpty(telePhone))
                    {
                        TStaffs staff = db.TStaffs.Where(t => t.TelePhone == telePhone).FirstOrDefault();
                        if (staff != null)
                        {
                            if (staff.ID != id)
                            {
                                errMsg += (++i).ToString() + "、联系电话已经存在;<br />";
                                isValid = false;
                            }
                        }
                    }
                    if (!string.IsNullOrEmpty(email))
                    {
                        TStaffs staff = db.TStaffs.Where(t => t.Email == email).FirstOrDefault();
                        if (staff != null)
                        {
                            if (staff.ID != id)
                            {
                                errMsg += (++i).ToString() + "、联系邮箱已经存在;<br />";
                                isValid = false;
                            }
                        }
                    }
                }
                #endregion
                if (!isValid)
                {
                    return Content("{result:'fail',msg:'" + errMsg + "'}");
                }
                else
                {
                    var staff = (from p in db.TStaffs where p.ID == id select p).FirstOrDefault();
                    OLog.BeforeValue = ObjectToJson.ModelToJson(staff);
                    if (staff == null)
                    {
                        return Content("{result:'fail',msg:'员工不存在!'}");
                    }
                    else
                    {
                        staff.StaffName = staffName;
                        staff.GroupID = groupid;
                        staff.TelePhone = telePhone;
                        staff.Email = email;
                        //staff.DepartmentID = depid;
                        staff.LastModifyerID = uid;
                        staff.LastUpdateTime = DateTime.Now;
                        staff.Password = password;
                        db.SubmitChanges();

                        OLog.UpdateValue = ObjectToJson.ModelToJson(staff);

                        //写入操作日志
                        OLog.UserID = Convert.ToInt32(Session["ID"]);
                        OLog.UserType = 2;//0 用户 1 会员 2 员工
                        OLog.CreateDate = DateTime.Now;
                        OLog.PageName = "修改员工账户";
                        Converter.InsertOperationLog(OLog);
                        //存入日志
                        Id = Convert.ToInt32(Session["ID"]); //id
                        Type = Session["Type"].ToString();  //类型
                        msg = "修改员工成功";
                        fruit = true;
                        Converter.InsertLog(Id, Name, Type, msg, fruit);
                        return Content("{result:'success',msg:'信息修改成功!'}");
                    }
                }
            }
            catch (Exception ex)
            {
                //存入日志
                Id = Convert.ToInt32(Session["ID"]); //id
                Type = Session["Type"].ToString();  //类型
                msg = "修改员工失败";
                fruit = false;
                Converter.InsertLog(Id, Name, Type, msg, fruit);
                return Content("{result:'fail',msg:'修改失败,出现未知异常!'}");
            }
        }
Example #6
0
        /// <summary>
        /// 处理提款申请结果
        /// </summary>
        /// <returns></returns>
        public ActionResult ApplyforResult(int orderId, int bankStatus, int? platformStatus, int? examine)
        {
            APIDataDataContext db = APIDataContextProxy.APIDB;
            var res = "1";
            try
            {
                TAccountMoney ta = db.TAccountMoney.Where(s => s.Id == orderId).FirstOrDefault();

                TOperationLog OLog = new TOperationLog();
                bool isTrue = false;
                OLog.BeforeValue = ObjectToJson.ModelToJson(ta);
                if (bankStatus == -1 || bankStatus == -2)
                {
                    OLog.PageName = bankStatus == -1 ? "确认出金成功" : "确认出金失败";
                }
                string payType = System.Configuration.ConfigurationManager.AppSettings["payType"];//支付接口类型
                if (ta.AgentId == null)
                {
                    TRealAccounts tr = db.TRealAccounts.Where(t => t.ID == ta.RealAccountId).FirstOrDefault();
                    #region 用户出金
                    switch (bankStatus)
                    {
                        case -1://确认出金成功
                            if (ta.Status > 1)
                            {
                                res = "订单状态错误!";
                            }
                            else
                            {
                                #region 调用出金接口
                                if (!string.IsNullOrEmpty(payType))
                                {
                                    if (tr != null)
                                    {
                                        RequestResult result = CashOutAPI.CachOut(payType, tr, null, ta);
                                        if (!result.IsSuccess)
                                        {
                                            return Json(result.ErrMsg);
                                        }
                                    }
                                    else
                                    {
                                        return Json("用户不存在!");//用户不存在
                                    }
                                }
                                #endregion
                                ta.BankState = 1;
                                ta.PlatformState = 1;
                                ta.Examine = 1;
                                ta.Status = 2;
                                //tr.AccountMoney = tr.AccountMoney - ta.CreateMoney;
                            }
                            break;
                        case -2://确认出金失败
                            ta.BankState = 2;
                            ta.PlatformState = 2;
                            ta.Examine = 2;
                            ta.Status = 3;
                            tr.AccountMoney = tr.AccountMoney + ta.CreateMoney;
                            break;
                        default://提交处理其他
                            ta.BankState = bankStatus;
                            ta.PlatformState = platformStatus;
                            ta.Examine = examine;
                            if (examine == 0)
                            {
                                TRealAccounts trr = db.TRealAccounts.Where(t => t.ID == ta.RealAccountId).FirstOrDefault();
                                TBanks tb = db.TBanks.Where(b => b.Id == trr.BankID).FirstOrDefault();
                                res = Converter.SetMoneyOrder(orderId.ToString(), trr.Name, ta.AccountNo, Converter.ToInt(ta.CreateMoney), ta.BankName, tb.Code);
                            }
                            break;
                    }
                    #endregion
                }
                else
                {
                    #region 会员出金
                    TAgents tg = db.TAgents.Where(t => t.ID == ta.AgentId).FirstOrDefault();
                    switch (bankStatus)
                    {
                        case -1://确认出金成功
                            if (ta.Status > 1)
                            {
                                res = "订单状态错误!";
                            }
                            else
                            {
                                #region 调用出金接口
                                if (!string.IsNullOrEmpty(payType))
                                {
                                    if (tg != null)
                                    {
                                        RequestResult result = CashOutAPI.CachOut(payType, null, tg, ta);
                                        if (!result.IsSuccess)
                                        {
                                            return Json(result.ErrMsg);
                                        }
                                    }
                                    else
                                    {
                                        return Json("会员不存在!");//会员不存在
                                    }
                                }
                                #endregion
                                isTrue = true;
                                ta.BankState = 1;
                                ta.PlatformState = 1;
                                ta.Examine = 1;
                                ta.Status = 2;
                                //tg.AccountMoney = ((double)tg.AccountMoney - (double)ta.CreateMoney);
                            }
                            break;
                        case -2://确认出金失败
                            ta.BankState = 2;
                            ta.PlatformState = 2;
                            ta.Examine = 2;
                            ta.Status = 3;
                            tg.AccountMoney = (tg.AccountMoney + (double)ta.CreateMoney);
                            break;
                        default://提交处理其他
                            ta.BankState = bankStatus;
                            ta.PlatformState = platformStatus;
                            ta.Examine = examine;
                            if (examine == 0)
                            {
                                TRealAccounts trr = db.TRealAccounts.Where(t => t.ID == ta.RealAccountId).FirstOrDefault();
                                TBanks tb = db.TBanks.Where(b => b.Id == trr.BankID).FirstOrDefault();
                                res = Converter.SetMoneyOrder(orderId.ToString(), trr.Name, ta.AccountNo, Converter.ToInt(ta.CreateMoney), ta.BankName, tb.Code);
                            }
                            break;
                    }
                    #endregion
                }

                db.SubmitChanges();
                if (isTrue)
                {
                    OLog.UpdateValue = ObjectToJson.ModelToJson(ta);
                    //写入操作日志
                    OLog.UserID = Convert.ToInt32(Session["ID"]);
                    OLog.UserType = 2;//0 用户 1 会员 2 员工
                    OLog.CreateDate = DateTime.Now;
                    Converter.InsertOperationLog(OLog);
                }
            }
            catch
            {
                res = "出金出现错误,请核实出金用户信息!";
            }
            return Json(res);
        }
Example #7
0
        public ActionResult RemoveTAnalysis()
        {
            int id = 0;  //Id
            string name = ""; //登陆名
            string Type = "";  //type
            string msg = "";  //提示信息
            bool fruit = false;  //结果
            TOperationLog OLog = new TOperationLog();

            if (!Request.IsAjaxRequest())
                return Content("{result:'fail',msg:'非法请求'}");
            string str = Converter.ToString(Request.QueryString["ids"]).Trim();
            if (str == "")
                return Content("{result:'fail',msg:'参数错误,删除失败!'}");
            try
            {
                string sql = "delete from TAnalysis where Id in (" + str + ")";
                int count = APIDataContextProxy.ExecuteNonQuery(null, sql, CommandType.Text);
                if (count > 0)
                {
                    //存入日志
                    id = Convert.ToInt32(Session["ID"]); //id
                    Type = Session["Type"].ToString();  //类型
                    msg = "删除分析成功";
                    fruit = true;
                    Converter.InsertLog(id, name, Type, msg, fruit);

                    string[] arr = str.Split(',');
                    StringBuilder sb = new StringBuilder();
                    sb.Append("{\"IDList\":[");
                    foreach (string i in arr)
                    {
                        sb.Append("{").AppendFormat("\"id\":\"{0}\"", i).Append("},");
                    }

                    sb.Remove(sb.Length - 1, 1).Append("]}");
                    OLog.BeforeValue = sb.ToString();
                    OLog.UpdateValue = "";
                    //写入操作日志
                    OLog.UserID = Convert.ToInt32(Session["ID"]);
                    OLog.UserType = 2;//0 用户 1 会员 2 员工
                    OLog.CreateDate = DateTime.Now;
                    OLog.PageName = "删除分析";
                    Converter.InsertOperationLog(OLog);
                    return Content("{result:'success',msg:'删除成功!'}");
                }

                else
                {
                    //存入日志
                    id = Convert.ToInt32(Session["ID"]); //id
                    Type = Session["Type"].ToString();  //类型
                    msg = "删除分析失败";
                    fruit = false;
                    Converter.InsertLog(id, name, Type, msg, fruit);
                    return Content("{result:'success',msg:'删除失败!'}");
                }

            }
            catch
            {
                //存入日志
                id = Convert.ToInt32(Session["ID"]); //id
                Type = Session["Type"].ToString();  //类型
                msg = "删除分析失败";
                fruit = false;
                Converter.InsertLog(id, name, Type, msg, fruit);

                return Content("{result:'success',msg:'删除失败,未知错误!'}");
            }
        }
Example #8
0
        public ActionResult PostAgentInfo()
        {
            int Id = 0;  //Id
            string name = ""; //登陆名
            string Type = "";  //type
            string msg = "";  //提示信息
            bool fruit = false;

            try
            {
                if (!Request.IsAjaxRequest())
                    return Content("{result:'success',msg:'非法提交数据,信息修改失败!'}");
                int id = Converter.ToInt(Request.Form["id"], 0);
                if (id == 0)
                    return Content("{result:'fail',msg:'非法提交数据,信息修改失败!'}");
                string agentName = Converter.ToString(Request.Form["agentname"]).Trim();
                string phone = Converter.ToString(Request.Form["phone"]).Trim();
                string email = Converter.ToString(Request.Form["email"]).Trim();
                string citycode = Converter.ToString(Request.Form["citycode"], "");
                string address = Converter.ToString(Request.Form["address"]).Trim();
                int dirid = Converter.ToInt(Request.Form["dirid"], 0);
                string idno = Converter.ToString(Request.Form["idno"]).Trim();
                int bankid = Converter.ToInt(Request.Form["bankid"], 0);
                string savings = Converter.ToString(Request.Form["savings"]).Trim();
                int allowcus = Converter.ToInt(Request.Form["allowcus"], -1);
                int allowagent = Converter.ToInt(Request.Form["allowagent"], -1);
                int groupid = Converter.ToInt(Request.Form["groupid"], 0);
                string password = Converter.ToString(Request.Form["password"], "");
                string branch = Converter.ToString(Request["Branch"], "");
                string savingsName = Converter.ToString(Request["SavingsName"], "");

                #region 返佣信息
                var hr1 = Converter.ToFloat(Request["HeadRate1"]);
                var pr1 = Converter.ToFloat(Request["ProcessRate1"]);
                var ir1 = Converter.ToFloat(Request["InterestRate1"]);
                var hr2 = Converter.ToFloat(Request["HeadRate2"]);
                var pr2 = Converter.ToFloat(Request["ProcessRate2"]);
                var ir2 = Converter.ToFloat(Request["InterestRate2"]);
                var hr3 = Converter.ToFloat(Request["HeadRate3"]);
                var pr3 = Converter.ToFloat(Request["ProcessRate3"]);
                var ir3 = Converter.ToFloat(Request["InterestRate3"]);
                var hr4 = Converter.ToFloat(Request["HeadRate4"]);
                var pr4 = Converter.ToFloat(Request["ProcessRate4"]);
                var ir4 = Converter.ToFloat(Request["InterestRate4"]);
                var hr5 = Converter.ToFloat(Request["HeadRate5"]);
                var pr5 = Converter.ToFloat(Request["ProcessRate5"]);
                var ir5 = Converter.ToFloat(Request["InterestRate5"]);
                #endregion

                #region 数据校验
                string errMsg = "";
                bool isValid = true;
                int i = 0;
                if (agentName == "")
                {
                    errMsg += (++i).ToString() + "、会员姓名不能为空;<br />";
                    isValid = false;
                }
                using (APIDataDataContext db = APIDataContextProxy.APIDB)
                {
                    TAgents agent = null;
                    if (!string.IsNullOrEmpty(phone))
                    {
                        agent = db.TAgents.Where(t => t.TelePhone == phone).FirstOrDefault();
                        if (agent != null)
                        {
                            if (agent.ID != id)
                            {
                                errMsg += (++i).ToString() + "、联系方式已经存在!<br />";
                                isValid = false;
                            }
                        }
                    }
                    if (!string.IsNullOrEmpty(email))
                    {

                        agent = db.TAgents.Where(t => t.Email == email).FirstOrDefault();
                        if (agent != null)
                        {
                            if (agent.ID != id)
                            {
                                errMsg += (++i).ToString() + "、联系邮箱已经存在!<br />";
                                isValid = false;
                            }
                        }
                    }
                }
                if (password == "")
                {
                    errMsg += (++i).ToString() + "、密码不能为空;<br />";
                    isValid = false;
                }
                if (id == dirid)
                {
                    errMsg += (++i).ToString() + "、所属上级不能为会员自己;<br />";
                    isValid = false;
                }
                if (string.IsNullOrEmpty(idno))
                {
                    errMsg += (++i).ToString() + "、身份证号不能为空!<br />";
                    isValid = false;
                }
                if (string.IsNullOrEmpty(savings))
                {
                    errMsg += (++i).ToString() + "、银行卡号不能为空!<br />";
                    isValid = false;
                }
                if (bankid <= 0)
                {
                    errMsg += (++i).ToString() + "、开户银行不能为空!<br />";
                    isValid = false;
                }
                if (string.IsNullOrEmpty(citycode))
                {
                    errMsg += (++i).ToString() + "、开户行所在地不能为空!<br />";
                    isValid = false;
                }
                if (string.IsNullOrEmpty(branch))
                {
                    errMsg += (++i).ToString() + "、银行支行名不能为空!<br />";
                    isValid = false;
                }
                if (bankid <= 0)
                {
                    errMsg += (++i).ToString() + "、开户银行不能为空!<br />";
                    isValid = false;
                }

                #endregion

                if (!isValid)
                {
                    return Content("{result:'fail',msg:'" + errMsg + "'}");
                }
                else
                {
                    using (APIDataDataContext db = APIDataContextProxy.APIDB)
                    {
                        TOperationLog OLog = new TOperationLog();

                        var agent = (from p in db.TAgents where p.ID == id select p).FirstOrDefault();
                        OLog.BeforeValue = ObjectToJson.ModelToJson(agent);
                        if (agent == null)
                            return Content("{result:'fail',msg:'会员不存在!'}");
                        int cityID = (from p in db.TCities where p.CityCode == citycode select p.ID).FirstOrDefault();
                        agent.CityID = cityID;
                        agent.AgentName = agentName;
                        agent.TelePhone = phone;
                        agent.Email = email;
                        agent.Address = address;
                        //agent.DirectAgentID = dirid;
                        agent.IdCardNo = idno;
                        agent.BankID = bankid;
                        agent.SavingsAccount = savings;
                        agent.PassWord = password;
                        agent.AllowDevelopAgents = Convert.ToBoolean(allowagent);
                        agent.AllowDevelopCustomers = Convert.ToBoolean(allowcus);
                        agent.GroupID = groupid;
                        agent.LastLoginTime = DateTime.Now;
                        agent.Branch = branch;
                        agent.SavingsName = savingsName;

                        agent.HeadRate1 = hr1;
                        agent.ProcessRate1 = pr1;
                        agent.InterestRate1 = ir1;
                        agent.HeadRate2 = hr2;
                        agent.ProcessRate2 = pr2;
                        agent.InterestRate2 = ir2;
                        agent.HeadRate3 = hr3;
                        agent.ProcessRate3 = pr3;
                        agent.InterestRate3 = ir3;
                        agent.HeadRate4 = hr4;
                        agent.ProcessRate4 = pr4;
                        agent.InterestRate4 = ir4;
                        agent.HeadRate5 = hr5;
                        agent.ProcessRate5 = pr5;
                        agent.InterestRate5 = ir5;

                        db.SubmitChanges();

                        OLog.UpdateValue = ObjectToJson.ModelToJson(agent);
                        //写入操作日志
                        OLog.UserID = Convert.ToInt32(Session["ID"]);
                        OLog.UserType = 2;//0 用户 1 会员 2 员工
                        OLog.CreateDate = DateTime.Now;
                        OLog.PageName = "修改会员会员";
                        Converter.InsertOperationLog(OLog);

                        //存入日志
                        id = Convert.ToInt32(Session["ID"]); //id
                        Type = Session["Type"].ToString();  //类型
                        msg = "修改会员信息成功";
                        fruit = true;
                        Converter.InsertLog(Id, name, Type, msg, fruit);
                        return Content("{result:'success',msg:'信息修改成功!'}");
                    }
                }
            }

            catch (Exception ex)
            {
                //存入日志
                Id = Convert.ToInt32(Session["ID"]); //id
                Type = Session["Type"].ToString();  //类型
                msg = "修改会员信息失败";
                fruit = false;
                Converter.InsertLog(Id, name, Type, msg, fruit);
                return Content("{result:'fail',msg:'修改失败,出现未知异常!'}");
            }
        }
Example #9
0
        public ActionResult PostCommission()
        {
            APIDataDataContext db = APIDataContextProxy.APIDB;
            int id = 0;  //Id
            string name = ""; //登陆名
            string Type = "";  //type
            string msg = "";  //提示信息
            bool fruit = false;  //结果
            TOperationLog OLog = new TOperationLog();
            OLog.PageName = "会员资金审核";
            try
            {
                var agentid = Request["agentid"];
                var createdate = Request["createdate"];

                var Yjtc = Convert.ToDouble(Converter.ToFloat(Request["Yjtc"], 0).ToString("f4"));
                var Yjjgf = Convert.ToDouble(Converter.ToFloat(Request["Yjjgf"], 0).ToString("f4"));
                var Yjcx = Convert.ToDouble(Converter.ToFloat(Request["Yjcx"], 0).ToString("f4"));
                var Yjxj = Convert.ToDouble(Converter.ToFloat(Request["Yjxj"], 0).ToString("f4"));

                var allrate = Convert.ToDouble(Converter.ToFloat(Request["allrate"], 0).ToString("f4"));

                TAgentCommission tac = new TAgentCommission();
                tac.agentid = Convert.ToInt32(agentid);
                tac.createdate = Convert.ToDateTime(createdate);
                db.TAgentCommission.InsertOnSubmit(tac);

                var ag = (from c in db.TAgents where c.ID == Convert.ToInt32(agentid) select c).FirstOrDefault();

                #region 资金记录

                TAccountMoney tam = new TAccountMoney();
                tam.MoneyOrderNum = DateTime.Now.ToString("yyyyMMddHHmmssfff");
                tam.AgentId = ag.ID;
                tam.TypeId = 4;
                tam.OriginalMoney = ag.AccountMoney;
                tam.CreateMoney = Yjtc;
                tam.NowMoney = ag.AccountMoney + Yjtc;
                if (tam.NowMoney < 0)
                {
                    tam.NowMoney = 0;
                }
                tam.CreateTime = Convert.ToDateTime(createdate);
                tam.UpDateTime = Convert.ToDateTime(createdate);
                tam.Status = 2;
                tam.TOrderId = 0;
                db.TAccountMoney.InsertOnSubmit(tam);

                TAccountMoney tams = new TAccountMoney();
                tams.MoneyOrderNum = DateTime.Now.ToString("yyyyMMddHHmmssfff");
                tams.AgentId = ag.ID;
                tams.TypeId = 5;
                tams.OriginalMoney = tam.NowMoney;
                tams.CreateMoney = Yjjgf;
                tams.NowMoney = tam.NowMoney + Yjjgf;
                if (tams.NowMoney < 0)
                {
                    tams.NowMoney = 0;
                }
                tams.CreateTime = Convert.ToDateTime(createdate);
                tams.UpDateTime = Convert.ToDateTime(createdate);
                tams.Status = 2;
                tams.TOrderId = 0;
                db.TAccountMoney.InsertOnSubmit(tams);

                TAccountMoney tams1 = new TAccountMoney();
                tams1.MoneyOrderNum = DateTime.Now.ToString("yyyyMMddHHmmssfff");
                tams1.AgentId = ag.ID;
                tams1.TypeId = 6;
                tams1.OriginalMoney = tams.NowMoney;
                tams1.CreateMoney = Yjcx;
                tams1.NowMoney = tams.NowMoney + Yjcx;
                if (tams1.NowMoney < 0)
                {
                    tams1.NowMoney = 0;
                }
                tams1.CreateTime = Convert.ToDateTime(createdate);
                tams1.UpDateTime = Convert.ToDateTime(createdate);
                tams1.Status = 2;
                tams1.TOrderId = 0;
                db.TAccountMoney.InsertOnSubmit(tams1);

                TAccountMoney tams2 = new TAccountMoney();
                tams2.MoneyOrderNum = DateTime.Now.ToString("yyyyMMddHHmmssfff");
                tams2.AgentId = ag.ID;
                tams2.TypeId = 7;
                tams2.OriginalMoney = tams1.NowMoney;
                tams2.CreateMoney = Yjxj;
                tams2.NowMoney = tams1.NowMoney + Yjxj;
                if (tams2.NowMoney < 0)
                {
                    tams2.NowMoney = 0;
                }
                tams2.CreateTime = Convert.ToDateTime(createdate);
                tams2.UpDateTime = Convert.ToDateTime(createdate);
                tams2.Status = 2;
                tams2.TOrderId = 0;
                db.TAccountMoney.InsertOnSubmit(tams2);

                #endregion

                ag.AccountMoney = ag.AccountMoney + Yjtc + Yjjgf + Yjcx + Yjxj;

                db.SubmitChanges();

                var total = allrate + Yjxj;
                StringBuilder sb = new StringBuilder();

                sb.Append("{")
                    .AppendFormat(
                        "\"会员金额\":\"{0}\",\"分红\":\"{1}\",\"加工费\":\"{2}\",\"仓息\":\"{3}\",\"本级汇总\":\"{4}\",\"下级汇总\":\"{5}\",\"总计\":\"{6}\"" +
                        "", ag.AccountMoney, Yjtc, Yjjgf, Yjcx, allrate, Yjxj, total).Append("}");

                OLog.UpdateValue = sb.ToString();
                OLog.BeforeValue = "";
                //写入操作日志
                OLog.UserID = Convert.ToInt32(Session["ID"]);
                OLog.UserType = 2;//0 用户 1 会员 2 员工
                OLog.CreateDate = DateTime.Now;
                Converter.InsertOperationLog(OLog);
                //存入日志
                id = Convert.ToInt32(Session["ID"]); //id
                Type = Session["Type"].ToString();  //类型
                msg = "修改会员账户金额";
                fruit = true;
                Converter.InsertLog(id, name, Type, msg, fruit);

                return Content("true");
            }
            catch
            {

                //存入日志
                id = Convert.ToInt32(Session["ID"]); //id
                Type = Session["Type"].ToString();  //类型
                msg = "修改会员账户金额";
                fruit = false;
                Converter.InsertLog(id, name, Type, msg, fruit);

                return Content("false");
            }
        }
Example #10
0
        public ActionResult PostClosingEdit()
        {
            APIDataDataContext db = APIDataContextProxy.APIDB;
            int TRealAccountsID = Converter.ToInt(Request["TRealAccountsID"], 0);
            var password = Request["password"];
            TOperationLog OLog = new TOperationLog();
            TRealAccounts realAccount = new TRealAccounts();
            if (!Request.IsAjaxRequest())
                return Json(new { code = 0, msg = "非法请求!" });
            int orderid = Converter.ToInt(Request["orderid"], 0);
            if (orderid == 0)
                return Json(new { code = 0, msg = "订单号错误!" });
            int type = Converter.ToInt(Request["type"], 0);
            if (!(type >= 1 && type <= 3))
                return Json(new { code = 0, msg = "操作类型错误!" });
            try
            {

                var user2 = (from c in db.TRealAccounts where c.ID == TRealAccountsID && c.PassWord == password select c).FirstOrDefault();
                if (user2 == null)
                {
                    return Json(new { code = 0, msg = "客户密码不正确!" });
                }
                var order = (from c in db.TOrders
                             where c.ID == orderid && c.OrderType == 2 && c.OrderState == 2
                             select c).FirstOrDefault();
                if (order == null)
                    return Json(new { code = 0, msg = "订单不存在!" });
                OLog.BeforeValue = ObjectToJson.ModelToJson(order);
                if (type == 1 || type == 2)
                {
                    OLog.PageName = "重新平仓";
                    OLog.UpdateValue = "";
                    bool orderType = Converter.ToInt(Request["OrderType"], 1) == 1 ? true : false;
                    double orderCount = Converter.ToFloat(Request["OrderCount"], order.OrderCount != null ? (float)order.OrderCount.Value : 0f);
                    double openPrice = Converter.ToFloat(Request["OpenPrice"], order.OpenPrice != null ? (float)order.OpenPrice.Value : 0f);
                    double loss = Converter.ToFloat(Request["Loss"], order.Loss != null ? (float)order.Loss.Value : 0f);
                    double profit = Converter.ToFloat(Request["Profit"], order.Profit != null ? (float)order.Profit.Value : 0f);
                    DateTime dtOpen = DateTime.Now;
                    if (!(DateTime.TryParse(Request["OpenTime"] + "", out dtOpen) && order.OpenTime != null))
                        dtOpen = order.OpenTime.Value;
                    DateTime dtClose = DateTime.Now;
                    if (!(DateTime.TryParse(Request["UpdateTime"] + "", out dtOpen) && order.UpdateTime != null))
                        dtClose = order.UpdateTime.Value;
                    double nowPrice = Converter.ToFloat(Request["NowPrice"], order.NowPrice != null ? (float)order.NowPrice.Value : 0f);
                    double deposit = Converter.ToFloat(Request["Deposit"], order.Deposit != null ? (float)order.Deposit.Value : 0f);
                    double interest = Converter.ToFloat(Request["Interest"], order.Interest != null ? (float)order.Interest.Value : 0f);
                    double proloss = Converter.ToFloat(Request["ProfitAndLoss"], order.ProfitAndLoss != null ? (float)order.ProfitAndLoss.Value : 0f);

                    order.Deal = orderType;
                    order.OrderCount = orderCount;
                    order.OpenPrice = openPrice;
                    order.Loss = loss;
                    order.OpenTime = dtOpen;
                    order.Profit = profit;
                    order.NowPrice = nowPrice;
                    order.Deposit = deposit;
                    order.UpdateTime = dtClose;
                    order.Interest = interest;
                    order.ProfitAndLoss = proloss;
                    if (type == 2)
                    {
                        OLog.PageName = "撤销平仓";
                        order.OrderType = 1;
                        order.OrderState = 1;
                        //撤销平仓要改余额
                        List<TAccountMoney> orders = db.TAccountMoney.Where(a => a.TOrderId == orderid).ToList();
                        double? yingkui = 0.0;
                        double? fee = 0.0;
                        foreach (TAccountMoney item in orders)
                        {
                            if (item.TypeId == 4)
                            {
                                yingkui -= item.CreateMoney;
                            }
                            if (item.TypeId == 5)
                            {
                                fee += item.CreateMoney;
                            }
                            db.TAccountMoney.DeleteOnSubmit(item);
                        }
                        realAccount = db.TRealAccounts.Where(r => r.ID == order.TRealAccountsID).FirstOrDefault();
                        OLog.BeforeValue += ObjectToJson.ModelToJson(realAccount);
                        realAccount.AccountMoney = realAccount.AccountMoney + yingkui + fee;
                    }
                    db.SubmitChanges();

                    OLog.UpdateValue = ObjectToJson.ModelToJson(order) + ObjectToJson.ModelToJson(realAccount);
                    //写入操作日志
                    OLog.UserID = Convert.ToInt32(Session["ID"]);
                    OLog.UserType = 2;//0 用户 1 会员 2 员工
                    OLog.CreateDate = DateTime.Now;
                    Converter.InsertOperationLog(OLog);
                }
                else if (type == 3)
                {
                    db.TOrders.DeleteOnSubmit(order);
                    db.SubmitChanges();
                    OLog.PageName = "删除交易";
                    OLog.UpdateValue = "";
                    //写入操作日志
                    OLog.UserID = Convert.ToInt32(Session["ID"]);
                    OLog.UserType = 2;//0 用户 1 会员 2 员工
                    OLog.CreateDate = DateTime.Now;
                    Converter.InsertOperationLog(OLog);
                }

                return Json(new { code = 1, msg = "操作成功!" });
            }
            catch (System.Exception ex)
            {
                return Json(new { code = 0, msg = "服务器内部错误!" });
            }
        }
Example #11
0
        public ActionResult MoneySetEdit()
        {
            string ID = AdminProduct.Utils.Converter.ToString(Request.Form["Id"], "");
            string OsName = AdminProduct.Utils.Converter.ToString(Request.Form["OsName"], "", null);
            string IsHaveSigned = AdminProduct.Utils.Converter.ToString(Request.Form["IsHaveSigned"], "", null);
            string MoneyInTime1_start = AdminProduct.Utils.Converter.ToString(Request.Form["MoneyInTime1_start"], "", null);
            string MoneyInTime1_end = AdminProduct.Utils.Converter.ToString(Request.Form["MoneyInTime1_end"], "", null);
            string MoneyInTime2_start = AdminProduct.Utils.Converter.ToString(Request.Form["MoneyInTime2_start"], "", null);
            string MoneyInTime2_end = AdminProduct.Utils.Converter.ToString(Request.Form["MoneyInTime2_end"], "", null);
            string MoneyInMin = AdminProduct.Utils.Converter.ToString(Request.Form["MoneyInMin"], "", null);
            string MoneyInMax = AdminProduct.Utils.Converter.ToString(Request.Form["MoneyInMax"], "", null);
            string MoneyOutTime_start = AdminProduct.Utils.Converter.ToString(Request.Form["MoneyOutTime_start"], "", null);
            string MoneyOutTime_end = AdminProduct.Utils.Converter.ToString(Request.Form["MoneyOutTime_end"], "", null);
            string MoneyOutDayMax = AdminProduct.Utils.Converter.ToString(Request.Form["MoneyOutDayMax"], "", null);
            string MoneyOutMin = AdminProduct.Utils.Converter.ToString(Request.Form["MoneyOutMin"], "", null);
            string MoneyOutMax = AdminProduct.Utils.Converter.ToString(Request.Form["MoneyOutMax"], "", null);
            string MoneyOutCounterFee = AdminProduct.Utils.Converter.ToString(Request.Form["MoneyOutCounterFee"], "", null);
            string IsMoneyOutSure = AdminProduct.Utils.Converter.ToString(Request.Form["IsMoneyOutSure"], "", null);
            string MoneyOutDayOfCount = AdminProduct.Utils.Converter.ToString(Request.Form["MoneyOutDayOfCount"], "", null);
            TOperationLog OLog = new TOperationLog();
            try
            {
                APIDataDataContext db = APIDataContextProxy.APIDB;
                {
                    var sys = (from c in db.TSysPreference select c).FirstOrDefault();
                    OLog.BeforeValue = ObjectToJson.ModelToJson(sys);
                    if (sys != null)
                    {
                        sys.OsName = OsName;
                        sys.IsHaveSigned = IsHaveSigned == "TRUE";
                        sys.MoneyInTime1_start = TimeSpan.Parse(MoneyInTime1_start);
                        sys.MoneyInTime1_end = TimeSpan.Parse(MoneyInTime1_end);
                        sys.MoneyInTime2_start = TimeSpan.Parse(MoneyInTime2_start);
                        sys.MoneyInTime2_end = TimeSpan.Parse(MoneyInTime2_end);
                        sys.MoneyInMin = double.Parse(MoneyInMin);
                        sys.MoneyInMax = double.Parse(MoneyInMax);
                        sys.MoneyOutTime_start = TimeSpan.Parse(MoneyOutTime_start);
                        sys.MoneyOutTime_end = TimeSpan.Parse(MoneyOutTime_end);
                        sys.MoneyOutDayMax = double.Parse(MoneyOutDayMax);
                        sys.MoneyOutMin = double.Parse(MoneyOutMin);
                        sys.MoneyOutMax = double.Parse(MoneyOutMax);
                        sys.MoneyOutCounterFee = double.Parse(MoneyOutCounterFee);
                        sys.IsMoneyOutSure = IsMoneyOutSure == "TRUE";
                        sys.MoneyOutDayOfCount = int.Parse(MoneyOutDayOfCount);
                        OLog.PageName = "设置资金后台";
                        OLog.UpdateValue = ObjectToJson.ModelToJson(sys);
                    }
                    else
                    {
                        TSysPreference tsys = new TSysPreference();
                        tsys.OsName = OsName;
                        tsys.IsHaveSigned = IsHaveSigned == "TRUE";
                        tsys.MoneyInTime1_start = TimeSpan.Parse(MoneyInTime1_start);
                        tsys.MoneyInTime1_end = TimeSpan.Parse(MoneyInTime1_end);
                        tsys.MoneyInTime2_start = TimeSpan.Parse(MoneyInTime2_start);
                        tsys.MoneyInTime2_end = TimeSpan.Parse(MoneyInTime2_end);
                        tsys.MoneyInMin = double.Parse(MoneyInMin);
                        tsys.MoneyInMax = double.Parse(MoneyInMax);
                        tsys.MoneyOutTime_start = TimeSpan.Parse(MoneyOutTime_start);
                        tsys.MoneyOutTime_end = TimeSpan.Parse(MoneyOutTime_end);
                        tsys.MoneyOutDayMax = double.Parse(MoneyOutDayMax);
                        tsys.MoneyOutMin = double.Parse(MoneyOutMin);
                        tsys.MoneyOutMax = double.Parse(MoneyOutMax);
                        tsys.MoneyOutCounterFee = double.Parse(MoneyOutCounterFee);
                        tsys.IsMoneyOutSure = IsMoneyOutSure == "TRUE";
                        tsys.MoneyOutDayOfCount = int.Parse(MoneyOutDayOfCount);
                        db.TSysPreference.InsertOnSubmit(tsys);
                        OLog.PageName = "设置资金后台";
                        OLog.UpdateValue = ObjectToJson.ModelToJson(tsys);
                        // }
                    }
                    db.SubmitChanges();

                    //写入操作日志
                    OLog.UserID = Convert.ToInt32(Session["ID"]);
                    OLog.UserType = 2;//0 用户 1 会员 2 员工
                    OLog.CreateDate = DateTime.Now;
                    Converter.InsertOperationLog(OLog);
                    return Content(ID.ToString());
                }
            }
            catch
            {
                return Content("fail");
            }
        }
Example #12
0
        /// <summary>
        /// 调整资金
        /// </summary>
        /// <param name="type">0表示客户,1表示会员</param>
        /// <param name="createMoney">调整金额</param>
        /// <param name="id">客户或会员的ID</param>
        /// <param name="typeid">存款或取款</param>
        /// <returns></returns>
        public ActionResult MoneyChange(int type, double createMoney, int id, int typeid)
        {
            APIDataDataContext db = APIDataContextProxy.APIDB;
            {
                try
                {
                    TRealAccounts realAccount = new TRealAccounts();
                    TAgents agent = new TAgents();
                    TOperationLog OLog = new TOperationLog();
                    OLog.BeforeValue = "";
                    TAccountMoney accountMoney = new TAccountMoney() { CreateMoney = createMoney, TypeId = typeid, CreateTime = DateTime.Now, Status = 2, BankState=1,PlatformState=1,Examine=1 };
                    if (type == 0)
                    {
                        realAccount = db.TRealAccounts.Where(t => t.ID == id).FirstOrDefault();
                        accountMoney.OriginalMoney = realAccount.AccountMoney;
                        accountMoney.NowMoney = realAccount.AccountMoney + (typeid == 1 ? createMoney : (-1) * createMoney);
                        accountMoney.RealAccountId = id;
                        realAccount.AccountMoney = accountMoney.NowMoney;
                        if (typeid == 3 && realAccount.AccountMoney < 0)
                        {
                            return Json("余额不足!");
                        }
                    }
                    else
                    {
                        agent = db.TAgents.Where(t => t.ID == id).FirstOrDefault();
                        accountMoney.OriginalMoney = agent.AccountMoney;
                        accountMoney.NowMoney = agent.AccountMoney + (typeid == 1 ? createMoney : (-1) * createMoney);
                        accountMoney.AgentId = id;
                        agent.AccountMoney = (double)accountMoney.NowMoney;
                        if (typeid == 3 && agent.AccountMoney < 0)
                        {
                            return Json("余额不足!");
                        }
                    }
                    db.TAccountMoney.InsertOnSubmit(accountMoney);
                    db.SubmitChanges();
                    OLog.UpdateValue = ObjectToJson.ModelToJson(accountMoney);

                    //写入操作日志
                    OLog.UserID = Convert.ToInt32(Session["ID"]);
                    OLog.UserType = 2;//0 用户 1 会员 2 员工
                    OLog.CreateDate = DateTime.Now;
                    OLog.PageName = "调整金额";
                    Converter.InsertOperationLog(OLog);
                    return Json(1);

                }
                catch
                {
                    return Json("服务器内部错误!");
                }
            }
        }
Example #13
0
        public ActionResult PostProduct()
        {
            int Id = 0;  //Id
            string name = ""; //登陆名
            string Type = "";  //type
            string msg = "";  //提示信息
            bool fruit = false;  //结果

            if (!Request.IsAjaxRequest())
                return Content("{result:'fail',msg:'非法请求'}");
            int id = Converter.ToInt(Request.Form["id"], 0);
            string pname = Converter.ToString(Request.Form["ProductName"]).Trim();
            string tn = Converter.ToString(Request.Form["TableName"]).Trim();
            string cn = Converter.ToString(Request.Form["ContractNumber"]).Trim();
            string fix = Converter.ToString(Request.Form["Fixedly"]).Trim();
            string scale = Converter.ToString(Request.Form["Scale"]).Trim();
            string prof = Converter.ToString(Request.Form["ProfitSize"]).Trim();
            string losize = Converter.ToString(Request.Form["LossSize"]).Trim();
            string ensize = Converter.ToString(Request.Form["EntrustSize"]).Trim();
            int isbuy = Converter.ToInt(Request.Form["IsBuy"], 0);
            int issell = Converter.ToInt(Request.Form["IsSell"], 0);
            int type1 = Converter.ToInt(Request.Form["OccupyFundsType"], 0);
            int type2 = Converter.ToInt(Request.Form["OpenDeposit"], 0);
            int type3 = Converter.ToInt(Request.Form["InterestType"], 0);
            int sortNum = 0;
            string sortNumStr = Request.Form["SortNum"];

            int Base_TCurrencyId = Converter.ToInt(Request.Form["Base_TCurrencyId"], 0);
            int Quote_TCurrencyId = Converter.ToInt(Request.Form["Quote_TCurrencyId"], 0);

            string errMsg = "";
            if (pname == "")
                errMsg += "、产品名称不能为空;";
            if (tn == "")
                errMsg += "、数据来源不能为空;";
            int cn1 = 0;
            if (!int.TryParse(sortNumStr, out sortNum) || sortNum < 0)
                errMsg += "、排列顺序必须为数字且为正整数;";
            if (!int.TryParse(cn, out cn1) || cn1 < 0)
                errMsg += "、合约数必须为大于或等于0的正数;";
            double fix1 = 0;
            if (!double.TryParse(fix, out fix1) || fix1 < 0)
                errMsg += "、交易点差必须为大于或等于0的数;";
            int scale1 = 0;
            if (!int.TryParse(scale, out scale1) || scale1 < 0)
                errMsg += "、小数点必须为大于或等于0的正数;";
            double prof1 = 0;
            if (!double.TryParse(prof, out prof1) || prof1 < 0)
                errMsg += "、止盈距离必须为大于或等于0的数;";
            double losize1 = 0;
            if (!double.TryParse(losize, out losize1) || losize1 < 0)
                errMsg += "、止盈距离必须为大于或等于0的数;";
            double ensize1 = 0;
            if (!double.TryParse(ensize, out ensize1) || ensize1 < 0)
                errMsg += "、挂单距离必须为大于或等于0的数";

            #region 保证金
            double funds = 0;
            if (type1 == 1)
            {
                string funds1 = Converter.ToString(Request.Form["Funds1"]).Trim();
                if (!double.TryParse(funds1, out funds) || funds < 0)
                    errMsg += "、固定保证金数额不能为空;";

            }

            else if (type1 == 2)
            {
                string funds1 = Converter.ToString(Request.Form["Funds2"]).Trim();
                if (!double.TryParse(funds1, out funds) || funds < 0)
                    errMsg += "、浮动保证金比率不能为空;";
            }
            else
                errMsg += "、请选择固定保证金模式;";
            #endregion

            #region 加工费
            double open = 0;
            double close = 0;

            if (type2 == 1)
            {
                string open1 = Converter.ToString(Request.Form["Open1"]).Trim();
                string close1 = Converter.ToString(Request.Form["Close1"]).Trim();
                if (!double.TryParse(open1, out open) || open < 0)
                    errMsg += "、开仓金额不能为空;";
                if (!double.TryParse(close1, out close) || close < 0)
                    errMsg += "、平仓金额不能为空";
            }

            else if (type2 == 2)
            {
                string open2 = Converter.ToString(Request.Form["Open2"]).Trim();
                string close2 = Converter.ToString(Request.Form["Close2"]).Trim();
                if (!double.TryParse(open2, out open) || open < 0)
                    errMsg += "、开仓金额不能为空;";
                if (!double.TryParse(close2, out close) || close < 0)
                    errMsg += "、平仓金额不能为空";
            }
            else
                errMsg += "、请选择固定保证金模式;";
            #endregion

            #region 仓息
            double buy = 0;
            double sell = 0;

            if (type3 == 1)
            {
                string buy1 = Converter.ToString(Request.Form["Buy1"]).Trim();
                string sell1 = Converter.ToString(Request.Form["Sell1"]).Trim();
                if (!double.TryParse(buy1, out buy) || buy < 0)
                    errMsg += "、买单金额不能为空;";
                if (!double.TryParse(sell1, out sell) || sell < 0)
                    errMsg += "、卖单金额不能为空";
            }

            else if (type3 == 2)
            {
                string buy2 = Converter.ToString(Request.Form["Buy2"]).Trim();
                string sell2 = Converter.ToString(Request.Form["Sell2"]).Trim();
                if (!double.TryParse(buy2, out buy) || buy < 0)
                    errMsg += "、买单比率不能为空;";
                if (!double.TryParse(sell2, out sell) || sell < 0)
                    errMsg += "、卖单比率不能为空";
            }
            else
                errMsg += "、请选择仓息模式;";
            #endregion

            if (errMsg.Length > 0)
                return Content("{result:'fail',msg:'" + errMsg + "'}");

            try
            {
                TOperationLog OLog = new TOperationLog();
                OLog.BeforeValue = "";

                //id>0表名是修改
                if (id > 0)
                {
                    APIDataDataContext db = APIDataContextProxy.APIDB;
                    {
                        var entify = (from p in db.TProducts where p.ID != id && p.ProductName.ToLower() == pname.ToLower() select p).FirstOrDefault();

                        int count = (from p in db.TProducts where p.ID != id && p.ProductName.ToLower() == pname.ToLower() select p).Count();

                        if (count > 0)
                            return Content("{result:'fail',msg:'产品名称已存在,不能重复!'}");
                        var entity = db.TProducts.Where(p => p.ID == id).FirstOrDefault();
                        if (entity == null)
                            return Content("{result:'fail',msg:'修改失败,产品不存在!'}");
                        else
                        {
                            OLog.BeforeValue = ObjectToJson.ModelToJson(entity);
                            //var ProductName = (from c in db.TProductName where c.ProductCode == entity.ProductCode select c).FirstOrDefault();
                            //if (ProductName != null)
                            //{
                            //    ProductName.Quote_TCurrencyId = Quote_TCurrencyId;
                            //    ProductName.Base_TCurrencyId = Base_TCurrencyId;
                            //}

                            entity.ProductName = pname;
                            entity.ProductCode = entity.ProductTable = tn;
                            entity.ContractNumber = cn1;
                            entity.Fixedly = fix1;
                            entity.Scale = scale1;
                            entity.ProfitSize = prof1;
                            entity.LossSize = losize1;
                            entity.EntrustSize = ensize1;
                            entity.IsBuy = isbuy == 0 ? false : true;
                            entity.IsSell = issell == 0 ? false : true;
                            entity.OccupyFundsType = type1;
                            entity.OccupyFunds = funds;
                            entity.DepositType = type2;
                            entity.OpenDeposit = open;
                            entity.CloseDeposit = close;
                            entity.InterestType = type3;
                            entity.BuyInterest = buy;
                            entity.IsLook = true;
                            entity.SellInterest = sell;
                            entity.SortNum = sortNum;
                            db.SubmitChanges();

                            OLog.UpdateValue = ObjectToJson.ModelToJson(entity);
                            //写入操作日志
                            OLog.UserID = Convert.ToInt32(Session["ID"]);
                            OLog.UserType = 2;//0 用户 1 会员 2 员工
                            OLog.CreateDate = DateTime.Now;
                            OLog.PageName = "修改交易商品";
                            Converter.InsertOperationLog(OLog);

                            //存入日志
                            Id = Convert.ToInt32(Session["ID"]); //id
                            Type = Session["Type"].ToString();  //类型
                            msg = "修改成功";
                            fruit = true;
                            Converter.InsertLog(Id, name, Type, msg, fruit);

                            return Content("{result:'success',msg:'修改产品信息成功!'}");
                        }
                    }
                }
                else
                {
                    APIDataDataContext db = APIDataContextProxy.APIDB;
                    {
                        int count = (from p in db.TProducts where p.ProductName.ToLower() == pname.ToLower() select p).Count();
                        if (count > 0)
                            return Content("{result:'fail',msg:'产品名称已存在,不能重复!'}");
                        TProducts entity = new TProducts();

                        //var ProductName = (from c in db.TProductName where c.ProductCode == entity.ProductCode select c).FirstOrDefault();
                        //if (ProductName != null)
                        //{
                        //    //ProductName.Quote_TCurrencyId = Quote_TCurrencyId;
                        //    //ProductName.Base_TCurrencyId = Base_TCurrencyId;
                        //}

                        entity.ProductName = pname;
                        entity.ProductCode = entity.ProductTable = tn;
                        entity.ContractNumber = cn1;
                        entity.Fixedly = fix1;
                        entity.Scale = scale1;
                        entity.ProfitSize = prof1;
                        entity.LossSize = losize1;
                        entity.EntrustSize = ensize1;
                        entity.IsBuy = isbuy == 0 ? false : true;
                        entity.IsSell = issell == 0 ? false : true;
                        entity.OccupyFundsType = type1;
                        entity.OccupyFunds = funds;
                        entity.DepositType = type2;
                        entity.OpenDeposit = open;
                        entity.CloseDeposit = close;
                        entity.InterestType = type3;
                        entity.BuyInterest = buy;
                        entity.SellInterest = sell;
                        entity.IsLook = true;
                        entity.SortNum = sortNum;
                        db.TProducts.InsertOnSubmit(entity);
                        db.SubmitChanges();

                        OLog.UpdateValue = ObjectToJson.ModelToJson(entity);
                        //写入操作日志
                        OLog.UserID = Convert.ToInt32(Session["ID"]);
                        OLog.UserType = 2;//0 用户 1 会员 2 员工
                        OLog.CreateDate = DateTime.Now;
                        OLog.PageName = "新增交易商品";
                        Converter.InsertOperationLog(OLog);
                        //存入日志
                        Id = Convert.ToInt32(Session["ID"]); //id
                        Type = Session["Type"].ToString();  //类型
                        msg = "产品增加成功";
                        fruit = true;
                        Converter.InsertLog(Id, name, Type, msg, fruit);

                        return Content("{result:'success',msg:'产品增加成功!'}");
                    }
                }
            }
            catch
            {

                //存入日志
                Id = Convert.ToInt32(Session["ID"]); //id
                Type = Session["Type"].ToString();  //类型
                msg = "产品编辑失败";
                fruit = false;
                Converter.InsertLog(Id, name, Type, msg, fruit);

                return Content("{result:'fail',msg:'出现位置错误,操作失败!'}");
            }
        }
Example #14
0
        public ActionResult DelUserGroup()
        {
            int Id = 0;  //Id
            string name = ""; //登陆名
            string Type = "";  //type
            string msg = "";  //提示信息
            bool fruit = false;
            if (!Request.IsAjaxRequest())
                return Content("fail");
            int id = Converter.ToInt(Request["id"], 0);
            try
            {
                if (id > 0)
                {
                    APIDataDataContext db = APIDataContextProxy.APIDB;
                    {
                        int defaultGroupID = Convert.ToInt32(db.TSysPreference.FirstOrDefault().DefaultDisplay);
                        if (defaultGroupID==id)
                        {
                            return Json(new {content="fail",msg="默认分组不能删除!" });//默认分组不能删除
                        }
                        var usergroup = (from c in db.TUserGroup where c.ID == id select c).FirstOrDefault();
                        TOperationLog OLog = new TOperationLog();
                        OLog.BeforeValue = ObjectToJson.ModelToJson(usergroup);

                        if (usergroup != null)
                        {
                            db.TUserGroup.DeleteOnSubmit(usergroup);
                            //该分组下的用户都归到默认分组下
                            List<TRealAccounts> listAccount = db.TRealAccounts.Where(t => t.GroupID == usergroup.ID).ToList();
                            foreach (TRealAccounts a in listAccount)
                            {
                                a.GroupID = defaultGroupID;
                            }

                            OLog.UpdateValue = "";
                            //写入操作日志
                            OLog.UserID = Convert.ToInt32(Session["ID"]);
                            OLog.UserType = 2;//0 用户 1 会员 2 员工
                            OLog.CreateDate = DateTime.Now;
                            OLog.PageName = "删除分组管理";
                            Converter.InsertOperationLog(OLog);
                            //存入日志
                            Id = Convert.ToInt32(Session["ID"]); //id
                            Type = Session["Type"].ToString();  //类型
                            msg = "用户分组删除成功";
                            fruit = true;
                            Converter.InsertLog(Id, name, Type, msg, fruit);
                            db.SubmitChanges();
                            return Json(new { result = "success", msg = "删除成功!!" });
                        }
                        else
                        {
                            //存入日志
                            Id = Convert.ToInt32(Session["ID"]); //id
                            Type = Session["Type"].ToString();  //类型
                            msg = "用户分组删除失败";
                            fruit = true;
                            Converter.InsertLog(Id, name, Type, msg, fruit);
                            return Json(new { result = "fail", msg = "删除失败!" });
                        }
                    }
                }
                else
                {
                    //存入日志
                    Id = Convert.ToInt32(Session["ID"]); //id
                    Type = Session["Type"].ToString();  //类型
                    msg = "用户分组删除失败";
                    fruit = true;
                    Converter.InsertLog(Id, name, Type, msg, fruit);
                    return Json(new { result = "fail", msg = "删除失败!" });
                }
            }
            catch
            {
                //存入日志
                Id = Convert.ToInt32(Session["ID"]); //id
                Type = Session["Type"].ToString();  //类型
                msg = "用户分组修改失败";
                fruit = false;
                Converter.InsertLog(Id, name, Type, msg, fruit);
                return Content("fail");
            }
        }
Example #15
0
        public ActionResult PostHoliday()
        {
            int id = 0;  //Id
            string Name = ""; //登陆名
            string Type = "";  //type
            string msg = "";  //提示信息
            bool fruit = false;  //结果
            TOperationLog OLog = new TOperationLog();
            OLog.BeforeValue = "";
            if (!Request.IsAjaxRequest())
                return Content("{result:'fail',msg:'非法请求'}");
            string name = Converter.ToString(Request.Form["HolidayName"]).Trim();
            string begin = Converter.ToString(Request.Form["BeginDate"]).Trim();
            string end = Converter.ToString(Request.Form["EndDate"]).Trim();
            string errMsg = "";
            DateTime dt1 = DateTime.Now;
            DateTime dt2 = DateTime.Now;
            if (name == "")
                errMsg += "名称不能为空;";
            if (begin == "")
                errMsg += "起始时间不能为空;";
            else
            {

                if (!DateTime.TryParse(begin, out dt1))
                    errMsg += "起始时间无效;";
            }
            if (end == "")
                errMsg += "起始时间不能为空;";
            else
            {
                if (!DateTime.TryParse(end, out dt2))
                    errMsg += "结束时间无效;";
            }
            if (errMsg != "")
                return Content("{result:'fail',msg:'" + errMsg + "'}");
            try
            {
                APIDataDataContext db = APIDataContextProxy.APIDB;
                {
                    int count = db.THoliday.Where(p => p.HolidayName.ToLower() == name.ToLower()).Count();
                    if (count > 0)
                        return Content("{result:'fail',msg:'假期休市已存在,不能重复!'}");
                    THoliday entity = new THoliday();
                    entity.CreateDate = DateTime.Now;
                    entity.HolidayName = name;
                    entity.BeginDate = dt1;
                    entity.EndDate = dt2;
                    db.THoliday.InsertOnSubmit(entity);
                    db.SubmitChanges();

                    OLog.UpdateValue = ObjectToJson.ModelToJson(entity);
                    //写入操作日志
                    OLog.UserID = Convert.ToInt32(Session["ID"]);
                    OLog.UserType = 2;//0 用户 1 会员 2 员工
                    OLog.CreateDate = DateTime.Now;
                    OLog.PageName = "添加假期休市";
                    Converter.InsertOperationLog(OLog);

                    //存入日志
                    id = Convert.ToInt32(Session["ID"]); //id
                    Type = Session["Type"].ToString();  //类型
                    msg = "添加假期休市成功";
                    fruit = true;
                    Converter.InsertLog(id, Name, Type, msg, fruit);

                    return Content("{result:'success',msg:'添加成功!'}");
                }
            }
            catch
            {
                //存入日志
                id = Convert.ToInt32(Session["ID"]); //id
                Type = Session["Type"].ToString();  //类型
                msg = "添加假期休市失败";
                fruit = false;
                Converter.InsertLog(id, Name, Type, msg, fruit);

                return Content("{result:'fail',msg:'添加失败,未知错误!'}");
            }
        }
Example #16
0
        public ActionResult AddAgentInfos()
        {
            int id = 0;  //Id
            string name = ""; //登陆名
            string Type = "";  //type
            string msg = "";  //提示信息
            bool fruit = false;

            var AgentName = Converter.ToString(Request["AgentName"], "");
            var Account = Converter.ToString(Request["Account"], "");
            var TelePhone = Converter.ToString(Request["TelePhone"], "");
            var Email = Converter.ToString(Request["Email"], "");
            var Status = Converter.ToInt(Request["Status"], -1);
            var CityCode = Converter.ToString(Request["CityCode"], "");
            var Address = Converter.ToString(Request["Address"], "");
            var DirectAgentID = Converter.ToInt(Request["DirectAgentID"], 0);
            var OpenerID = Convert.ToInt32(Session["ID"]);  //
            DateTime dt = DateTime.Now;
            var OpenTime = dt;
            var IdCardNo = Converter.ToString(Request["IdCardNo"], "");
            var BankID = Converter.ToInt(Request["BankID"], -1);
            var SavingsAccount = Converter.ToString(Request["SavingsAccount"], "");
            var AllowDevelopCustomers = Converter.ToInt(Request["AllowDevelopCustomers"], -1);
            var AllowDevelopAgents = Converter.ToInt(Request["AllowDevelopAgents"], -1);
            var GroupID = Converter.ToInt(Request["GroupID"], -1);
            //var password = Request["PassWord"];
            var Branch = Converter.ToString(Request["Branch"], "");
            var savingsName = Converter.ToString(Request["SavingsName"], "");

            #region 返佣信息
            var hr1= Converter.ToFloat(Request["HeadRate1"]);
            var pr1=Converter.ToFloat(Request["ProcessRate1"]);
            var ir1 = Converter.ToFloat(Request["InterestRate1"]);
            var hr2 = Converter.ToFloat(Request["HeadRate2"]);
            var pr2 = Converter.ToFloat(Request["ProcessRate2"]);
            var ir2 = Converter.ToFloat(Request["InterestRate2"]);
            var hr3 = Converter.ToFloat(Request["HeadRate3"]);
            var pr3 = Converter.ToFloat(Request["ProcessRate3"]);
            var ir3 = Converter.ToFloat(Request["InterestRate3"]);
            var hr4 = Converter.ToFloat(Request["HeadRate4"]);
            var pr4 = Converter.ToFloat(Request["ProcessRate4"]);
            var ir4 = Converter.ToFloat(Request["InterestRate4"]);
            var hr5 = Converter.ToFloat(Request["HeadRate5"]);
            var pr5 = Converter.ToFloat(Request["ProcessRate5"]);
            var ir5 = Converter.ToFloat(Request["InterestRate5"]);
            var depth = Converter.ToInt(Request["Depth"]);
            #endregion

            #region 数据校验
            bool isValid = true;
            int i = 0;
            if (string.IsNullOrEmpty(AgentName))
            {
                msg += (++i).ToString() + "、会员名不能为空!<br />";
                isValid = false;
            }
            if (string.IsNullOrEmpty(Account))
            {
                msg += (++i).ToString() + "、会员帐号不能为空!<br />";
                isValid = false;
            }
            else
            {
                using (APIDataDataContext db = APIDataContextProxy.APIDB)
                {
                    int count = db.TAgents.Count(t => t.Account == Account);
                    if (count > 0)
                    {
                        msg += (++i).ToString() + "、会员帐号已经存在!<br />";
                        isValid = false;
                    }
                }
            }

            if (!string.IsNullOrEmpty(TelePhone))
            {
                using (APIDataDataContext db = APIDataContextProxy.APIDB)
                {
                    int count = db.TAgents.Count(t => t.TelePhone == TelePhone);
                    if (count > 0)
                    {
                        msg += (++i).ToString() + "、联系方式已经存在!<br />";
                        isValid = false;
                    }
                }
            }
            if (!string.IsNullOrEmpty(Email))
            {
                using (APIDataDataContext db = APIDataContextProxy.APIDB)
                {
                    int count = db.TAgents.Count(t => t.Email == Email);
                    if (count > 0)
                    {
                        msg += (++i).ToString() + "、联系邮箱已经存在!<br />";
                        isValid = false;
                    }
                }
            }
            if (string.IsNullOrEmpty(IdCardNo))
            {
                msg += (++i).ToString() + "、身份证号不能为空!<br />";
                isValid = false;
            }
            if (string.IsNullOrEmpty(SavingsAccount))
            {
                msg += (++i).ToString() + "、银行卡号不能为空!<br />";
                isValid = false;
            }
            if (BankID == -1)
            {
                msg += (++i).ToString() + "、开户银行不能为空!<br />";
                isValid = false;
            }
            if (string.IsNullOrEmpty(CityCode))
            {
                msg += (++i).ToString() + "、开户行所在地不能为空!<br />";
                isValid = false;
            }
            if (string.IsNullOrEmpty(Branch))
            {
                msg += (++i).ToString() + "、银行支行名不能为空!<br />";
                isValid = false;
            }
            if (BankID == -1)
            {
                msg += (++i).ToString() + "、开户银行不能为空!<br />";
                isValid = false;
            }
            #endregion

            if (isValid)
            {
                APIDataDataContext db = APIDataContextProxy.APIDB;
                int cityId = (from c in db.TCities where c.CityCode == CityCode select c.ID).FirstOrDefault();
                TAgents t = new TAgents();
                t.AgentName = AgentName;
                t.Account = Account;
                t.TelePhone = TelePhone;
                t.Email = Email;
                t.Status = Status;
                t.CityID = cityId;
                t.Address = Address;
                t.DirectAgentID = DirectAgentID;
                t.OpenerID = OpenerID;
                t.OpenTime = Convert.ToDateTime(OpenTime);
                //t.LastLoginIP = LastLoginIP;
                t.IdCardNo = IdCardNo;
                t.BankID = BankID;
                t.SavingsAccount = SavingsAccount;
                t.AllowDevelopCustomers = Convert.ToBoolean(AllowDevelopCustomers);
                t.AllowDevelopAgents = Convert.ToBoolean(AllowDevelopAgents);
                t.GroupID = GroupID;
                t.PassWord = Account;
                t.SavingsName = savingsName;
                t.Branch = Branch;

                t.HeadRate1 = hr1;
                t.ProcessRate1 = pr1;
                t.InterestRate1 = ir1;
                t.HeadRate2 = hr2;
                t.ProcessRate2 = pr2;
                t.InterestRate2 = ir2;
                t.HeadRate3 = hr3;
                t.ProcessRate3 = pr3;
                t.InterestRate3 = ir3;
                t.HeadRate4 = hr4;
                t.ProcessRate4 = pr4;
                t.InterestRate4 = ir4;
                t.HeadRate5 = hr5;
                t.ProcessRate5 = pr5;
                t.InterestRate5 = ir5;
                t.Depth = depth;

                db.TAgents.InsertOnSubmit(t);
                db.SubmitChanges();

                TOperationLog OLog = new TOperationLog();
                OLog.BeforeValue = "";
                OLog.UpdateValue = ObjectToJson.ModelToJson(t);
                //写入操作日志
                OLog.UserID = Convert.ToInt32(Session["ID"]);
                OLog.UserType = 2;//0 用户 1 会员 2 员工
                OLog.CreateDate = DateTime.Now;
                OLog.PageName = "添加会员会员";
                Converter.InsertOperationLog(OLog);

                //存入日志
                id = Convert.ToInt32(Session["ID"]); //id
                Type = Session["Type"].ToString();  //类型
                msg = "添加会员成功";
                fruit = true;
                Converter.InsertLog(id, name, Type, msg, fruit);

                return Content("{result:'success',msg:'添加成功!'}");
            }
            else
            {
                //存入日志
                id = Convert.ToInt32(Session["ID"]); //id
                Type = Session["Type"].ToString();  //类型
                //msg = "添加会员失败";
                fruit = false;
                Converter.InsertLog(id, name, Type, "添加会员失败", fruit);
                return Content("{result:'fail',msg:'" + msg + "'}");
            }
        }
Example #17
0
        public ActionResult PostAgentGroupInfo()
        {
            int Id = 0;  //Id
            string name = ""; //登陆名
            string Type = "";  //type
            string msg = "";  //提示信息
            bool fruit = false;

            if (!Request.IsAjaxRequest())
                return Content("{result:'fail',msg:'会员不存在!'}");
            int id = Converter.ToInt(Request.Form["id"], 0);
            bool isValid = true;
            string errMsg = "";
            string gname = Converter.ToString(Request.Form["gname"]).Trim();
            if (gname == "")
            {
                errMsg += "分组名不能为空;";
                isValid = false;
            }
            //int cycle = Converter.ToInt(Request.Form["cycle"], 0);
            //if (cycle <= 0)
            //{
            //    errMsg += "结算周期不能为空;";
            //    isValid = false;
            //}
            //int sway = Converter.ToInt(Request.Form["sway"], 0);
            //if (sway <= 0)
            //{
            //    errMsg += "结算方式不能为空;";
            //    isValid = false;
            //}

            //float lev = 0f;
            //string leverage = Converter.ToString(Request.Form["leverage"]).Trim();
            //if (leverage == "")
            //{
            //    errMsg += "保证金杠杆不能为空;";
            //    isValid = false;
            //}
            //else if (!float.TryParse(leverage, out lev))
            //{
            //    errMsg += "保证金杠杆必须为数值;";
            //    isValid = false;
            //}

            //float ret = 0f;
            //string retrate = Converter.ToString(Request.Form["retrate"]).Trim();
            //if (retrate == "")
            //{
            //    errMsg += "返还费用税率不能为空;";
            //    isValid = false;
            //}
            //else if (!float.TryParse(retrate, out ret))
            //{
            //    errMsg += "返还费用税率必须为数值;";
            //    isValid = false;
            //}

            float prat = 0f;
            string prate = Converter.ToString(Request.Form["prate"]).Trim();
            if (prate == "")
            {
                errMsg += "加工费分成比率不能为空;";
                isValid = false;
            }
            else if (!float.TryParse(prate, out prat))
            {
                errMsg += "加工费分成比率必须为数值;";
                isValid = false;
            }

            float br = 0f;
            string brate = Converter.ToString(Request.Form["brate"]).Trim();
            if (brate == "")
            {
                errMsg += "头寸分成比率不能为空;";
                isValid = false;
            }
            else if (!float.TryParse(brate, out br))
            {
                errMsg += "头寸分成比率必须为数值;";
                isValid = false;
            }

            float nr = 0f;
            string nrate = Converter.ToString(Request.Form["nrate"]).Trim();
            //if (nrate == "")
            //{
            //    errMsg += "下级会员分成占比不能为空;";
            //    isValid = false;
            //}
            //else if (!float.TryParse(nrate, out nr))
            //{
            //    errMsg += "下级会员分成占比必须为数值;";
            //    isValid = false;
            //}

            float ir = 0f;
            string irate = Converter.ToString(Request.Form["irate"]).Trim();
            if (irate == "")
            {
                errMsg += "仓息分成比率不能为空;";
                isValid = false;
            }
            else if (!float.TryParse(irate, out ir))
            {
                errMsg += "仓息分成比率必须为数值;";
                isValid = false;
            }
            float fe = 0f;
            //string fee = Converter.ToString(Request.Form["fee"]).Trim();
            //if (fee == "")
            //{
            //    errMsg += "客户赠金不能为空;";
            //    isValid = false;
            //}
            //else if (!float.TryParse(fee, out fe))
            //{
            //    errMsg += "客户赠金必须为数值;";
            //    isValid = false;
            //}

            //int bway = Converter.ToInt(Request.Form["bway"], 0);
            //if (bway <= 0)
            //{
            //    errMsg += "赠金方式不能为空;";
            //    isValid = false;
            //}

            int asr = Converter.ToInt(Request.Form["asr"], 0);
            int ar = Converter.ToInt(Request.Form["ar"], 0);
            TOperationLog OLog = new TOperationLog();
            if (isValid == false)
                return Content("{result:'fail',msg:'" + errMsg + "'}");
            try
            {
                if (id <= 0)
                {
                    TAgentGroup group = new TAgentGroup();
                    group.GroupName = gname;
                    group.CreateTime = DateTime.Now;
                    //group.SettleWay = sway;
                    //group.SettleCycle = cycle;
                    //group.Leverage = Convert.ToDouble(lev.ToString("F4"));
                    //group.ReturnRate = Convert.ToDouble(ret.ToString("F4"));
                    group.ProcessRate = Convert.ToDouble(prat.ToString("F4"));
                    group.HeadRate = Convert.ToDouble(br.ToString("F4"));
                    group.InterestRate = Convert.ToDouble(ir.ToString("F4"));
                    group.NextRate = Convert.ToDouble(nr.ToString("F4"));
                    group.SubAgentFee = Convert.ToDouble(fe.ToString("F4"));
                    //group.BonusWay = bway;
                    group.AllowInspectionReport = ar == 0 ? false : true;
                    group.AllowSubAgentRead = asr == 0 ? false : true;
                    using (APIDataDataContext db = APIDataContextProxy.APIDB)
                    {
                        db.TAgentGroup.InsertOnSubmit(group);
                        db.SubmitChanges();

                        //记录操作日志
                        OLog.BeforeValue = "";
                        OLog.UpdateValue = ObjectToJson.ModelToJson(group);
                        OLog.UserID = Convert.ToInt32(Session["ID"]);
                        OLog.UserType = 2;//0 用户 1 会员 2 员工
                        OLog.CreateDate = DateTime.Now;
                        OLog.PageName = "新增会员分组";
                        Converter.InsertOperationLog(OLog);
                        //存入日志
                        Id = Convert.ToInt32(Session["ID"]); //id
                        Type = Session["Type"].ToString();  //类型
                        msg = "会员分组添加成功";
                        fruit = true;
                        Converter.InsertLog(Id, name, Type, msg, fruit);

                    }
                    return Content("{result:'success',msg:'会员分组添加成功!'}");
                }
                else
                {
                    using (APIDataDataContext db = APIDataContextProxy.APIDB)
                    {
                        var group = (from p in db.TAgentGroup where p.ID == id select p).FirstOrDefault();
                        OLog.BeforeValue = ObjectToJson.ModelToJson(group);
                        if (group == null)
                        {
                            return Content("{result:'fail',msg:'修改失败,分组不存在!'}");
                        }
                        group.GroupName = gname;
                        //group.SettleWay = sway;
                        //group.SettleCycle = cycle;
                        //group.Leverage = Convert.ToDouble(lev.ToString("F4"));
                        //group.ReturnRate = Convert.ToDouble(ret.ToString("F4"));
                        group.ProcessRate = Convert.ToDouble(prat.ToString("F4"));
                        group.HeadRate = Convert.ToDouble(br.ToString("F4"));
                        group.InterestRate = Convert.ToDouble(ir.ToString("F4"));
                        group.NextRate = Convert.ToDouble(nr.ToString("F4"));
                        group.SubAgentFee = Convert.ToDouble(fe.ToString("F4"));
                        //group.BonusWay = bway;
                        group.AllowInspectionReport = ar == 0 ? false : true;
                        group.AllowSubAgentRead = asr == 0 ? false : true;
                        db.SubmitChanges();

                        OLog.UpdateValue = ObjectToJson.ModelToJson(group);
                        OLog.UserID = Convert.ToInt32(Session["ID"]);
                        OLog.UserType = 2;//0 用户 1 会员 2 员工
                        OLog.CreateDate = DateTime.Now;
                        OLog.PageName = "修改会员分组";
                        Converter.InsertOperationLog(OLog);
                        //存入日志
                        Id = Convert.ToInt32(Session["ID"]); //id
                        Type = Session["Type"].ToString();  //类型
                        msg = "会员分组修改成功";
                        fruit = true;
                        Converter.InsertLog(Id, name, Type, msg, fruit);

                        return Content("{result:'success',msg:'修改成功!'}");
                    }
                }
                APIDataDataContext db2 = APIDataContextProxy.APIDB;
                string sql = "UPDATE TAgentGroup SET NextRate = " + nr.ToString("F4");
                db2.ExecuteCommand(sql);
                db2.SubmitChanges();

            }
            catch
            {
                //存入日志
                Id = Convert.ToInt32(Session["ID"]); //id
                Type = Session["Type"].ToString();  //类型
                msg = "会员分组修改失败";
                fruit = false;
                Converter.InsertLog(Id, name, Type, msg, fruit);

                return Content("{result:'fail',msg:'修改失败,出现未知异常!'}");
            }
        }
Example #18
0
        //删除员工分组
        public ActionResult DelGroup(int id)
        {
            if (id == 1)
            {
                return Json("超级管理员不能删除!");
            }
            APIDataDataContext db = APIDataContextProxy.APIDB;
            {
                int count = (from g in db.TStaffs where g.GroupID == id select g).Count();
                if (count > 0)
                {
                    return Json("该分组下有员工,不能删除");//该分组下有员工,不能删除
                }
                try
                {
                    var del = (from g in db.TStaffGroup where g.ID == id select g).FirstOrDefault();
                    db.TStaffGroup.DeleteOnSubmit(del);
                    db.SubmitChanges();

                    TOperationLog OLog = new TOperationLog();

                    OLog.BeforeValue = ObjectToJson.ModelToJson(del);
                    OLog.UpdateValue = "";
                    //写入操作日志
                    OLog.UserID = Convert.ToInt32(Session["ID"]);
                    OLog.UserType = 2;//0 用户 1 会员 2 员工
                    OLog.CreateDate = DateTime.Now;
                    OLog.PageName = "删除员工分组";
                    Converter.InsertOperationLog(OLog);
                    return Json(1);//删除成功
                }
                catch (Exception)
                {
                    return Json("服务器出现内部错误,删除失败!");//删除出现意外情况,删除失败
                }
            }
        }
Example #19
0
        public ActionResult PostTAnalsTs()
        {
            int id = 0;  //Id
            string name = ""; //登陆名
            string Type = "";  //type
            string msg = "";  //提示信息
            bool fruit = false;  //结果
            TOperationLog OLog = new TOperationLog();
            OLog.BeforeValue = "";

            if (!Request.IsAjaxRequest())
                return Content("{result:'fail',msg:'非法请求!'}");
            int Id = Converter.ToInt(Request.Form["Id"], 0);
            string title = Converter.ToString(Request.Form["Title"]).Trim();
            string body = Converter.ToString(Request.Form["MsgBody"]).Trim();
            string timer = Converter.ToString(Request.Form["timer"]).Trim();
            string date = Converter.ToString(Request.Form["sendtime"]).Trim();
            string errMsg = "";
            DateTime dt = DateTime.Now;
            if (title == "")
                errMsg += "标题不能为空;";
            if (body == "")
                errMsg += "正文不能为空;";
            if (timer == "1")
            {
                if (!DateTime.TryParse(date, out dt))
                    errMsg += "定时分析必须设置时间;";
                else if (DateTime.Now > dt)
                    errMsg += "您设置的时间已过期;";
            }
            if (errMsg != "")
            {
                return Content("{result:'fail',msg:'" + errMsg + "'}");
            }
            if (Id > 0)
            {
                try
                {
                    using (APIDataDataContext db = APIDataContextProxy.APIDB)
                    {
                        var arr = (from b in db.TAnalysis where b.ID == Id select b).FirstOrDefault();
                        OLog.BeforeValue = ObjectToJson.ModelToJson(arr);
                        arr.Title = title;
                        arr.MsgBody = body;
                        arr.SendTime = DateTime.Now;
                        if (timer=="1")
                        {
                            arr.SendTime = dt;
                        }

                        db.SubmitChanges();

                        //存入日志
                        id = Convert.ToInt32(Session["ID"]); //id
                        Type = Session["Type"].ToString();  //类型
                        msg = "修改分析成功";
                        fruit = true;
                        Converter.InsertLog(id, name, Type, msg, fruit);

                        OLog.UpdateValue = ObjectToJson.ModelToJson(arr);
                        //写入操作日志
                        OLog.UserID = Convert.ToInt32(Session["ID"]);
                        OLog.UserType = 2;//0 用户 1 会员 2 员工
                        OLog.CreateDate = DateTime.Now;
                        OLog.PageName = "修改分析";
                        Converter.InsertOperationLog(OLog);
                        return Content("{result:'success',msg:'分析修改成功!'}");
                    }
                }
                catch (Exception ex)
                {
                    //存入日志
                    id = Convert.ToInt32(Session["ID"]); //id
                    Type = Session["Type"].ToString();  //类型
                    msg = "修改分析失败";
                    fruit = false;
                    Converter.InsertLog(id, name, Type, msg, fruit);
                    return Content("{result:'fail',msg:'未知错误,分析修改失败!'}");
                }

            }
            else
            {
                try
                {
                    using (APIDataDataContext db = APIDataContextProxy.APIDB)
                    {
                        TAnalysis entity = new TAnalysis();
                        entity.Title = title;
                        entity.MsgBody = body;
                        entity.SendTime = DateTime.Now;
                        if (timer == "1")
                        {
                            entity.SendTime = dt;
                        }
                        entity.SenderID = Convert.ToInt32(Session["ID"]);
                        db.TAnalysis.InsertOnSubmit(entity);
                        db.SubmitChanges();

                        //存入日志
                        id = Convert.ToInt32(Session["ID"]); //id
                        Type = Session["Type"].ToString();  //类型
                        msg = "发布分析成功";
                        fruit = true;
                        Converter.InsertLog(id, name, Type, msg, fruit);

                        OLog.UpdateValue = ObjectToJson.ModelToJson(entity);
                        //写入操作日志
                        OLog.UserID = Convert.ToInt32(Session["ID"]);
                        OLog.UserType = 2;//0 用户 1 会员 2 员工
                        OLog.CreateDate = DateTime.Now;
                        OLog.PageName = "发布分析";
                        Converter.InsertOperationLog(OLog);

                        return Content("{result:'success',msg:'分析发布成功!'}");
                    }
                }
                catch (Exception ex)
                {
                    //存入日志
                    id = Convert.ToInt32(Session["ID"]); //id
                    Type = Session["Type"].ToString();  //类型
                    msg = "发布分析失败";
                    fruit = false;
                    Converter.InsertLog(id, name, Type, msg, fruit);
                    return Content("{result:'fail',msg:'未知错误,分析发送失败!'}");
                }

            }
        }
Example #20
0
        //修改员工分组
        public ActionResult UpdateGroup(int id, string groupName, string desc)
        {
            APIDataDataContext db = APIDataContextProxy.APIDB;
            {
                try
                {
                    TOperationLog OLog = new TOperationLog();
                    TStaffGroup group = (from g in db.TStaffGroup where g.ID == id select g).FirstOrDefault();
                    OLog.BeforeValue = ObjectToJson.ModelToJson(group);
                    if (group == null)
                    {
                        return Json(-1);//没有找到对应分组
                    }
                    group.GroupName = groupName;
                    group.Descriptions = desc;

                    db.SubmitChanges();

                    OLog.UpdateValue = ObjectToJson.ModelToJson(group);
                    //写入操作日志
                    OLog.UserID = Convert.ToInt32(Session["ID"]);
                    OLog.UserType = 2;//0 用户 1 会员 2 员工
                    OLog.CreateDate = DateTime.Now;
                    OLog.PageName = "修改员工分组";
                    Converter.InsertOperationLog(OLog);
                    return Json(group.ID);//修改成功
                }
                catch (Exception)
                {
                    return Json(0);//修改出现意外情况,删除失败
                }
            }
        }
Example #21
0
        /// <summary>
        /// 写入操作日志
        /// </summary>
        /// <param name="model"></param>
        public static void InsertOperationLog(TOperationLog model)
        {
            //记录登录IP
            model.IP = IPAddress;
            //后台为写死员工操作

            APIDataDataContext db = DBFactory.DB;
            db.TOperationLog.InsertOnSubmit(model);
            db.SubmitChanges();
        }
Example #22
0
        public ActionResult EditPositionPassword()
        {
            var password = Request["password"];

            var orderid = Converter.ToInt(Request["orderid"], 0);
            var types = Request["types"];//0保存 1删除 2平仓
            var OrderNum = Request["OrderNum"];
            var ProductID = Request["ProductID"];
            var TRealAccountsID = Converter.ToInt(Request["TRealAccountID"], 0);
            var Deal = Request["Deal"];
            var OrderCount = Request["OrderCount"];
            var OpenPrice = Request["OpenPrice"];
            var Loss = Request["Loss"];
            var OpenTime = Request["OpenTime"];
            var Profit = Request["Profit"];
            var NowPrice = Request["NowPrice"];
            var Deposit = Request["Deposit"];
            var UpdateTime = Request["UpdateTime"];

            APIDataDataContext db = APIDataContextProxy.APIDB;
            TOperationLog OLog = new TOperationLog();

            var user2 = (from c in db.TRealAccounts where c.ID == TRealAccountsID && c.PassWord == password select c).FirstOrDefault();

            if (user2 == null)
            {
                return Json(new { code = "0", msg = "客户密码不正确!" });
            }
            try
            {
                if (orderid > 0)
                {
                    var order = (from c in db.TOrders where c.ID == orderid select c).FirstOrDefault();
                    OLog.BeforeValue = ObjectToJson.ModelToJson(order);

                    OLog.UserID = Convert.ToInt32(Session["ID"]);
                    OLog.UserType = 2;//0 用户 1 会员 2 员工
                    OLog.CreateDate = DateTime.Now;

                    if (order != null)
                    {
                        if (types == "1")
                        {
                            #region 删除订单
                            db.TOrders.DeleteOnSubmit(order);
                            db.SubmitChanges();
                            OLog.UpdateValue = "";
                            //写入操作日志
                            OLog.PageName = "删除在手订单";
                            Converter.InsertOperationLog(OLog);
                            return Json(new { code = "1", msg = "提交成功!" });
                            #endregion

                        }
                        else if (types == "0")
                        {
                            #region 修改保存
                            order.ProductID = Converter.ToInt(ProductID, 0);
                            order.TRealAccountsID = Converter.ToInt(TRealAccountsID, 0);
                            order.Deal = Deal == "1" ? true : false;
                            order.OrderCount = Converter.ToInt(OrderCount, 0);
                            order.OpenPrice = Converter.ToFloat(OpenPrice, 0);
                            order.Loss = Converter.ToFloat(Loss, 0);
                            order.OpenTime = Convert.ToDateTime(OpenTime);
                            order.Profit = Converter.ToFloat(Profit, 0);
                            order.NowPrice = Converter.ToFloat(NowPrice, 0);
                            order.Deposit = Converter.ToFloat(Deposit, 0);
                            order.UpdateTime = Convert.ToDateTime(UpdateTime);
                            db.SubmitChanges();
                            OLog.UpdateValue = ObjectToJson.ModelToJson(order);
                            //写入操作日志
                            OLog.PageName = "修改在手订单";
                            Converter.InsertOperationLog(OLog);
                            return Json(new { code = "1", msg = "提交成功!" });
                            #endregion
                        }
                        else
                        {
                            #region 平仓
                            int OrderId = orderid;
                            var item = (from c in db.TOrders
                                        where c.ID == OrderId
                                        && c.OrderState == 1
                                        && c.OrderType == 1
                                        select c).FirstOrDefault();
                            if (item != null)
                            {
                                var product = (from c in db.TProducts
                                               join b in db.TLastClose on c.ProductCode equals b.ProductCode
                                               where c.ID == item.ProductID
                                               orderby c.ID
                                               select new
                                               {
                                                   c,
                                                   b.LastClose,
                                                   b.LastUpdateTime
                                               }).FirstOrDefault();
                                if (product != null)
                                {
                                    var Scale = Converter.ToFloat(product.c.Scale, 2);
                                    var nowdate = product.LastUpdateTime;
                                    #region 加工费
                                    double closedeposit = 0.0;   //加工费
                                    if (product.c.DepositType == 1)//固定
                                    {
                                        closedeposit = Converter.ToFloat(product.c.CloseDeposit, 0) * Converter.ToFloat(product.c.ContractNumber, 0) * Converter.ToFloat(item.OrderCount, 0);
                                    }
                                    else if (product.c.DepositType == 2)//浮动
                                    {
                                        if (item.Deal == false)
                                            closedeposit = 0.01 * Converter.ToFloat(product.c.CloseDeposit, 0) * (Converter.ToFloat(product.LastClose, 0)) * Converter.ToFloat(product.c.ContractNumber, 0) * Converter.ToFloat(item.OrderCount, 0);
                                        else
                                            closedeposit = 0.01 * Converter.ToFloat(product.c.CloseDeposit, 0) * (Converter.ToFloat(product.LastClose, 0) + Converter.ToFloat(product.c.Fixedly, 0)) * Converter.ToFloat(product.c.ContractNumber, 0) * Converter.ToFloat(item.OrderCount, 0);
                                    }
                                    closedeposit = Converter.ToFloat(closedeposit.ToString("F" + Scale), 0);
                                    #endregion
                                    item.Deposit = Converter.ToFloat((Converter.ToFloat(item.Deposit, 0) + closedeposit).ToString("F" + Scale), 0);
                                    double LastClose = 0.0;       //市场价 收盘价
                                    double Spread = 0.0;        //点数
                                    //计算盈亏
                                    if (item.Deal == false)//卖出
                                    {
                                        LastClose = Converter.ToFloat(product.LastClose, 0) + Converter.ToFloat(product.c.Fixedly, 0);
                                        Spread = Converter.ToFloat(item.OpenPrice, 0) - LastClose;
                                    }
                                    else if (item.Deal == true)//买入
                                    {
                                        LastClose = Converter.ToFloat(product.LastClose, 0);
                                        Spread = LastClose - Converter.ToFloat(item.OpenPrice, 0);
                                    }
                                    item.Spread = Converter.ToFloat(Spread.ToString("F" + Scale), 0);
                                    item.ProfitAndLoss = Converter.ToFloat((Converter.ToFloat(Spread * item.OrderCount, 0) * Converter.ToFloat(product.c.ContractNumber, 0)).ToString("F" + Scale), 0);
                                    item.NowPrice = Converter.ToFloat(LastClose.ToString("F" + Scale), 0);
                                    item.NetProfit = Converter.ToFloat((Converter.ToFloat(item.ProfitAndLoss, 0) - Converter.ToFloat(item.Deposit, 0) - Converter.ToFloat(item.Interest, 0)).ToString("F" + Scale), 0);
                                    item.UpdateTime = nowdate;
                                    item.OrderState = 2;
                                    item.OrderType = 2;
                                    item.CloseType = "授权平仓";
                                    var user = (from c in db.TRealAccounts where c.ID == item.TRealAccountsID select c).FirstOrDefault();

                                    try
                                    {
                                        var agent = (from c in db.TAgents
                                                     join b in db.TAgentGroup on c.GroupID equals b.ID
                                                     where c.ID == user.AgendID
                                                     select new
                                                     {
                                                         c.ID,
                                                         c.DirectAgentID,
                                                         c.Depth,
                                                         c.HeadRate1,
                                                         c.ProcessRate1,
                                                         c.InterestRate1,
                                                         c.HeadRate2,
                                                         c.ProcessRate2,
                                                         c.InterestRate2,
                                                         c.HeadRate3,
                                                         c.ProcessRate3,
                                                         c.InterestRate3,
                                                         c.HeadRate4,
                                                         c.ProcessRate4,
                                                         c.InterestRate4,
                                                         c.HeadRate5,
                                                         c.ProcessRate5,
                                                         c.InterestRate5,
                                                         GID = b.ID,
                                                         b.GroupName,
                                                         b.ProcessRate,
                                                         b.HeadRate,
                                                         b.InterestRate,
                                                         b.NextRate
                                                     }).FirstOrDefault();

                                        #region 分成
                                        if (agent != null)
                                        {
                                            //查询客户所属会员的分成
                                            double HeadRate = Convert.ToDouble(Converter.ToFloat(agent.HeadRate, 0).ToString("F4")) * 0.01;
                                            double ProcessRate = Convert.ToDouble(Converter.ToFloat(agent.ProcessRate, 0).ToString("F4")) * 0.01;
                                            double InterestRate = Convert.ToDouble(Converter.ToFloat(agent.InterestRate, 0).ToString("F4")) * 0.01;
                                            //计算分成
                                            double HeadInfo = Convert.ToDouble((Converter.ToFloat(item.ProfitAndLoss, 0) * HeadRate * -1).ToString("F4"));
                                            double ProcessInfo = Convert.ToDouble((Converter.ToFloat(item.Deposit, 0) * ProcessRate).ToString("F4"));
                                            double InterestInfo = Convert.ToDouble((Converter.ToFloat(item.Interest, 0) * InterestRate).ToString("F4"));

                                            TAgentRate tar = new TAgentRate();
                                            tar.HeadRate = HeadInfo.ToString();
                                            tar.ProcessRate = ProcessInfo.ToString();
                                            tar.InterestRate = InterestInfo.ToString();
                                            tar.AllRate = (HeadInfo + ProcessInfo + InterestInfo).ToString();
                                            tar.NextHeadRate = "0";
                                            tar.NextProcessRate = "0";
                                            tar.NextInterestRate = "0";
                                            tar.NextAllRate = "0";
                                            tar.Date = DateTime.Now;
                                            tar.TAgentId = agent.ID;
                                            tar.TOrderId = item.ID;

                                            IList<TAgentRate> tarlist = new List<TAgentRate>();
                                            int depth = agent.Depth;//深度
                                            if (depth > 6)
                                                depth = 6;
                                            var ag = (from c in db.TAgents where c.ID == agent.ID select c).FirstOrDefault();
                                            var age = ag;
                                            for (int i = 1; i < depth; i++)
                                            {
                                                if (i == 1)
                                                {
                                                    //会员的分成
                                                    HeadRate = Convert.ToDouble(Converter.ToFloat(age.HeadRate1, 0).ToString("F4")) * 0.01;
                                                    ProcessRate = Convert.ToDouble(Converter.ToFloat(age.ProcessRate1, 0).ToString("F4")) * 0.01;
                                                    InterestRate = Convert.ToDouble(Converter.ToFloat(age.ProcessRate1, 0).ToString("F4")) * 0.01;
                                                    //计算分成
                                                    var HeadInfo_ = Convert.ToDouble((Converter.ToFloat(item.ProfitAndLoss, 0) * HeadRate * -1).ToString("F4"));
                                                    var ProcessInfo_ = Convert.ToDouble((Converter.ToFloat(item.Deposit, 0) * ProcessRate).ToString("F4"));
                                                    var InterestInfo_ = Convert.ToDouble((Converter.ToFloat(item.Interest, 0) * InterestRate).ToString("F4"));

                                                    TAgentRate tars = new TAgentRate();
                                                    tars.HeadRate = "0";
                                                    tars.ProcessRate = "0";
                                                    tars.InterestRate = "0";
                                                    tars.AllRate = "0";
                                                    tars.NextHeadRate = HeadInfo_.ToString();
                                                    tars.NextProcessRate = ProcessInfo_.ToString();
                                                    tars.NextInterestRate = InterestInfo_.ToString();
                                                    tars.NextAllRate = (HeadInfo_ + ProcessInfo_ + InterestInfo_).ToString();
                                                    tars.Date = DateTime.Now;
                                                    tars.TAgentId = ag.DirectAgentID;
                                                    tars.TOrderId = item.ID;
                                                    tarlist.Add(tars);
                                                    tar.HeadRate = (Convert.ToDouble(tar.HeadRate) - HeadInfo_).ToString("F4");
                                                    tar.ProcessRate = (Convert.ToDouble(tar.ProcessRate) - ProcessInfo_).ToString("F4");
                                                    tar.InterestRate = (Convert.ToDouble(tar.InterestRate) - InterestInfo_).ToString("F4");
                                                    tar.AllRate = (Convert.ToDouble(tar.AllRate) - (HeadInfo_ + ProcessInfo_ + InterestInfo_)).ToString("F4");
                                                }
                                                else if (i == 2)
                                                {
                                                    //会员的分成
                                                    HeadRate = Convert.ToDouble(Converter.ToFloat(age.HeadRate2, 0).ToString("F4")) * 0.01;
                                                    ProcessRate = Convert.ToDouble(Converter.ToFloat(age.ProcessRate2, 0).ToString("F4")) * 0.01;
                                                    InterestRate = Convert.ToDouble(Converter.ToFloat(age.ProcessRate2, 0).ToString("F4")) * 0.01;
                                                    //计算分成
                                                    var HeadInfo_ = Convert.ToDouble((Converter.ToFloat(item.ProfitAndLoss, 0) * HeadRate * -1).ToString("F4"));
                                                    var ProcessInfo_ = Convert.ToDouble((Converter.ToFloat(item.Deposit, 0) * ProcessRate).ToString("F4"));
                                                    var InterestInfo_ = Convert.ToDouble((Converter.ToFloat(item.Interest, 0) * InterestRate).ToString("F4"));

                                                    TAgentRate tars = new TAgentRate();
                                                    tars.HeadRate = "0";
                                                    tars.ProcessRate = "0";
                                                    tars.InterestRate = "0";
                                                    tars.AllRate = "0";
                                                    tars.NextHeadRate = HeadInfo_.ToString();
                                                    tars.NextProcessRate = ProcessInfo_.ToString();
                                                    tars.NextInterestRate = InterestInfo_.ToString();
                                                    tars.NextAllRate = (HeadInfo_ + ProcessInfo_ + InterestInfo_).ToString();
                                                    tars.Date = DateTime.Now;
                                                    tars.TAgentId = ag.DirectAgentID;
                                                    tars.TOrderId = item.ID;
                                                    tarlist.Add(tars);
                                                    tar.HeadRate = (Convert.ToDouble(tar.HeadRate) - HeadInfo_).ToString("F4");
                                                    tar.ProcessRate = (Convert.ToDouble(tar.ProcessRate) - ProcessInfo_).ToString("F4");
                                                    tar.InterestRate = (Convert.ToDouble(tar.InterestRate) - InterestInfo_).ToString("F4");
                                                    tar.AllRate = (Convert.ToDouble(tar.AllRate) - (HeadInfo_ + ProcessInfo_ + InterestInfo_)).ToString("F4");
                                                }
                                                else if (i == 3)
                                                {
                                                    //会员的分成
                                                    HeadRate = Convert.ToDouble(Converter.ToFloat(age.HeadRate3, 0).ToString("F4")) * 0.01;
                                                    ProcessRate = Convert.ToDouble(Converter.ToFloat(age.ProcessRate3, 0).ToString("F4")) * 0.01;
                                                    InterestRate = Convert.ToDouble(Converter.ToFloat(age.ProcessRate3, 0).ToString("F4")) * 0.01;
                                                    //计算分成
                                                    var HeadInfo_ = Convert.ToDouble((Converter.ToFloat(item.ProfitAndLoss, 0) * HeadRate * -1).ToString("F4"));
                                                    var ProcessInfo_ = Convert.ToDouble((Converter.ToFloat(item.Deposit, 0) * ProcessRate).ToString("F4"));
                                                    var InterestInfo_ = Convert.ToDouble((Converter.ToFloat(item.Interest, 0) * InterestRate).ToString("F4"));

                                                    TAgentRate tars = new TAgentRate();
                                                    tars.HeadRate = "0";
                                                    tars.ProcessRate = "0";
                                                    tars.InterestRate = "0";
                                                    tars.AllRate = "0";
                                                    tars.NextHeadRate = HeadInfo_.ToString();
                                                    tars.NextProcessRate = ProcessInfo_.ToString();
                                                    tars.NextInterestRate = InterestInfo_.ToString();
                                                    tars.NextAllRate = (HeadInfo_ + ProcessInfo_ + InterestInfo_).ToString();
                                                    tars.Date = DateTime.Now;
                                                    tars.TAgentId = ag.DirectAgentID;
                                                    tars.TOrderId = item.ID;
                                                    tarlist.Add(tars);
                                                    tar.HeadRate = (Convert.ToDouble(tar.HeadRate) - HeadInfo_).ToString("F4");
                                                    tar.ProcessRate = (Convert.ToDouble(tar.ProcessRate) - ProcessInfo_).ToString("F4");
                                                    tar.InterestRate = (Convert.ToDouble(tar.InterestRate) - InterestInfo_).ToString("F4");
                                                    tar.AllRate = (Convert.ToDouble(tar.AllRate) - (HeadInfo_ + ProcessInfo_ + InterestInfo_)).ToString("F4");
                                                }
                                                else if (i == 4)
                                                {
                                                    //会员的分成
                                                    HeadRate = Convert.ToDouble(Converter.ToFloat(age.HeadRate4, 0).ToString("F4")) * 0.01;
                                                    ProcessRate = Convert.ToDouble(Converter.ToFloat(age.ProcessRate4, 0).ToString("F4")) * 0.01;
                                                    InterestRate = Convert.ToDouble(Converter.ToFloat(age.ProcessRate4, 0).ToString("F4")) * 0.01;
                                                    //计算分成
                                                    var HeadInfo_ = Convert.ToDouble((Converter.ToFloat(item.ProfitAndLoss, 0) * HeadRate * -1).ToString("F4"));
                                                    var ProcessInfo_ = Convert.ToDouble((Converter.ToFloat(item.Deposit, 0) * ProcessRate).ToString("F4"));
                                                    var InterestInfo_ = Convert.ToDouble((Converter.ToFloat(item.Interest, 0) * InterestRate).ToString("F4"));

                                                    TAgentRate tars = new TAgentRate();
                                                    tars.HeadRate = "0";
                                                    tars.ProcessRate = "0";
                                                    tars.InterestRate = "0";
                                                    tars.AllRate = "0";
                                                    tars.NextHeadRate = HeadInfo_.ToString();
                                                    tars.NextProcessRate = ProcessInfo_.ToString();
                                                    tars.NextInterestRate = InterestInfo_.ToString();
                                                    tars.NextAllRate = (HeadInfo_ + ProcessInfo_ + InterestInfo_).ToString();
                                                    tars.Date = DateTime.Now;
                                                    tars.TAgentId = ag.DirectAgentID;
                                                    tars.TOrderId = item.ID;
                                                    tarlist.Add(tars);
                                                    tar.HeadRate = (Convert.ToDouble(tar.HeadRate) - HeadInfo_).ToString("F4");
                                                    tar.ProcessRate = (Convert.ToDouble(tar.ProcessRate) - ProcessInfo_).ToString("F4");
                                                    tar.InterestRate = (Convert.ToDouble(tar.InterestRate) - InterestInfo_).ToString("F4");
                                                    tar.AllRate = (Convert.ToDouble(tar.AllRate) - (HeadInfo_ + ProcessInfo_ + InterestInfo_)).ToString("F4");
                                                }
                                                else if (i == 5)
                                                {
                                                    //会员的分成
                                                    HeadRate = Convert.ToDouble(Converter.ToFloat(age.HeadRate5, 0).ToString("F4")) * 0.01;
                                                    ProcessRate = Convert.ToDouble(Converter.ToFloat(age.ProcessRate5, 0).ToString("F4")) * 0.01;
                                                    InterestRate = Convert.ToDouble(Converter.ToFloat(age.ProcessRate5, 0).ToString("F4")) * 0.01;
                                                    //计算分成
                                                    var HeadInfo_ = Convert.ToDouble((Converter.ToFloat(item.ProfitAndLoss, 0) * HeadRate * -1).ToString("F4"));
                                                    var ProcessInfo_ = Convert.ToDouble((Converter.ToFloat(item.Deposit, 0) * ProcessRate).ToString("F4"));
                                                    var InterestInfo_ = Convert.ToDouble((Converter.ToFloat(item.Interest, 0) * InterestRate).ToString("F4"));

                                                    TAgentRate tars = new TAgentRate();
                                                    tars.HeadRate = "0";
                                                    tars.ProcessRate = "0";
                                                    tars.InterestRate = "0";
                                                    tars.AllRate = "0";
                                                    tars.NextHeadRate = HeadInfo_.ToString();
                                                    tars.NextProcessRate = ProcessInfo_.ToString();
                                                    tars.NextInterestRate = InterestInfo_.ToString();
                                                    tars.NextAllRate = (HeadInfo_ + ProcessInfo_ + InterestInfo_).ToString();
                                                    tars.Date = DateTime.Now;
                                                    tars.TAgentId = ag.DirectAgentID;
                                                    tars.TOrderId = item.ID;
                                                    tarlist.Add(tars);
                                                    tar.HeadRate = (Convert.ToDouble(tar.HeadRate) - HeadInfo_).ToString("F4");
                                                    tar.ProcessRate = (Convert.ToDouble(tar.ProcessRate) - ProcessInfo_).ToString("F4");
                                                    tar.InterestRate = (Convert.ToDouble(tar.InterestRate) - InterestInfo_).ToString("F4");
                                                    tar.AllRate = (Convert.ToDouble(tar.AllRate) - (HeadInfo_ + ProcessInfo_ + InterestInfo_)).ToString("F4");
                                                }
                                                ag = (from c in db.TAgents where c.ID == ag.DirectAgentID select c).FirstOrDefault();
                                            }
                                            tarlist.Add(tar);
                                            db.TAgentRate.InsertAllOnSubmit(tarlist);
                                            db.SubmitChanges();

                                            //AgentRate ar = new AgentRate();
                                            //ar.Id = agent.ID;
                                            //ar.DirectAgentID = Converter.ToInt(agent.DirectAgentID, 0);
                                            //ar.Groupid = agent.GID;
                                            //ar.Num = 0;
                                            //ar.HeadInfo = HeadInfo;
                                            //ar.ProcessInfo = ProcessInfo;
                                            //ar.InterestInfo = InterestInfo;
                                            //ar.NextheadInfo = HeadInfo;
                                            //ar.NextprocessInfo = ProcessInfo;
                                            //ar.NextinterestInfo = InterestInfo;
                                            //if (ar.DirectAgentID > 0)
                                            //{
                                            //    Converter.GetAgent(ar, ar, item.ID);
                                            //}
                                            //ar.HeadInfo = ar.NextheadInfo;
                                            //ar.ProcessInfo = ar.NextprocessInfo;
                                            //ar.InterestInfo = ar.NextinterestInfo;
                                            //ar.NextheadInfo = 0;
                                            //ar.NextprocessInfo = 0;
                                            //ar.NextinterestInfo = 0;

                                            //APIDataDataContext db2 = ConnectionHelper.Db;
                                            //{
                                            //    TAgentRate tar = new TAgentRate();
                                            //    tar.HeadRate = ar.HeadInfo.ToString();
                                            //    tar.ProcessRate = ar.ProcessInfo.ToString();
                                            //    tar.InterestRate = ar.InterestInfo.ToString();
                                            //    tar.AllRate = (ar.HeadInfo + ar.ProcessInfo + ar.InterestInfo).ToString();
                                            //    tar.NextHeadRate = ar.NextheadInfo.ToString();
                                            //    tar.NextProcessRate = ar.NextprocessInfo.ToString();
                                            //    tar.NextInterestRate = ar.NextinterestInfo.ToString();
                                            //    tar.NextAllRate = (ar.NextheadInfo + ar.NextprocessInfo + ar.NextinterestInfo).ToString();
                                            //    tar.Date = DateTime.Now;
                                            //    tar.TAgentId = agent.ID;
                                            //    tar.TOrderId = item.ID;
                                            //    db2.TAgentRate.InsertOnSubmit(tar);
                                            //    db2.SubmitChanges();
                                            //}
                                        }
                                        #endregion
                                    }
                                    catch
                                    {
                                    }

                                    #region 资金记录
                                    TAccountMoney tam = new TAccountMoney();
                                    tam.MoneyOrderNum = DateTime.Now.ToString("yyyyMMddHHmmssfff");
                                    tam.RealAccountId = Converter.ToInt(item.TRealAccountsID, 0);
                                    tam.TypeId = 4;
                                    tam.OriginalMoney = user.AccountMoney;
                                    tam.CreateMoney = item.ProfitAndLoss;
                                    tam.NowMoney = user.AccountMoney + item.ProfitAndLoss;
                                    if (tam.NowMoney < 0)
                                    {
                                        tam.NowMoney = 0;
                                    }
                                    tam.CreateTime = nowdate;
                                    tam.UpDateTime = nowdate;
                                    tam.Status = 2;
                                    tam.TOrderId = item.ID;
                                    db.TAccountMoney.InsertOnSubmit(tam);

                                    TAccountMoney tams = new TAccountMoney();
                                    tams.MoneyOrderNum = DateTime.Now.ToString("yyyyMMddHHmmssfff");
                                    tams.RealAccountId = Converter.ToInt(item.TRealAccountsID, 0);
                                    tams.TypeId = 5;
                                    tams.OriginalMoney = tam.NowMoney;
                                    tams.CreateMoney = item.Deposit;
                                    tams.NowMoney = tam.NowMoney - item.Deposit;
                                    if (tams.NowMoney < 0)
                                    {
                                        tams.NowMoney = 0;
                                    }
                                    tams.CreateTime = nowdate;
                                    tams.UpDateTime = nowdate;
                                    tams.Status = 2;
                                    tams.TOrderId = item.ID;
                                    db.TAccountMoney.InsertOnSubmit(tams);

                                    #endregion
                                    user.AccountMoney = user.AccountMoney + item.ProfitAndLoss - item.Deposit;
                                    if (user.AccountMoney < 0)
                                    {
                                        user.AccountMoney = 0;
                                    }
                                    db.SubmitChanges();
                                    OLog.UpdateValue = ObjectToJson.ModelToJson(order);
                                    //写入操作日志
                                    OLog.PageName = "平仓";
                                    Converter.InsertOperationLog(OLog);
                                    return Json(new { code = "1", msg = "提交成功!" });
                                }
                                else
                                {
                                    return Json(new { code = "0", msg = "订单id不正确!" });
                                }
                            }
                            else
                            {
                                return Json(new { code = "0", msg = "订单id不正确!" });
                            }
                            #endregion
                        }
                    }
                    else
                    {
                        return Json(new { code = "0", msg = "提交失败请稍后在试!" });
                    }
                }
                else
                {
                    //添加
                    #region 添加
                    TOrders to = new TOrders();
                    to.OrderNum = DateTime.Now.ToString("yyyyMMddHHmmssfff");
                    to.ProductID = Converter.ToInt(ProductID, 0);
                    to.TRealAccountsID = TRealAccountsID;
                    to.Deal = Deal == "1" ? true : false;
                    to.OrderCount = Converter.ToInt(OrderCount, 0);
                    to.OpenPrice = Converter.ToFloat(OpenPrice, 0);
                    to.Profit = Converter.ToFloat(Profit, 0);
                    to.Loss = Converter.ToFloat(Loss, 0);
                    to.NowPrice = Converter.ToFloat(NowPrice, 0);
                    to.Deposit = Converter.ToFloat(Deposit, 0);
                    to.Interest = 0;
                    double nowbaozhengjin = 0;
                    var product = (from c in db.TProducts where c.ID == Converter.ToInt(ProductID, 0) select c).FirstOrDefault();
                    int OccupyFundsType = product.OccupyFundsType.Value;    //保证金方式(每单必须有的保证金) 1固定(每笔统一价) 2浮动(按照交易金额的百分比来算)
                    double OccupyFunds = Converter.ToFloat(product.OccupyFunds, 0);         //保证金   固定(固定值*手数)   浮动(开仓价*固定值*手数)
                    if (OccupyFundsType == 1)
                        nowbaozhengjin = OccupyFunds * product.ContractNumber.Value * Converter.ToInt(OrderCount, 0);
                    else
                        nowbaozhengjin = 0.01 * OccupyFunds * product.ContractNumber.Value * Converter.ToFloat(NowPrice, 0) * Converter.ToInt(OrderCount, 0);
                    to.OccupyFunds = nowbaozhengjin;
                    to.OpenTime = Convert.ToDateTime(OpenTime);
                    to.UpdateTime = DateTime.Now;
                    try
                    {
                        to.OperatorIP = GetUserIp;
                    }
                    catch
                    {
                        return Json(new { code = "0", msg = "服务器内部错误!" });
                    }
                    to.OrderState = 1;
                    to.OrderType = 1;
                    to.EntrustType = 0;
                    db.TOrders.InsertOnSubmit(to);
                    db.SubmitChanges();
                    return Json(new { code = "1", msg = "提交成功!" });
                    #endregion
                }
            }
            catch
            {
                return Json(new { code = "0", msg = "服务器内部错误!" });
            }
        }
Example #23
0
        /// <summary>
        /// 删除员工
        /// </summary>
        /// <returns></returns>
        public ActionResult DeleteStaff()
        {
            int id = 0;  //Id
            string name = ""; //登陆名
            string Type = "";  //type
            string msg = "";  //提示信息
            bool fruit = false;  //结果
            TOperationLog OLog = new TOperationLog();

            APIDataDataContext db = APIDataContextProxy.APIDB;
            int Id = Converter.ToInt(Request["Id"], 0);
            var arr = (from b in db.TStaffs where b.ID == Id select b).FirstOrDefault();
            if (arr != null)
            {
                try
                {
                    db.TStaffs.DeleteOnSubmit(arr);
                    db.SubmitChanges();
                    //存入日志
                    id = Convert.ToInt32(Session["ID"]); //id
                    Type = Session["Type"].ToString();  //类型
                    msg = "删除用户成功";
                    fruit = true;
                    Converter.InsertLog(id, name, Type, msg, fruit);

                    OLog.BeforeValue = ObjectToJson.ModelToJson(arr);
                    OLog.UpdateValue = "";
                    //写入操作日志
                    OLog.UserID = Convert.ToInt32(Session["ID"]);
                    OLog.UserType = 2;//0 用户 1 会员 2 员工
                    OLog.CreateDate = DateTime.Now;
                    OLog.PageName = "删除模拟账户";
                    Converter.InsertOperationLog(OLog);

                    return Content("true");
                }
                catch
                {
                    //存入日志
                    id = Convert.ToInt32(Session["ID"]); //id
                    Type = Session["Type"].ToString();  //类型
                    msg = "删除用户失败";
                    fruit = false;
                    Converter.InsertLog(id, name, Type, msg, fruit);
                    return Content("删除失败");

                }
            }
            else
            {
                //存入日志
                id = Convert.ToInt32(Session["ID"]); //id
                Type = Session["Type"].ToString();  //类型
                msg = "删除用户失败";
                fruit = false;
                Converter.InsertLog(id, name, Type, msg, fruit);
                return Content("传入的参数不正确");
            }
        }
Example #24
0
        /// <summary>
        /// 处理提款申请结果
        /// </summary>
        /// <returns></returns>
        public ActionResult ApplyforResult(int orderId, int bankStatus, int? platformStatus, int? examine)
        {
            using (APIDataDataContext db = APIDataContextProxy.APIDB)
            {
                var res = "1";
                try
                {
                    //调用出金接口
                    Tranx tranx = new Tranx();
                    TAccountMoney ta = db.TAccountMoney.Where(s => s.Id == orderId).FirstOrDefault();

                    TOperationLog OLog = new TOperationLog();
                    bool isTrue = false;
                    OLog.BeforeValue = ObjectToJson.ModelToJson(ta);
                    if (bankStatus == -1 || bankStatus == -2)
                    {
                        OLog.PageName = bankStatus == -1 ? "确认出金成功" : "确认出金失败";
                    }
                    if (ta.AgentId == null)
                    {
                        #region 用户出金
                        switch (bankStatus)
                        {
                            case -1://确认出金成功
                                TRealAccounts tr = db.TRealAccounts.Where(t => t.ID == ta.RealAccountId).FirstOrDefault();
                                var linq = db.TOrders.Where(o => o.TRealAccountsID == ta.RealAccountId && o.OrderType == 1 && o.OrderState == 1);
                                double NetProfit = 0.0;
                                if (linq.Count() > 0)
                                {
                                    NetProfit = db.TOrders.Where(o => o.TRealAccountsID == ta.RealAccountId && o.OrderType == 1 && o.OrderState == 1).Sum(p => p.NetProfit.Value);
                                }
                                if ((NetProfit + tr.AccountMoney) < ta.CreateMoney)
                                {
                                    res = "余额不足!";//余额不足
                                }
                                else if (ta.Status > 1)
                                {
                                    res = "订单状态错误!";
                                }
                                else
                                {
                                    //调用出金接口
                                    TRealAccounts account = db.TRealAccounts.Where(a => a.ID == ta.RealAccountId.Value).FirstOrDefault();
                                    if (account != null)
                                    {
                                        RequestResult result = tranx.tranxTestMethod(account.Name, account.SavingsAccount, "PERSONAL", (ta.CreateMoney * 100).ToString(), db.TBanks.Where(b => b.Id == account.BankID).FirstOrDefault().BankName + account.Branch, "");
                                        if (!result.IsSuccess)
                                        {
                                            return Json(0);
                                        }
                                    }
                                    else
                                    {
                                        return Json(0);//用户不存在
                                    }
                                    ta.BankState = 1;
                                    ta.PlatformState = 1;
                                    ta.Examine = 1;
                                    ta.Status = 2;
                                    tr.AccountMoney = tr.AccountMoney - ta.CreateMoney;
                                }
                                break;
                            case -2://确认出金失败
                                ta.BankState = 2;
                                ta.PlatformState = 2;
                                ta.Examine = 2;
                                ta.Status = 3;
                                break;
                            default://提交处理其他
                                ta.BankState = bankStatus;
                                ta.PlatformState = platformStatus;
                                ta.Examine = examine;
                                if (examine == 0)
                                {
                                    TRealAccounts trr = db.TRealAccounts.Where(t => t.ID == ta.RealAccountId).FirstOrDefault();
                                    TBanks tb = db.TBanks.Where(b => b.Id == trr.BankID).FirstOrDefault();
                                    res = Converter.SetMoneyOrder(orderId.ToString(), trr.Name, ta.AccountNo, Converter.ToInt(ta.CreateMoney), ta.BankName, tb.Code);
                                }
                                break;
                        }
                        #endregion
                    }
                    else
                    {
                        #region 会员出金
                        switch (bankStatus)
                        {
                            case -1://确认出金成功
                                //TRealAccounts tr = db.TRealAccounts.Where(t => t.ID == ta.RealAccountId).FirstOrDefault();
                                TAgents tg = db.TAgents.Where(t => t.ID == ta.AgentId).FirstOrDefault();
                                var linq = db.TOrders.Where(o => o.TRealAccountsID == ta.RealAccountId && o.OrderType == 1 && o.OrderState == 1);
                                double NetProfit = 0.0;
                                if (linq.Count() > 0)
                                {
                                    NetProfit = db.TOrders.Where(o => o.TRealAccountsID == ta.RealAccountId && o.OrderType == 1 && o.OrderState == 1).Sum(p => p.NetProfit.Value);
                                }
                                if ((NetProfit + tg.AccountMoney) < ta.CreateMoney)
                                {
                                    res = "余额不足!";//余额不足
                                }
                                else if (ta.Status > 1)
                                {
                                    res = "订单状态错误!";
                                }
                                else
                                {
                                    //调用出金接口
                                    TAgents agent = db.TAgents.Where(a => a.ID == ta.AgentId.Value).FirstOrDefault();
                                    if (agent != null)
                                    {
                                        RequestResult result = tranx.tranxTestMethod(agent.SavingsName, agent.SavingsAccount, "PERSONAL", (ta.CreateMoney * 100).ToString(), db.TBanks.Where(b => b.Id == agent.BankID).FirstOrDefault().BankName + agent.Branch, "");
                                        if (!result.IsSuccess)
                                        {
                                            return Json(0);
                                        }
                                    }
                                    else
                                    {
                                        return Json(0);//会员不存在
                                    }
                                    isTrue = true;
                                    ta.BankState = 1;
                                    ta.PlatformState = 1;
                                    ta.Examine = 1;
                                    ta.Status = 2;
                                    tg.AccountMoney = ((double)tg.AccountMoney - (double)ta.CreateMoney);
                                }
                                break;
                            case -2://确认出金失败
                                ta.BankState = 2;
                                ta.PlatformState = 2;
                                ta.Examine = 2;
                                ta.Status = 3;
                                break;
                            default://提交处理其他
                                ta.BankState = bankStatus;
                                ta.PlatformState = platformStatus;
                                ta.Examine = examine;
                                if (examine == 0)
                                {
                                    TRealAccounts trr = db.TRealAccounts.Where(t => t.ID == ta.RealAccountId).FirstOrDefault();
                                    TBanks tb = db.TBanks.Where(b => b.Id == trr.BankID).FirstOrDefault();
                                    res = Converter.SetMoneyOrder(orderId.ToString(), trr.Name, ta.AccountNo, Converter.ToInt(ta.CreateMoney), ta.BankName, tb.Code);
                                }
                                break;
                        }
                        #endregion
                    }

                    db.SubmitChanges();
                    if (isTrue)
                    {
                        OLog.UpdateValue = ObjectToJson.ModelToJson(ta);
                        //写入操作日志
                        OLog.UserID = Convert.ToInt32(Session["ID"]);
                        OLog.UserType = 2;//0 用户 1 会员 2 员工
                        OLog.CreateDate = DateTime.Now;
                        Converter.InsertOperationLog(OLog);
                    }
                }
                catch
                {
                    res = "0";
                }
                return Json(res);
            }
        }
Example #25
0
        public ActionResult AddStaffs()
        {
            int id = 0;  //Id
            string Name = ""; //登陆名
            string Type = "";  //type
            string msg = "";  //提示信息
            bool fruit = false;  //结果
            TOperationLog OLog = new TOperationLog();
            OLog.BeforeValue = "";
            var name = Converter.ToString(Request["StaffName"], "");
            var Account = Converter.ToString(Request["Account"], "");
            var GroupID = Converter.ToInt(Request["GroupID"], -1);
            var TelePhone = Converter.ToString(Request["TelePhone"], "");
            var Email = Converter.ToString(Request["Email"], "");
            var Status = Converter.ToInt(Request["Status"], -1);
            var DepartmentID = Converter.ToInt(Request["DepartmentID"], -1);
            //var password = Converter.ToString(Request["Password"]);
            var OpenerID = 1;
            var LastUpdateTime = DateTime.Now;
            var LastLoginIP = "192.168.1.2";
            string returnMsg = string.Empty;

            APIDataDataContext db = APIDataContextProxy.APIDB;

            #region 参数校验
            bool isStop = false;
            int i = 0;
            if (string.IsNullOrEmpty(name))
            {
                returnMsg += (++i).ToString() + "、员工名称不能为空。<br />";
                isStop = true;
            }
            if (string.IsNullOrEmpty(Account))
            {
                returnMsg += (++i).ToString() + "、员工帐号不能为空。<br />";
                isStop = true;
            }
            else
            {
                int count = db.TStaffs.Count(t => t.Account == Account);
                if (count > 0)
                {
                    returnMsg += (++i).ToString() + "、员工帐号已经存在。<br />";
                    isStop = true;
                }
            }
            //if (string.IsNullOrEmpty(password))
            //{
            //    returnMsg += (++i).ToString()+"、密码不能为空。<br />";
            //    isStop = true;
            //}
            if (!string.IsNullOrEmpty(TelePhone))
            {
                int countPh = db.TRealAccounts.Count(t => t.Phone == TelePhone);
                if (countPh > 0)
                {
                    returnMsg += (++i).ToString() + "、此联系电话已经存在。<br />";
                    isStop = true;
                }
            }
            if (!string.IsNullOrEmpty(Email))
            {
                int countPh = db.TRealAccounts.Count(t => t.Phone == TelePhone);
                if (countPh > 0)
                {
                    returnMsg += (++i).ToString() + "、此联系邮箱已经存在。<br />";
                    isStop = true;
                }
            }

            if (isStop)
            {
                return Json(new { code = 0, msg = returnMsg });
            }
            #endregion

            TStaffs s = new TStaffs();
            s.GroupID = GroupID;
            s.StaffName = name;
            s.Account = Account;
            s.TelePhone = TelePhone;
            s.Email = Email;
            s.Status = Status;
            s.DepartmentID = DepartmentID;
            s.OpenerID = OpenerID;
            s.LastUpdateTime = LastUpdateTime;
            s.LastLoginIP = LastLoginIP;
            s.Password = Account;
            db.TStaffs.InsertOnSubmit(s);
            db.SubmitChanges();

            OLog.BeforeValue = "";
            OLog.UpdateValue = ObjectToJson.ModelToJson(s);
            //写入操作日志
            OLog.UserID = Convert.ToInt32(Session["ID"]);
            OLog.UserType = 2;//0 用户 1 会员 2 员工
            OLog.CreateDate = DateTime.Now;
            OLog.PageName = "新增员工账户";
            Converter.InsertOperationLog(OLog);
            //存入日志
            id = Convert.ToInt32(Session["ID"]); //id
            Type = Session["Type"].ToString();  //类型
            msg = "添加员工成功";
            fruit = true;
            Converter.InsertLog(id, Name, Type, msg, fruit);

            return Json(new { code = 1, msg = "添加成功!" });
        }
Example #26
0
        public ActionResult DelAgentGroup()
        {
            int Id = 0;  //Id
            string name = ""; //登陆名
            string Type = "";  //type
            string msg = "";  //提示信息
            bool fruit = false;

            if (!Request.IsAjaxRequest())
                return Content("fail");
            int id = Converter.ToInt(Request["id"], 0);

            try
            {
                if (id > 0)
                {
                    using (APIDataDataContext db = APIDataContextProxy.APIDB)
                    {
                        var agentgroup = (from c in db.TAgentGroup where c.ID == id select c).FirstOrDefault();
                        if (agentgroup != null)
                        {
                            db.TAgentGroup.DeleteOnSubmit(agentgroup);
                            TOperationLog OLog = new TOperationLog();
                            //记录操作日志
                            OLog.BeforeValue = ObjectToJson.ModelToJson(agentgroup);
                            OLog.UpdateValue = "";
                            OLog.UserID = Convert.ToInt32(Session["ID"]);
                            OLog.UserType = 2;//0 用户 1 会员 2 员工
                            OLog.CreateDate = DateTime.Now;
                            OLog.PageName = "删除会员分组";
                            Converter.InsertOperationLog(OLog);
                            //存入日志
                            Id = Convert.ToInt32(Session["ID"]); //id
                            Type = Session["Type"].ToString();  //类型
                            msg = "会员分组删除成功";
                            fruit = true;
                            Converter.InsertLog(Id, name, Type, msg, fruit);
                            db.SubmitChanges();
                            return Content("success");
                        }
                        else
                        {
                            //存入日志
                            Id = Convert.ToInt32(Session["ID"]); //id
                            Type = Session["Type"].ToString();  //类型
                            msg = "会员分组删除失败";
                            fruit = true;
                            Converter.InsertLog(Id, name, Type, msg, fruit);
                            return Content("fail");
                        }

                    }
                }
                else
                {
                    //存入日志
                    Id = Convert.ToInt32(Session["ID"]); //id
                    Type = Session["Type"].ToString();  //类型
                    msg = "会员分组删除失败";
                    fruit = true;
                    Converter.InsertLog(Id, name, Type, msg, fruit);
                    return Content("fail");
                }
            }
            catch
            {
                //存入日志
                Id = Convert.ToInt32(Session["ID"]); //id
                Type = Session["Type"].ToString();  //类型
                msg = "会员分组修改失败";
                fruit = false;
                Converter.InsertLog(Id, name, Type, msg, fruit);
                return Content("fail");
            }
        }
Example #27
0
        public ActionResult Delete()
        {
            int id = 0;  //Id
            string name = ""; //登陆名
            string Type = "";  //type
            string msg = "";  //提示信息
            bool fruit = false;  //结果

            int Id = Converter.ToInt(Request["Accountsid"], 0);
            APIDataDataContext db = APIDataContextProxy.APIDB;
            //查询此条实盘记录的orderyType orderyState 账号余额
            var arr = (from b in db.TRealAccounts
                       where b.ID == Id
                       select new
                       {
                           //判断是否有在手、持仓单子
                           orderCount = (from o in db.TOrders where o.TRealAccountsID == b.ID && o.OrderState==1 && o.OrderType==1 select o.ID).Count(),
                           b.AccountMoney
                       }).FirstOrDefault();

            //要是orderype==1 orderyState=1 账号余额大于0.01
            if (arr.orderCount > 0 || arr.AccountMoney >= 0.01)
            {
                return Content("false");
            }
            else
            {
                try
                {
                    var ra = (from b in db.TRealAccounts where b.ID == Id select b).FirstOrDefault();
                    TOperationLog OLog = new TOperationLog();
                    OLog.BeforeValue = ObjectToJson.ModelToJson(ra);
                    if (ra != null)
                    {
                        db.TRealAccounts.DeleteOnSubmit(ra);
                        db.SubmitChanges();

                        OLog.UpdateValue = "";
                        //写入操作日志
                        OLog.UserID = Convert.ToInt32(Session["ID"]);
                        OLog.UserType = 2;//0 用户 1 会员 2 员工
                        OLog.CreateDate = DateTime.Now;
                        OLog.PageName = "删除客户";
                        Converter.InsertOperationLog(OLog);
                        //存入日志
                        id = Convert.ToInt32(Session["ID"]); //id
                        Type = Session["Type"].ToString();  //类型
                        msg = "删除用户成功";
                        fruit = true;
                        Converter.InsertLog(id, name, Type, msg, fruit);

                        return Content("true");
                    }
                }
                catch
                {

                    //存入日志
                    id = Convert.ToInt32(Session["ID"]); //id
                    Type = Session["Type"].ToString();  //类型
                    msg = "删除用户失败";
                    fruit = false;
                    Converter.InsertLog(id, name, Type, msg, fruit);

                    return Content("false");
                }

            }
            return View();
        }
Example #28
0
        /// <summary>
        /// 删除会员
        /// </summary>
        /// <returns></returns>
        public ActionResult DeletetTagent(int Id)
        {
            int id = 0;  //Id
            string name = ""; //登陆名
            string Type = "";  //type
            string msg = "";  //提示信息
            bool fruit = false;

            APIDataDataContext db = APIDataContextProxy.APIDB;
            var arr = (from b in db.TAgents where b.ID == Id select b.AccountMoney).FirstOrDefault();
            if (Id != 0)
            {
                if (arr <= 0)
                {
                    TOperationLog OLog=new TOperationLog();
                    var Tagent = (from a in db.TAgents where a.ID == Id select a).FirstOrDefault();
                    OLog.BeforeValue = ObjectToJson.ModelToJson(Tagent);
                    string update = "update dbo.[TRealAccounts] set [AgendID]=0 where [AgendID]=" + Id;
                    db.ExecuteQuery<int>(update);
                    db.TAgents.DeleteOnSubmit(Tagent);
                    db.SubmitChanges();

                    OLog.UpdateValue = "";
                    //写入操作日志
                    OLog.UserID = Convert.ToInt32(Session["ID"]);
                    OLog.UserType = 2;//0 用户 1 会员 2 员工
                    OLog.CreateDate = DateTime.Now;
                    OLog.PageName = "删除会员会员";
                    Converter.InsertOperationLog(OLog);

                    //存入日志
                    id = Convert.ToInt32(Session["ID"]); //id
                    Type = Session["Type"].ToString();  //类型
                    msg = "删除会员成功";
                    fruit = true;
                    Converter.InsertLog(id, name, Type, msg, fruit);

                    return Content("true");

                }
                else
                {
                    //存入日志
                    id = Convert.ToInt32(Session["ID"]); //id
                    Type = Session["Type"].ToString();  //类型
                    msg = "删除会员失败";
                    fruit = false;
                    Converter.InsertLog(id, name, Type, msg, fruit);

                    return Content("删除会员失败");
                }

            }
            else
            {
                //存入日志
                id = Convert.ToInt32(Session["ID"]); //id
                Type = Session["Type"].ToString();  //类型
                msg = "删除会员失败";
                fruit = false;
                Converter.InsertLog(id, name, Type, msg, fruit);
                return Content("删除会员失败");
            }
        }
Example #29
0
        public ActionResult AddInfors()
        {
            int id = 0;  //Id
            string name = ""; //登陆名
            string Type = "";  //type
            string msg = "";  //提示信息
            bool fruit = false;  //结果

            APIDataDataContext db = APIDataContextProxy.APIDB;
            var Name = Converter.ToString(Request["Name"], "");  //姓名
            var Account = Converter.ToString(Request["Account"], "");   //账号
            var AccountType = Converter.ToInt(Request["AccountType"], -1);  //账号类型    0为"模拟" 1为"实盘";
            var Phone = Converter.ToString(Request["Phone"], "");   //联系方式
            var Email = Converter.ToString(Request["Email"], "");   //email
            var Status = Converter.ToInt(Request["Status"], -1);      //状态
            var CityCode = Request["CityCode"];     //地区
            var Address = Converter.ToString(Request["Address"], "");    //地址
            var agentid = Converter.ToInt(Request["agentid"], -1);    //所属会员id
            var OpenerID = Converter.ToInt(Request["staffs"], 0);      //开户专员
            DateTime dt = DateTime.Now;
            var OpenTime = dt;  //开户时间
            var LastLoginTime = dt;   //最后登陆时间
            var LastLoginIP = "";   //登陆的ip
            var IDCardNo = Converter.ToString(Request["IDCardNo"], "");   //身份证号
            var Bankid = Converter.ToInt(Request["Bankid"], 0);  //开户银行
            var SavingsAccount = Converter.ToString(Request["SavingsAccount"], "");  //储蓄账号
            var AllowTrade = Converter.ToInt(Request["AllowTrade"], -1);    //交易操作
            var AllowFinance = Converter.ToInt(Request["AllowFinance"], -1);  //资金操作
            var GroupID = Converter.ToInt(Request["GroupID"], -1);   //用户分组
            var AccountMoney = Converter.ToFloat(Request["AccountMoney"], 0);     //账户余额
            //var Password = Converter.ToString(Request["password"], "");   //密码
            var Branch = Converter.ToString(Request["Branch"], "");//开户行支行

            #region 数据校验
            bool isValid = true;
            int i = 0;
            if (string.IsNullOrEmpty(Name))
            {
                msg += (++i).ToString() + "、客户名称不能为空!<br />";
                isValid = false;
            }
            if (string.IsNullOrEmpty(Account))
            {
                msg += (++i).ToString() + "、账号不能为空!<br />";
                isValid = false;
            }
            int count = db.TRealAccounts.Count(t => t.Account == Account);
            if (count > 0)
            {
                msg += (++i).ToString() + "、该帐号已经存在!<br />";
                isValid = false;
            }
            if (!string.IsNullOrEmpty(Phone))
            {
                count = db.TRealAccounts.Count(t => t.Phone == Phone);
                if (count > 0)
                {
                    msg += (++i).ToString() + "、该联系方式已经存在!<br />";
                    isValid = false;
                }
            }
            if (!string.IsNullOrEmpty(Email))
            {
                count = db.TRealAccounts.Count(t => t.Email == Email);
                if (count > 0)
                {
                    msg += (++i).ToString() + "、该联系邮箱已经存在!<br />";
                    isValid = false;
                }
            }
            //if (string.IsNullOrEmpty(Password))
            //{
            //    msg += (++i).ToString()+"、密码不能为空!<br />";
            //    isValid = false;
            //}
            if (string.IsNullOrEmpty(IDCardNo))
            {
                msg += (++i).ToString() + "、身份证号不能为空!<br />";
                isValid = false;
            }
            if (Bankid <= 0)
            {
                msg += (++i).ToString() + "、开户银行不能为空!<br />";
            }
            if (string.IsNullOrEmpty(SavingsAccount))
            {
                msg += (++i).ToString() + "、银行卡号不能为空!<br />";
                isValid = false;
            }
            //if (string.IsNullOrEmpty(CityCode))
            //{
            //    msg += (++i).ToString() + "、开户行所在地不能为空!<br />";
            //    isValid = false;
            //}
            //if (string.IsNullOrEmpty(Branch))
            //{
            //    msg += (++i).ToString() + "、开户行支行不能为空!<br />";
            //    isValid = false;
            //}
            #endregion

            if (isValid)
            {
                TRealAccounts trs = new TRealAccounts();
                trs.Name = Name;
                trs.Account = Account;
                trs.AccountType = AccountType;
                trs.Phone = Phone;
                trs.Email = Email;
                trs.PassWord = Account;
                trs.Status = Status;
                trs.CityID = (from c in db.TCities where c.CityCode == CityCode select c.ID).FirstOrDefault();
                trs.Address = Address;
                if (agentid > 0)
                    trs.AgendID = agentid;
                else
                    trs.AgendID = (from c in db.TAgents select c.ID).FirstOrDefault();
                trs.OpenerID = OpenerID;
                trs.OpenTime = Convert.ToDateTime(OpenTime);
                trs.LastLoginTime = Convert.ToDateTime(LastLoginTime);
                trs.LastLoginIP = LastLoginIP;
                trs.IDCardNo = IDCardNo;
                trs.BankID = Bankid;
                trs.SavingsAccount = SavingsAccount;
                trs.AllowTrade = Convert.ToBoolean(AllowTrade);
                trs.AllowFinance = Convert.ToBoolean(AllowFinance);
                trs.GroupID = GroupID;
                trs.AccountMoney = AccountMoney;
                trs.Branch = Branch;
                db.TRealAccounts.InsertOnSubmit(trs);
                db.SubmitChanges();
                TOperationLog OLog = new TOperationLog();

                OLog.BeforeValue = "";
                OLog.UpdateValue = ObjectToJson.ModelToJson(trs);
                //写入操作日志
                OLog.UserID = Convert.ToInt32(Session["ID"]);
                OLog.UserType = 2;//0 用户 1 会员 2 员工
                OLog.CreateDate = DateTime.Now;
                OLog.PageName = "新增用户";
                Converter.InsertOperationLog(OLog);
                //存入日志
                id = Convert.ToInt32(Session["ID"]); //id
                Type = Session["Type"].ToString();  //类型
                msg = "添加用户成功";
                fruit = true;
                Converter.InsertLog(id, name, Type, msg, fruit);

                return Content("{result:'success',msg:'添加成功!'}");

            }
            else
            {
                //存入日志
                id = Convert.ToInt32(Session["ID"]); //id
                Type = Session["Type"].ToString();  //类型
                //msg = "添加用户失败";
                fruit = false;
                Converter.InsertLog(id, name, Type, "添加用户失败", fruit);

                return Content("{result:'fail',msg:'" + msg + "'}");

            }
        }
Example #30
0
        public ActionResult KLineHistoryDel()
        {
            int Id = 0;  //Id
            string name = ""; //登陆名
            string Type = "";  //type
            string msg = "";  //提示信息
            bool fruit = false;  //结果

            int ids = Converter.ToInt(Request["ids"], 1);
            int id = Converter.ToInt(Request["id"], 1);
            string type = Converter.ToString(Request["type"], "_01MINUTE");
            APIDataDataContext db = APIDataContextProxy.APIDB;
            TOperationLog OLog = new TOperationLog();
            try
            {
                var productname = (from c in db.TProductName where c.ID == ids select c.TableName).FirstOrDefault();
                string sql = "DELETE FROM [" + productname + type + "] WHERE id = " + id;
                int i = db.ExecuteCommand(sql);
                if (i > 0)
                {
                    //存入日志
                    Id = Convert.ToInt32(Session["ID"]); //id
                    Type = Session["Type"].ToString();  //类型
                    msg = "删除时段里的数据数据成功";
                    fruit = true;
                    Converter.InsertLog(Id, name, Type, msg, fruit);

                    OLog.BeforeValue = "{\"TableName\":\"" + productname + type + "\",\"id\":\"" + id + "\"}";
                    OLog.UpdateValue = "";
                    //写入操作日志
                    OLog.UserID = Convert.ToInt32(Session["ID"]);
                    OLog.UserType = 2;//0 用户 1 会员 2 员工
                    OLog.CreateDate = DateTime.Now;
                    OLog.PageName = "删除时段里的数据";
                    Converter.InsertOperationLog(OLog);

                    return Content("true");
                }
                else
                {
                    //存入日志
                    Id = Convert.ToInt32(Session["ID"]); //id
                    Type = Session["Type"].ToString();  //类型
                    msg = "删除时段里的数据数据失败";
                    fruit = false;
                    Converter.InsertLog(Id, name, Type, msg, fruit);

                    return Content("false");
                }
            }
            catch
            {
                Id = Convert.ToInt32(Session["ID"]); //id
                Type = Session["Type"].ToString();  //类型
                msg = "删除时段里的数据数据失败";
                fruit = false;
                Converter.InsertLog(Id, name, Type, msg, fruit);
                return Content("false");
            }
        }