Ejemplo n.º 1
0
        /// <summary>
        /// 删除菜单集合
        /// </summary>
        /// <param name="validationErrors">返回的错误信息</param>
        /// <param name="deleteCollection">主键的菜单</param>
        /// <returns></returns>
        public bool DeleteCollection(ref ValidationErrors validationErrors, string[] deleteCollection)
        {
            try
            {
                if (deleteCollection != null)
                {
                    using (TransactionScope transactionScope = new TransactionScope())
                    {
                        repository.Delete(db, deleteCollection);
                        if (deleteCollection.Length == repository.Save(db))
                        {
                            db.SaveChanges();
                            //要先提交事务,然后修改编码,否则IsLeaf字段得不到更新

                            //在1.2版本中修改
                            //此方法由eastday(qq:76381028)提供
                            //删除后重置菜单编码
                            List <int> flags = new List <int>();//层级
                            GetMenus2(null, flags);
                            db.SaveChanges();

                            transactionScope.Complete();
                            return(true);
                        }
                        else
                        {
                            Transaction.Current.Rollback();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                validationErrors.Add(ex.Message);
                ExceptionsHander.WriteExceptions(ex);
            }
            return(false);
        }
Ejemplo n.º 2
0
        public bool SetStopPaymentSuccess(SysEntities db, List <int> stopIds, List <int?> alltypes)
        {
            bool result = false;

            try
            {
                var stopPayment = db.EmployeeStopPayment.Where(o => stopIds.Contains(o.Id) && alltypes.Contains(o.EmployeeAdd.InsuranceKindId));
                foreach (EmployeeStopPayment stop in stopPayment)
                {
                    stop.State             = EmployeeStopPayment_State.申报成功.ToString();
                    stop.EmployeeAdd.State = EmployeeAdd_State.已报减.ToString();
                }
                db.SaveChanges();
                //修改企业员工关系表 的状态
                var lstRelationId = stopPayment.Select(o => o.EmployeeAdd).GroupBy(g => g.CompanyEmployeeRelationId).Select(x => x.Key);
                foreach (int relationId in lstRelationId)
                {
                    string strState = EmployeeAdd_State.已报减.ToString();

                    if (!db.EmployeeAdd.Any(o => o.CompanyEmployeeRelationId == relationId && o.State != strState))
                    {
                        int id = relationId;
                        var companyEmployeeRelation = db.CompanyEmployeeRelation.Single(o => o.Id == id);
                        companyEmployeeRelation.State = "离职";
                    }
                }


                db.SaveChanges();
                result = true;
            }
            catch (Exception)
            {
                result = false;
            }

            return(result);
        }
Ejemplo n.º 3
0
        public ActionResult Async_SaveHospital(HttpPostedFileBase files, string id)
        {
            string fileName = String.Empty;

            // The Name of the Upload component is "files"
            if (files != null)
            {
                // Remove all files by HospID
                var    dir          = new System.IO.DirectoryInfo(Server.MapPath("~/PhotoCloud/HospitalImages/"));
                string sDir         = Server.MapPath("~/PhotoCloud") + @"/HospitalImages/";
                string physicalPath = String.Empty;

                foreach (var file in dir.EnumerateFiles(id + "_*.*"))
                {
                    physicalPath = System.IO.Path.Combine(sDir + "/", file.ToString());
                    if (System.IO.File.Exists(physicalPath))
                    {
                        System.IO.File.Delete(physicalPath);
                    }
                }

                fileName     = id + "_" + Path.GetFileName(files.FileName);
                physicalPath = Path.Combine(sDir + "/", fileName);

                files.SaveAs(physicalPath);

                Session["SourcePhotoFileName"] = fileName;

                // update SysHospital set HospImage = fileName where HospRowid = id
                using (var db = new SysEntities())
                {
                    var result = db.SysHospital.SingleOrDefault(b => b.HospRowid == id);
                    if (result != null)
                    {
                        result.HospImage = fileName;
                        db.SaveChanges();
                    }
                }
            }

            // Return an empty string to signify success
            return(Json(new { HospImage = fileName }, "text/plain"));
        }
Ejemplo n.º 4
0
        public bool EditSTATUS2(ref ValidationErrors validationErrors, SIGN sign)
        {
            try
            {
                using (SysEntities sys = new SysEntities())
                {
                    sys.SIGN.Add(sign);
                    sys.SaveChanges();
                }


                return(true);
            }
            catch (Exception ex)
            {
                validationErrors.Add(ex.Message);
                ExceptionsHander.WriteExceptions(ex);
            }
            return(false);
        }
        public ActionResult SysMedicalGroup_Create(ViewModel_MedicalGroups sysMedicalGroups, string MGType)
        {
            if (sysMedicalGroups != null && ModelState.IsValid)
            {
                var target = new SysMedicalGroup();
                target.MGRowid    = Guid.NewGuid().ToString();
                target.MGName     = sysMedicalGroups.MGName;
                target.MGDescript = sysMedicalGroups.MGDescript;
                target.MGFont     = sysMedicalGroups.MGFont;
                target.MGType     = MGType;

                db.SysMedicalGroup.Add(target);
                db.SaveChanges();

                sysMedicalGroups.MGRowid = target.MGRowid;
            }

            return(Json(new[] { sysMedicalGroups }.ToDataSourceResult(new DataSourceRequest(), ModelState)));
        }
Ejemplo n.º 6
0
 /// <summary>
 /// 修改密码
 /// </summary>
 /// <param name="personName">用户名</param>
 /// <param name="oldPassword">旧密码</param>
 /// <param name="newPassword">新密码</param>
 /// <returns>修改密码是否成功</returns>
 public bool ChangePassword(string personName, string oldPassword, string newPassword)
 {
     if (!string.IsNullOrWhiteSpace(personName) && !string.IsNullOrWhiteSpace(oldPassword) && !string.IsNullOrWhiteSpace(newPassword))
     {
         try
         {
             using (SysEntities db = new SysEntities())
             {
                 var person = db.SysPerson.FirstOrDefault(p => (p.Name == personName) && (p.Password == oldPassword));
                 person.Password     = newPassword;
                 person.SurePassword = newPassword;
                 db.SaveChanges();
                 return(true);
             }
         }
         catch (Exception ex)
         {
             ExceptionsHander.WriteExceptions(ex);
         }
     }
     return(false);
 }
        public string InsertStopPaymentInfo(SysEntities db, List <PostInfo> lstStopPaymentEmployeeInfo, int CompanyId)
        {
            string        result = string.Empty;
            StringBuilder error  = new StringBuilder();
            List <EmployeeStopPayment> lstStopPayment = new List <EmployeeStopPayment>();
            DateTime      now            = DateTime.Now;
            List <string> lstStopingKind = new List <string> {
                "待责任客服确认", "待员工客服经理分配", "员工客服确认", "社保专员已提取"
            };

            #region 验证

            try
            {
                foreach (PostInfo emp in lstStopPaymentEmployeeInfo)
                {
                    StringBuilder err = new StringBuilder();

                    var e = db.Employee.FirstOrDefault(o => o.CertificateNumber == emp.IDNumber);
                    if (e == null)
                    {
                        err.AppendLine(string.Format("不存在员工 {0} - {1},不能报减。", emp.Name, emp.IDNumber));
                        continue;
                    }
                    emp.EmployeeId = e.Id;

                    var cer =
                        db.CompanyEmployeeRelation.Where(
                            o => o.CompanyId == CompanyId && o.EmployeeId == emp.EmployeeId && o.State == "在职")
                        .OrderByDescending(o => o.Id)
                        .FirstOrDefault();
                    if (cer == null)
                    {
                        err.AppendLine(string.Format("{0} 没有任何申报成功的社保或公积金,不能报减。", emp.Name));
                        continue;
                    }

                    var empAdd = db.EmployeeAdd.Where(o => o.CompanyEmployeeRelationId == cer.Id && o.State == "申报成功");
                    if (!empAdd.Any())
                    {
                        err.AppendLine(string.Format("{0}  没有任何申报成功的社保或公积金,不能报减。", emp.Name));
                        continue;
                    }
                    foreach (InsuranceType k in emp.InsuranceType)
                    {
                        var add = empAdd.FirstOrDefault(o => o.PoliceInsuranceId == k.PoliceInsuranceId);
                        if (add == null)
                        {
                            err.AppendLine(string.Format(" {1} 没有申报成功 {2},不能报减。", "", emp.Name,
                                                         k.Insurance));
                        }
                        else
                        {
                            var stopingKind = add.EmployeeGoonPayment.Where(o => lstStopingKind.Contains(o.State));
                            if (stopingKind.Any())
                            {
                                err.AppendLine(string.Format("{0} 的员工 {1}  {2} 正在报减,不能重复报减。", "",
                                                             emp.Name, k.Insurance));
                            }
                            else
                            {
                                EmployeeStopPayment stopPayment = new EmployeeStopPayment();
                                stopPayment.EmployeeAddId     = add.Id;
                                stopPayment.InsuranceMonth    = k.ReductionTime;
                                stopPayment.PoliceOperationId = k.PoliceOperationId;
                                stopPayment.Remark            = "";
                                stopPayment.State             = "待责任客服确认";
                                stopPayment.CreateTime        = now;
                                stopPayment.CreatePerson      = "1";
                                stopPayment.UpdateTime        = now;
                                stopPayment.UpdatePerson      = "1";
                                stopPayment.YearMonth         = Convert.ToInt32(DateTime.Now.ToString("yyyyMM"));

                                lstStopPayment.Add(stopPayment);
                            }
                        }
                    }
                    if (!string.IsNullOrEmpty(err.ToString()))
                    {
                        error.AppendLine(err.ToString());
                        continue;
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }

            #endregion
            result = error.ToString();
            try
            {
                if (lstStopPayment.Any() && string.IsNullOrEmpty(result))
                {
                    foreach (EmployeeStopPayment stopPayment in lstStopPayment)
                    {
                        db.EmployeeStopPayment.Add(stopPayment);
                        db.SaveChanges();
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(result);
        }
Ejemplo n.º 8
0
 public int Commit()
 {
     return(_ctx.SaveChanges());
 }
Ejemplo n.º 9
0
        public Common.ClientResult.Result Shanchu(string IDs)
        {
            ValidationErrors validationErrors = new ValidationErrors();
            StringBuilder    sbError          = new StringBuilder();
            SysEntities      SysEntitiesO2O   = new SysEntities();

            try
            {
                using (TransactionScope scope = new TransactionScope())
                {
                    int[]    intArray; List <int> intArrayuser = new List <int>();
                    string[] strArray = IDs.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                    intArray = Array.ConvertAll <string, int>(strArray, s => int.Parse(s));
                    var GropTable = SysEntitiesO2O.ORG_Group.FirstOrDefault(o => true && intArray.Contains(o.ID));
                    // GropTable = GropTable.FirstOrDefault(o => o.ID == IntId);
                    if (GropTable != null)
                    {
                        var       ORG_GroupBLL = new BLL.ORG_GroupBLL();
                        ORG_Group Model        = new ORG_Group();
                        Model = GropTable;
                        ORG_GroupBLL.DeleteCollection(ref validationErrors, intArray);
                    }
                    var GropUserTable = SysEntitiesO2O.ORG_GroupUser.Where(o => true && intArray.Contains(o.ORG_Group_ID)).ToList();
                    if (GropUserTable != null)
                    {
                        foreach (var item in GropUserTable)
                        {
                            int j = 0;
                            intArrayuser.Add(item.ID);
                            j++;
                        }
                    }
                    if (intArrayuser.Count > 0)
                    {
                        var   ORG_GroupUserBLL = new BLL.ORG_GroupUserBLL();
                        int[] allid            = new int[intArrayuser.Count];
                        for (int i = 0; i < intArrayuser.Count(); i++)
                        {
                            allid[i] = intArrayuser[i];
                        }

                        ORG_GroupUserBLL.DeleteCollection(ref validationErrors, allid);
                    }


                    SysEntitiesO2O.SaveChanges();
                    scope.Complete();
                    Common.ClientResult.Result result = new Common.ClientResult.Result();
                    result.Code    = ClientCode.Succeed;
                    result.Message = "删除成功";
                    return(result);
                }
            }
            catch (Exception er)
            {
                Common.ClientResult.Result result = new Common.ClientResult.Result();
                result.Code    = ClientCode.Fail;
                result.Message = "删除失败";
                return(result);
            }
        }
Ejemplo n.º 10
0
        /// <summary>
        /// 供应商专员报增反馈 成功
        /// </summary>
        /// <param name="query">报增成功id集合</param>
        /// <param name="CompanyEmployeeRelationId">人员企业关系</param>
        /// <param name="alltype">险种</param>
        /// <returns></returns>
        public string FeedbackIndexPass1(string query, string CompanyEmployeeRelationId, string alltype)
        {
            try
            {
                using (TransactionScope scope = new TransactionScope())
                {
                    alltype = HttpUtility.HtmlDecode(alltype);
                    string   result = "";
                    string   prompt = "";
                    int[]    intArray;
                    string[] strArray = query.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                    intArray = Array.ConvertAll <string, int>(strArray, s => int.Parse(s));
                    int?[]      intArrayall1       = new int?[10];
                    List <int?> InsuranceKindTypes = new List <int?>();
                    string[]    strArrayall        = alltype.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                    foreach (var a in strArrayall)
                    {
                        int InsuranceKindId = (int)(Common.EmployeeAdd_InsuranceKindId)Enum.Parse(typeof(Common.EmployeeAdd_InsuranceKindId), a);
                        InsuranceKindTypes.Add(InsuranceKindId);
                    }

                    int[]    fuwuintArray;
                    string[] fuwuArray = CompanyEmployeeRelationId.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                    fuwuintArray = Array.ConvertAll <string, int>(fuwuArray, s => int.Parse(s));
                    using (var ent = new SysEntities())
                    {
                        var empadd       = ent.EmployeeAdd.Where(a => true);                                                                      //报增表
                        var updateEmpAdd = ent.EmployeeAdd.Where(a => intArray.Contains(a.Id) && InsuranceKindTypes.Contains(a.InsuranceKindId)); //获取险种要报增的险种
                        if (updateEmpAdd != null && updateEmpAdd.Count() >= 1)
                        {
                            foreach (var item in updateEmpAdd)
                            {
                                string statesuccess                = EmployeeAdd_State.申报成功.ToString();//申报成功 && o.State == statesuccess
                                var    EmployeeAdd                 = ent.EmployeeAdd.FirstOrDefault(o => o.Id == item.Id);
                                var    CompanyEmployeeRelation     = ent.CompanyEmployeeRelation.FirstOrDefault(o => o.Id == EmployeeAdd.CompanyEmployeeRelationId);
                                var    CompanyEmployeeRelationList = ent.CompanyEmployeeRelation.FirstOrDefault(o => o.EmployeeId == CompanyEmployeeRelation.EmployeeId && o.CompanyId == CompanyEmployeeRelation.CompanyId && o.Id == EmployeeAdd.CompanyEmployeeRelationId && o.State == "在职");

                                var EmployeeAdd_Seccess = ent.EmployeeAdd.FirstOrDefault(o => o.CompanyEmployeeRelationId == CompanyEmployeeRelationList.Id && o.State == statesuccess && o.InsuranceKindId == EmployeeAdd.InsuranceKindId);

                                if (EmployeeAdd_Seccess != null)
                                {
                                    var KindName = Enum.GetName(typeof(Common.EmployeeAdd_InsuranceKindId), EmployeeAdd.InsuranceKindId);
                                    var Employee = ent.Employee.FirstOrDefault(o => o.Id == CompanyEmployeeRelationList.EmployeeId);
                                    result = result + Employee.Name + "在此公司下以存在" + KindName + "的报增成功记录";
                                }
                                else
                                {
                                    item.State        = EmployeeAdd_State.申报成功.ToString();
                                    item.UpdateTime   = DateTime.Now;
                                    item.UpdatePerson = LoginInfo.LoginName;
                                    ent.SaveChanges();
                                    #region 添加服务费
                                    #region 得出服务费

                                    decimal payService_One     = 0;
                                    decimal payService_OneBJ   = 0;
                                    int     count              = 0;
                                    CRM_CompanyRepository api1 = new CRM_CompanyRepository();
                                    count = api1.getEmployee(SysEntitiesO2O, item.CompanyEmployeeRelation.CompanyId, item.YearMonth);

                                    int[] cclpStatus = new int[] {
                                        (int)Common.Status.启用, (int)Common.Status.修改中
                                    };
                                    //找出单人服务费
                                    var cRM_CompanyLadderPrice = SysEntitiesO2O.CRM_CompanyLadderPrice.Where(cclp => cclp.CRM_Company_ID == item.CompanyEmployeeRelation.CompanyId && cclpStatus.Contains(cclp.Status) && cclp.BeginLadder <= count && cclp.EndLadder >= count);
                                    if (cRM_CompanyLadderPrice.Count() > 0)
                                    {
                                        payService_One = cRM_CompanyLadderPrice.OrderByDescending(o => o.EndLadder).FirstOrDefault().SinglePrice;
                                    }
                                    decimal payService_All = 0;
                                    bool    zhengHu        = false;
                                    //找出整户服务费
                                    var cRM_CompanyPrice = SysEntitiesO2O.CRM_CompanyPrice.Where(ccp => (new[] { (int)Common.Status.启用, (int)Common.Status.修改中 }).Contains(ccp.Status) && ccp.CRM_Company_ID == item.CompanyEmployeeRelation.CompanyId);
                                    if (cRM_CompanyPrice.Count() > 0)
                                    {
                                        payService_All   = cRM_CompanyPrice.FirstOrDefault().LowestPrice.Value;
                                        payService_OneBJ = cRM_CompanyPrice.FirstOrDefault().AddPrice.Value;
                                    }
                                    //判断取单人服务费还是整户服务费
                                    if (payService_One * count > payService_All)
                                    {
                                        zhengHu        = false;
                                        payService_All = 0;
                                    }
                                    else
                                    {
                                        zhengHu        = true;
                                        payService_One = 0;
                                    }
                                    #endregion
                                    #region 得出需要修改的人和公司全部人
                                    string[] ZENG_STATUS = new string[] {
                                        Common.EmployeeAdd_State.待责任客服确认.ToString(), Common.EmployeeAdd_State.待员工客服经理分配.ToString(),
                                             Common.EmployeeAdd_State.待员工客服确认.ToString(), Common.EmployeeAdd_State.员工客服已确认.ToString(), Common.EmployeeAdd_State.社保专员已提取.ToString(),
                                             Common.EmployeeAdd_State.申报成功.ToString()
                                    };

                                    int[] emploees = api1.getEmployeeIDs(SysEntitiesO2O, item.CompanyEmployeeRelation.CompanyId, item.YearMonth);
                                    var   CompanyEmployeeRelationlist = (from ce in SysEntitiesO2O.CompanyEmployeeRelation.Where(ce => ce.State == "在职")
                                                                         join e in SysEntitiesO2O.EmployeeAdd on ce.Id equals e.CompanyEmployeeRelationId
                                                                         where ce.CompanyId == item.CompanyEmployeeRelation.CompanyId && ZENG_STATUS.Contains(e.State) && emploees.Contains(ce.EmployeeId ?? 0)
                                                                         select new
                                    {
                                        CompanyId = (int)ce.CompanyId,
                                        Employee_ID = ce.EmployeeId,
                                        YearMonth = e.YearMonth
                                    }).Distinct().ToList();
                                    #endregion
                                    #endregion
                                    #region 修改费用服务费表中的正常服务费
                                    int   PaymentStyle   = (int)Common.EmployeeMiddle_PaymentStyle.正常;
                                    int[] FEIYONG_STATUS = new int[] { (int)Common.COST_Table_Status.财务作废, (int)Common.COST_Table_Status.客户作废, (int)Common.COST_Table_Status.责任客服作废 };
                                    var   COST_CostTable = ent.COST_CostTable.Where(a => true);
                                    foreach (var item3 in CompanyEmployeeRelationlist)
                                    {
                                        var list1 = (from a in COST_CostTable
                                                     join b in ent.COST_CostTableService on a.ID equals b.COST_CostTable_ID
                                                     where !FEIYONG_STATUS.Contains(a.Status) && b.PaymentStyle == PaymentStyle && b.CRM_Company_ID == item3.CompanyId && a.YearMonth == item3.YearMonth && b.Employee_ID == item.CompanyEmployeeRelation.EmployeeId
                                                     select b).FirstOrDefault();//费用表
                                        if (list1 != null)
                                        {
                                            if (zhengHu == true)//整户服务费
                                            {
                                                list1.ServiceCoset = payService_All;

                                                var list2 = from a in COST_CostTable
                                                            join b in ent.COST_CostTableService on a.ID equals b.COST_CostTable_ID
                                                            where !FEIYONG_STATUS.Contains(a.Status) && b.PaymentStyle == PaymentStyle && b.CRM_Company_ID == item3.CompanyId && a.YearMonth == item3.YearMonth && b.Employee_ID != item.CompanyEmployeeRelation.EmployeeId
                                                            select b;//
                                                if (list2.Count() > 0)
                                                {
                                                    foreach (var item4 in list2)
                                                    {
                                                        item4.ServiceCoset = 0;
                                                    }
                                                }
                                            }
                                            else//单人服务费
                                            {
                                                list1.ServiceCoset = payService_One;
                                                var list2 = from a in COST_CostTable
                                                            join b in ent.COST_CostTableService on a.ID equals b.COST_CostTable_ID
                                                            where !FEIYONG_STATUS.Contains(a.Status) && b.PaymentStyle == PaymentStyle && b.CRM_Company_ID == item3.CompanyId && a.YearMonth == item3.YearMonth && b.Employee_ID != item.CompanyEmployeeRelation.EmployeeId
                                                            select b;//
                                                if (list2.Count() > 0)
                                                {
                                                    foreach (var item4 in list2)
                                                    {
                                                        item4.ServiceCoset = payService_One;
                                                    }
                                                }
                                            }
                                        }
                                    }
                                    #endregion
                                    #region  修改补缴服务费
                                    //取中间表的补缴数据
                                    string Middlestate = Common.Status.启用.ToString();
                                    var    CompanyEmployeeRelationlistMiddle =
                                        (from em in ent.EmployeeMiddle.Where(em => em.PaymentStyle == (int)Common.EmployeeMiddle_PaymentStyle.补缴)
                                         join cer in ent.CompanyEmployeeRelation on em.CompanyEmployeeRelationId equals cer.Id
                                         join e in ent.Employee on cer.EmployeeId equals e.Id
                                         where cer.CompanyId == item.CompanyEmployeeRelation.CompanyId && em.State == Middlestate
                                         select new
                                    {
                                        StartDate = em.StartDate,
                                        Employee_ID = e.Id,
                                        CompanyId = cer.CompanyId,
                                        PaymentMonth = em.PaymentMonth,
                                    }).GroupBy(o => new { o.Employee_ID, o.CompanyId, o.PaymentMonth, o.StartDate }).Select(o => new
                                    {
                                        StartDate    = o.Key.StartDate,
                                        ServiceCoset = (decimal)o.Max(m => m.PaymentMonth) * payService_OneBJ,
                                        Employee_ID  = o.Key.Employee_ID,
                                        CompanyId    = item.CompanyEmployeeRelation.CompanyId,
                                        PaymentMonth = o.Key.PaymentMonth,
                                    }).ToList();
                                    #region 修改费用服务费表中的补缴服务费
                                    int bujiaoPaymentStyle = (int)Common.EmployeeMiddle_PaymentStyle.补缴;


                                    foreach (var item3 in CompanyEmployeeRelationlistMiddle)
                                    {
                                        var listooo = (from a in COST_CostTable
                                                       join b in ent.COST_CostTableService on a.ID equals b.COST_CostTable_ID
                                                       where !FEIYONG_STATUS.Contains(a.Status) && b.PaymentStyle == bujiaoPaymentStyle && b.CRM_Company_ID == item3.CompanyId && a.YearMonth == item3.StartDate && b.Employee_ID == item3.Employee_ID
                                                       select b).FirstOrDefault();//费用表
                                        if (listooo != null)
                                        {
                                            listooo.ServiceCoset = item3.ServiceCoset;
                                        }
                                    }
                                    #endregion
                                    #endregion
                                    ent.SaveChanges();
                                    result = "报增成功!";
                                }
                            }
                            scope.Complete();
                            prompt = result;
                        }
                        else
                        {
                            prompt = "不存在此险种!";
                        }
                        return(prompt);
                    }
                }
            }
            catch (Exception e)
            {
                return(e.Message.ToString());
            }
        }
Ejemplo n.º 11
0
        public IHttpActionResult AddCompany(CompanyInfo companyinfo)
        {
            if (!IsValidation())
            {
                return(Json(new { code = -1, message = "验证未通过" }));
            }
            try
            {
                using (SysEntities db = new SysEntities())
                {
                    CRM_Company company = new CRM_Company();

                    company.CompanyCode      = "0001测试";
                    company.CompanyName      = companyinfo.Name;
                    company.OrganizationCode = companyinfo.OrganizationCode;
                    //company.TaxRegistryNumber = companyinfo.TaxNumber;
                    //company.InvoiceCompanyName = companyinfo.InvoiceName;
                    //company.PayCompanyName =   companyinfo.PaymentName;
                    company.CreateTime     = DateTime.Now;
                    company.CreateUserID   = 1;
                    company.CreateUserName = "******";
                    company.OperateStatus  = 1;//启用


                    //注意   是否需要转换
                    company.Dict_HY_Code = companyinfo.Industry;
                    company.Source       = 1;//平台推送。


                    db.CRM_Company.Add(company);
                    db.SaveChanges();
                    //#region 开票回款

                    //CRM_CompanyFinance companyfinance = new CRM_CompanyFinance();
                    //companyfinance.CRM_Company_ID = company.ID;
                    //companyfinance.FinanceName = companyinfo.InvoiceName;
                    //companyfinance.FinanceType = 1;//开票
                    //companyfinance.Status = 1;//启用
                    //companyfinance.BranchID = 1;
                    //companyfinance.CreateTime = DateTime.Now;
                    //companyfinance.CreateUserID = 1;
                    //companyfinance.CreateUserName = "******";

                    //db.CRM_CompanyFinance.Add(companyfinance);
                    //db.SaveChanges();

                    //companyfinance = new CRM_CompanyFinance();
                    //companyfinance.CRM_Company_ID = company.ID;
                    //companyfinance.FinanceName = companyinfo.PaymentName;
                    //companyfinance.FinanceType = 2;//回款
                    //companyfinance.Status = 1;//启用
                    //companyfinance.BranchID = 1;
                    //companyfinance.CreateTime = DateTime.Now;
                    //companyfinance.CreateUserID = 1;
                    //companyfinance.CreateUserName = "******";

                    //db.CRM_CompanyFinance.Add(companyfinance);
                    //db.SaveChanges();
                    //#endregion

                    #region 联系人
                    CRM_CompanyLinkMan companylinkman = new CRM_CompanyLinkMan();
                    companylinkman.CRM_Company_ID = company.ID;
                    companylinkman.LinkManName    = companyinfo.ContactPerson;
                    companylinkman.Telephone      = companyinfo.ContactPhone;
                    companylinkman.Address        = companyinfo.ContactAddress;

                    companylinkman.CreateTime     = DateTime.Now;
                    companylinkman.BranchID       = 1;//暂时写1
                    companylinkman.CreateUserID   = 1;
                    companylinkman.CreateUserName = "******";
                    companylinkman.Status         = 1;

                    db.CRM_CompanyLinkMan.Add(companylinkman);
                    db.SaveChanges();

                    #endregion


                    return(Json(new { code = 0, message = "成功", id = company.ID }));
                };
            }
            catch (Exception ee)
            {
                return(Json(new { code = -1, message = ee.ToString() }));
            }
        }
Ejemplo n.º 12
0
        public bool SaveCollection(ref ValidationErrors validationErrors, string[] ids, string id)
        {
            char split = '^';
            var  data  = (
                from f in ids
                where f.Contains(split)
                select f.Substring(0, f.IndexOf(split))
                ).Union(
                from f in ids
                where !string.IsNullOrWhiteSpace(f) && !f.Contains(split)
                select f);

            //using (TransactionScope transactionScope = new TransactionScope())
            {
                //利用编码机制,查询出所有的菜单
                var           codes = db.SysMenu.Where(w => data.Contains(w.Id)).Select(s => s.Remark).Distinct();
                List <string> ls    = new List <string>();
                foreach (var item in codes)
                {
                    if (item == null)
                    {
                        continue;
                    }
                    for (int i = 0; i < item.Length / 4; i++)
                    {
                        //在1.2版本中修改
                        string num = System.Numerics.BigInteger.Divide(System.Numerics.BigInteger.Parse(item), System.Numerics.BigInteger.Pow(10000, i)).ToString();

                        if (!ls.Contains(num))
                        {
                            ls.Add(num);
                        }
                    }
                }
                //现在所有的菜单
                var SysMenusIds = from f in db.SysMenu
                                  where ls.Contains(f.Remark)
                                  select f.Id;
                //删除的菜单
                var deleteSysMenuSysRoleSysOperation = from f in db.SysMenuSysRoleSysOperation
                                                       where f.SysRoleId == id
                                                       select f;
                foreach (var item in deleteSysMenuSysRoleSysOperation)
                {
                    db.SysMenuSysRoleSysOperation.Remove(item);
                }

                foreach (var item in SysMenusIds)
                {//插入菜单
                    db.SysMenuSysRoleSysOperation.Add(new SysMenuSysRoleSysOperation()
                    {
                        Id = Common.Result.GetNewId(), SysRoleId = id, SysMenuId = item
                    });
                }

                foreach (var item in ids)
                {//插入操作
                    if (item.Contains(split))
                    {
                        db.SysMenuSysRoleSysOperation.Add(new SysMenuSysRoleSysOperation()
                        {
                            Id = Common.Result.GetNewId(), SysRoleId = id, SysMenuId = item.Substring(0, item.IndexOf(split)), SysOperationId = item.Substring(item.IndexOf(split) + 1)
                        });
                    }
                }
                db.SaveChanges();
                //transactionScope.Complete();
                return(true);
            }
        }
Ejemplo n.º 13
0
        public ActionResult ComboMaster_Create(ViewModel_ComboMasters combomaster)
        {
            if (combomaster != null && ModelState.IsValid)
            {
                var target = new ComboMaster();
                target.CBMRowid                = Guid.NewGuid().ToString();
                target.CBMClass                = combomaster.CBMClass;
                target.CBMDescription          = combomaster.CBMDescription;
                target.CBMRemark               = combomaster.CBMRemark;
                target.CBMGroup                = combomaster.CBMGroup;
                target.CBMLastModifiedDateTime = combomaster.CBMLastModifiedDateTime;
                target.CBMModifiedUserRowid    = combomaster.CBMModifiedUserRowid;

                db.ComboMaster.Add(target);
                db.SaveChanges();

                combomaster.CBMRowid = target.CBMRowid;
            }

            return(Json(new[] { combomaster }.ToDataSourceResult(new DataSourceRequest(), ModelState)));
        }
Ejemplo n.º 14
0
        public ActionResult SysHospital_Create([DataSourceRequest] DataSourceRequest request, SysHospital sysHospital)
        {
            string sRowid = Guid.NewGuid().ToString();

            //string sPath = "/PhotoCloud/HospitalImages/";
            //string sMoveFile = (Session["SourcePhotoFileName"] == null) ? sRowid + "_no-photo-available.png" : sRowid + "_" + Session["SourcePhotoFileName"].ToString();

            if (ModelState.IsValid)
            {
                var entity = new SysHospital
                {
                    HospRowid     = sRowid,
                    HospID        = sysHospital.HospID,
                    HospName      = sysHospital.HospName,
                    HospPrincipal = sysHospital.HospPrincipal,
                    HospDean      = sysHospital.HospDean,
                    HospAddress   = sysHospital.HospAddress,
                    HospAreaCode  = sysHospital.HospAreaCode,
                    HospPhone     = sysHospital.HospPhone,
                    HospFaxno     = sysHospital.HospFaxno,
                    HospEmail     = sysHospital.HospEmail,
                    HospLevel     = sysHospital.HospLevel,
                    HospHIS       = sysHospital.HospHIS,
                    HospActive    = sysHospital.HospActive,
                    HospImage     = (Session["SourcePhotoFileName"] == null) ? "no-photo-available.png" : Session["SourcePhotoFileName"].ToString(),
                    //HospImage = (sysHospital.HospImage == null) ? "no-photo-available.png" : sysHospital.HospImage,
                    HospRegSys = "0"
                };

                db.SysHospital.Add(entity);
                db.SaveChanges();
                sysHospital.HospRowid = entity.HospRowid;
                sysHospital.HospImage = entity.HospImage;
                //if (Session["SourcePhotoFileName"] == null)
                //{
                //    System.IO.File.Copy(Request.MapPath(sPath + "no-photo-available.png"), Request.MapPath(sPath + sMoveFile));
                //    sysHospital.HospImage = sRowid + "_no-photo-available.png";
                //}
                //else
                //{
                //    sysHospital.HospImage = entity.HospImage;
                //}
            }

            //Session.Remove("SourcePhotoFileName");

            return(Json(new[] { sysHospital }.ToDataSourceResult(request, ModelState)));
        }
Ejemplo n.º 15
0
        public bool SaveCollection(ref ValidationErrors validationErrors, string[] ids, string id)
        {
            char split = '^';
            var  data  = (
                from f in ids
                where f.Contains(split)
                select f.Substring(0, f.IndexOf(split))
                ).Union(
                from f in ids
                where !string.IsNullOrWhiteSpace(f) && !f.Contains(split)
                select f);

            using (TransactionScope transactionScope = new TransactionScope())
            {
                //利用编码机制,查询出所有的菜单
                var           codes = db.SysMenu.Where(w => data.Contains(w.Id)).Select(s => s.Remark).Distinct();
                List <string> ls    = new List <string>();
                foreach (var item in codes)
                {
                    if (item == null)
                    {
                        continue;
                    }
                    for (int i = 0; i < item.Length / 4; i++)
                    {
                        //在1.2版本中修改
                        string num = System.Numerics.BigInteger.Divide(System.Numerics.BigInteger.Parse(item), System.Numerics.BigInteger.Pow(10000, i)).ToString();

                        if (!ls.Contains(num))
                        {
                            ls.Add(num);
                        }
                    }
                }
                var SysMenusIds = from f in db.SysMenu
                                  where ls.Contains(f.Remark)
                                  select f.Id; //现在所有的菜单

                StringBuilder builder = new StringBuilder();
                builder.AppendFormat("DELETE FROM  [SysMenuSysRoleSysOperation] WHERE [SysRoleId] = '{0}';", id); //删除该角色的所有的菜单和操作
                foreach (var item in SysMenusIds)
                {                                                                                                 //插入菜单
                    builder.AppendFormat("INSERT INTO [SysMenuSysRoleSysOperation]([Id],[SysRoleId],[SysMenuId])VALUES('{0}','{1}','{2}');"
                                         , Common.Result.GetNewId(), id, item);
                }

                foreach (var item in ids)
                {//插入操作
                    if (item.Contains(split))
                    {
                        builder.AppendFormat("INSERT INTO [SysMenuSysRoleSysOperation]([Id],[SysRoleId],[SysMenuId],[SysOperationId])VALUES('{0}','{1}','{2}','{3}');"
                                             , Common.Result.GetNewId(), id, item.Substring(0, item.IndexOf(split)), item.Substring(item.IndexOf(split) + 1));
                    }
                }

                db.Database.ExecuteSqlCommand(builder.ToString());
                db.SaveChanges();
                transactionScope.Complete();
                return(true);
            }
        }
Ejemplo n.º 16
0
 /// <summary>
 /// 提交保存,持久化到数据库
 /// </summary>
 /// <param name="db">实体数据</param>
 /// <returns>受影响行数</returns>
 public int Save(SysEntities db)
 {
     return(db.SaveChanges());
 }
Ejemplo n.º 17
0
        /// <summary>
        /// 编辑一个菜单
        /// </summary>
        /// <param name="validationErrors">返回的错误信息</param>
        /// <param name="db">数据上下文</param>
        /// <param name="entity">一个菜单</param>
        /// <returns>是否编辑成功</returns>
        public bool Edit(ref ValidationErrors validationErrors, SysEntities db, SysMenu entity)
        {  /*
            * 不操作 原有 现有
            * 增加   原没 现有
            * 删除   原有 现没
            */
            if (entity == null)
            {
                return(false);
            }
            int count = 1;

            List <string> addSysOperationId    = new List <string>();
            List <string> deleteSysOperationId = new List <string>();

            DataOfDiffrent.GetDiffrent(entity.SysOperationId.GetIdSort(), entity.SysOperationIdOld.GetIdSort(), ref addSysOperationId, ref deleteSysOperationId);
            List <SysOperation> listEntitySysOperation = new List <SysOperation>();

            if (deleteSysOperationId != null && deleteSysOperationId.Count() > 0)
            {
                foreach (var item in deleteSysOperationId)
                {
                    SysOperation sys = new SysOperation {
                        Id = item
                    };
                    listEntitySysOperation.Add(sys);
                    entity.SysOperation.Add(sys);
                }
            }

            SysMenu editEntity = repository.Edit(db, entity);


            if (addSysOperationId != null && addSysOperationId.Count() > 0)
            {
                foreach (var item in addSysOperationId)
                {
                    SysOperation sys = new SysOperation {
                        Id = item
                    };
                    db.SysOperation.Attach(sys);
                    editEntity.SysOperation.Add(sys);
                    count++;
                }
            }
            if (deleteSysOperationId != null && deleteSysOperationId.Count() > 0)
            {
                foreach (SysOperation item in listEntitySysOperation)
                {
                    editEntity.SysOperation.Remove(item);
                    count++;
                }
            }

            if (count == repository.Save(db))
            {
                //修改后重置菜单编码
                List <int> flags = new List <int>();//层级
                GetMenus2(null, flags);
                db.SaveChanges();
                return(true);
            }
            else
            {
                validationErrors.Add("编辑菜单出错了");
            }
            return(false);
        }
Ejemplo n.º 18
0
        /// <summary>
        /// 注册
        /// </summary>
        public Common.Account Register(string name, string phoneNumber, string password, string inviteCode, ref string message)
        {
            //获取用户信息,请确定web.config中的连接字符串正确
            using (SysEntities db = new SysEntities())
            {
                bool invites = Convert.ToBoolean(System.Configuration.ConfigurationManager.AppSettings["InviteCodeEnabled"]);

                if (!invites)
                {
                    password = EncryptAndDecrypte.EncryptString(password);
                    var dataAccount = (from p in db.Account
                                       where p.PhoneNumber == phoneNumber ||
                                       p.Name == name
                                       select p).FirstOrDefault();
                    if (dataAccount == null)
                    {
                        Invite invite = new Invite()
                        {
                            Id    = Common.Result.GetNewId(),
                            Code  = GetByRndNum(5),
                            State = StateEnums.QY
                            ,
                            CreateTime   = DateTime.Now,
                            CreatePerson = name
                        };
                        db.Invite.Add(invite);
                        Invite invite2 = new Invite()
                        {
                            Id    = Common.Result.GetNewId(),
                            Code  = GetByRndNum(5),
                            State = StateEnums.QY
                            ,
                            CreateTime   = DateTime.Now,
                            CreatePerson = name
                        };
                        db.Invite.Add(invite2);
                        var account = new DAL.Account()
                        {
                            Id          = Common.Result.GetNewId(),
                            State       = StateEnums.QY,
                            PhoneNumber = phoneNumber,
                            Name        = name,
                            Password    = password

                            ,
                            CreateTime   = DateTime.Now,
                            CreatePerson = phoneNumber
                        };
                        db.Account.Add(account);
                        Resume resume = new Resume()
                        {
                            Id                   = Common.Result.GetNewId(),
                            AccountId            = account.Id,
                            CreateTime           = DateTime.Now,
                            CreatePerson         = name,
                            Name                 = "默认",
                            Remark               = "注册账号自动创建",
                            Sort                 = 0,
                            State                = StateEnums.QY,
                            CompletionPercentage = 0
                        };
                        db.Resume.Add(resume);

                        SysNotice notice = new SysNotice();
                        notice.Id           = Result.GetNewId();
                        notice.CreatePerson = name;
                        notice.CreateTime   = DateTime.Now;
                        notice.AccountId    = account.Id;
                        notice.Message      = "您的邀请码为:" + invite.Code + ",另一个为:" + invite2.Code;
                        db.SysNotice.Add(notice);

                        db.SaveChanges();

                        Common.Account accountCommon = new Common.Account();
                        accountCommon.ResumeId = resume.Id;
                        accountCommon.Name     = name;
                        accountCommon.Id       = account.Id;
                        return(accountCommon);
                    }
                    else
                    {
                        if (phoneNumber == dataAccount.PhoneNumber)
                        {
                            message = "手机号码已经存在";
                        }
                        else if (name == dataAccount.Name)
                        {
                            message = "绰号已经存在";
                        }
                    }
                }
                else
                {
                    var data = (from p in db.Invite
                                where p.Code == inviteCode &&
                                p.State == StateEnums.QY
                                select p).FirstOrDefault();
                    if (data != null)
                    {
                        password = EncryptAndDecrypte.EncryptString(password);
                        var dataAccount = (from p in db.Account
                                           where p.PhoneNumber == phoneNumber ||
                                           p.Name == name
                                           select p).FirstOrDefault();
                        if (dataAccount == null)
                        {
                            data.State        = StateEnums.JY;
                            data.UpdatePerson = name;
                            data.UpdateTime   = DateTime.Now;
                            Invite invite = new Invite()
                            {
                                Id    = Common.Result.GetNewId(),
                                Code  = GetByRndNum(5),
                                State = StateEnums.QY
                                ,
                                CreateTime   = DateTime.Now,
                                CreatePerson = name
                            };
                            db.Invite.Add(invite);
                            Invite invite2 = new Invite()
                            {
                                Id    = Common.Result.GetNewId(),
                                Code  = GetByRndNum(5),
                                State = StateEnums.QY
                                ,
                                CreateTime   = DateTime.Now,
                                CreatePerson = name
                            };
                            db.Invite.Add(invite2);
                            var account = new DAL.Account()
                            {
                                Id          = Common.Result.GetNewId(),
                                State       = StateEnums.QY,
                                PhoneNumber = phoneNumber,
                                Name        = name,
                                Password    = password

                                ,
                                CreateTime   = DateTime.Now,
                                CreatePerson = phoneNumber
                            };
                            db.Account.Add(account);
                            Resume resume = new Resume()
                            {
                                Id                   = Common.Result.GetNewId(),
                                AccountId            = account.Id,
                                CreateTime           = DateTime.Now,
                                CreatePerson         = name,
                                Name                 = "默认",
                                Remark               = "注册账号自动创建",
                                Sort                 = 0,
                                State                = StateEnums.QY,
                                CompletionPercentage = 0
                            };
                            db.Resume.Add(resume);

                            SysNotice notice = new SysNotice();
                            notice.Id           = Result.GetNewId();
                            notice.CreatePerson = name;
                            notice.CreateTime   = DateTime.Now;
                            notice.AccountId    = account.Id;
                            notice.Message      = "您的邀请码为:" + invite.Code + ",另一个为:" + invite2.Code;
                            db.SysNotice.Add(notice);

                            db.SaveChanges();

                            Common.Account accountCommon = new Common.Account();
                            accountCommon.ResumeId = resume.Id;
                            accountCommon.Name     = name;
                            accountCommon.Id       = account.Id;
                            return(accountCommon);
                        }
                        else
                        {
                            if (phoneNumber == dataAccount.PhoneNumber)
                            {
                                message = "手机号码已经存在";
                            }
                            else if (name == dataAccount.Name)
                            {
                                message = "绰号已经存在";
                            }
                        }
                    }
                    else
                    {
                        message = "邀请码不正确";
                    }
                }
            }
            return(null);
        }