Esempio n. 1
0
        public ActionResult OrgInfo_AddEdit()
        {
            string          ID         = Request["ID"]._ToStrTrim();
            string          ParentID   = Request["ParentID"]._ToStrTrim();
            List <retValue> resultList = new List <retValue>();

            //如果修改则传ID,新增则传上级ID
            if (!string.IsNullOrEmpty(ID))
            {
                retValue ret = new retValue();
                ret.result = true;
                ret.data   = "修改";
                resultList.Add(ret);
                BLL.OrgInfoBLL _OrgInfoBLL = new OrgInfoBLL();
                ret = _OrgInfoBLL.GetOrgByPK(ID._ToInt32());
                resultList.Add(ret);
                ViewData.Model = resultList;
            }
            else if (!string.IsNullOrEmpty(ParentID))
            {
                retValue ret = new retValue();
                ret.result = false;
                ret.data   = ParentID;
                resultList.Add(ret);
                ViewData.Model = resultList;
            }
            else
            {
                ViewData.Model = null;
            }
            return(View());
        }
Esempio n. 2
0
        public ActionResult OrgInfos2(int limit, int page, string Province, string CompanyCity, string CompanyUnderCity, string CompanyUnderArea)
        {
            PageModel ret = new PageModel();

            BLL.OrgInfoBLL _BLL  = new OrgInfoBLL();
            UserModel      user  = Session["UserModel"] as UserModel;
            string         OrgID = "";

            if (Province._ToInt32() > 0)
            {
                OrgID = Province;
            }
            if (CompanyCity._ToInt32() > 0)
            {
                OrgID = CompanyCity;
            }
            if (CompanyUnderCity._ToInt32() > 0)
            {
                OrgID = CompanyUnderCity;
            }
            if (CompanyUnderArea._ToInt32() > 0)
            {
                OrgID = CompanyUnderArea;
            }
            ret = _BLL.GetOrgByParentID(OrgID._ToInt32(), limit, page, user.OrgID, user.Level);
            var js = JsonConvert.SerializeObject(ret);

            return(Content(js));
        }
Esempio n. 3
0
        public JsonResult OrgInfos(string str)
        {
            retValue ret = new retValue();

            BLL.OrgInfoBLL _BLL = new OrgInfoBLL();
            UserModel      user = Session["UserModel"] as UserModel;

            ret = _BLL.GetOrgByParentID(str._ToInt32(), user.OrgID, user.Level);
            var js = JsonConvert.SerializeObject(ret);

            return(Json(js, JsonRequestBehavior.AllowGet));
        }
Esempio n. 4
0
        public JsonResult OrgInfo_Deletes(string str)
        {
            retValue ret = new retValue();

            BLL.OrgInfoBLL _BLL = new OrgInfoBLL();
            UserModel      user = Session["UserModel"] as UserModel;

            if (!string.IsNullOrEmpty(str))
            {
                ret = _BLL.DeleteByPK(str, user.Level);
            }
            var js = JsonConvert.SerializeObject(ret);

            return(Json(js, JsonRequestBehavior.AllowGet));
        }
Esempio n. 5
0
        public ActionResult OrgInfo_AddEdits(string str)
        {
            retValue ret = new retValue();

            BLL.OrgInfoBLL _BLL = new OrgInfoBLL();
            JObject        o    = null;

            if (!string.IsNullOrEmpty(str))
            {
                o = JObject.Parse(str);

                string    ID      = o["ID"]._ToStrTrim();
                string    NAME    = o["Name"]._ToStrTrim();
                string    OrgCode = o["OrgCode"]._ToStrTrim();
                string    Address = o["Address"]._ToStrTrim();
                UserModel user    = Session["UserModel"] as UserModel;
                //新增
                if (string.IsNullOrEmpty(ID))
                {
                    string Province         = o["Province"]._ToStrTrim();
                    string CompanyCity      = o["CompanyCity"]._ToStrTrim();
                    string CompanyUnderCity = o["CompanyUnderCity"]._ToStrTrim();
                    string CompanyUnderArea = o["CompanyUnderArea"]._ToStrTrim();
                    string OrgID            = "";
                    if (Province._ToInt32() > 0)
                    {
                        OrgID = Province;
                    }
                    if (CompanyCity._ToInt32() > 0)
                    {
                        OrgID = CompanyCity;
                    }
                    if (CompanyUnderCity._ToInt32() > 0)
                    {
                        OrgID = CompanyUnderCity;
                    }
                    if (CompanyUnderArea._ToInt32() > 0)
                    {
                        OrgID = CompanyUnderArea;
                    }
                    int level = 0;
                    ret = _BLL.GetOrgByPK(OrgID._ToInt32());
                    if (ret.result)
                    {
                        level = ((DataTable)ret.data).Rows[0]["Level"]._ToInt32() + 1;
                    }
                    if (user.Level > level)
                    {
                        ret.result = false;
                        ret.reason = "您不能添加当前级别的机构";
                    }
                    else
                    {
                        ret = _BLL.insert(NAME, Address, OrgCode, OrgID._ToInt32(), level);
                    }
                }
                //更新
                else
                {
                    int level = 0;
                    ret = _BLL.GetOrgByPK(ID._ToInt32());
                    if (ret.result)
                    {
                        level = ((DataTable)ret.data).Rows[0]["Level"]._ToInt32();

                        if (user.Level > level)
                        {
                            ret.result = false;
                            ret.reason = "您不能更新当前级别的机构";
                        }
                        else
                        {
                            ret = _BLL.update(ID._ToInt32(), NAME, OrgCode, Address);
                        }
                    }
                }
            }
            var js = JsonConvert.SerializeObject(ret);

            return(Json(js, JsonRequestBehavior.AllowGet));
        }
Esempio n. 6
0
        //// <summary>
        /// 这里保存上传的文件到服务器上面
        /// </summary>
        /// <param name="file">上传文件实例,名称应该和前台页面上的上传控件name属性一致</param>
        /// <returns></returns>
        public ActionResult Order_PL(HttpPostedFileBase file)
        {
            retValue ret = new retValue();

            ret.result = true;
            if (file == null)
            {
                ret.result = false;
                ret.reason = "请选择上传文件!";
            }
            else
            {
                PMS.Models.UserModel userModel = Session["UserModel"] as PMS.Models.UserModel;
                int    userid   = userModel._ID;
                Random r        = new Random();
                var    fileExt  = System.IO.Path.GetExtension(file.FileName).Substring(1);
                var    filename = DateTime.Now.ToString("yyyyMMddHHmmss") + r.Next(10000) + "." + fileExt;
                var    filepath = System.IO.Path.Combine(Server.MapPath("~/Images"), filename);
                var    savepath = "/Images/" + filename;
                file.SaveAs(filepath);
                BLL.OrderInfoBLL _bll = new OrderInfoBLL();
                BLL.OrgInfoBLL   _Org = new OrgInfoBLL();
                DataTable        dt   = OpenFile(filepath);
                //删除文件
                FileInfo fileInfo = new FileInfo(filepath);
                fileInfo.Delete();
                if (dt == null || dt.Rows.Count == 0)
                {
                    ret.result = false;
                    ret.reason = "Excel中没有数据";
                }
                else
                {
                    int           count    = 0;
                    SqlHelp       dbhelper = new SqlHelp();
                    SqlConnection conn     = new SqlConnection(dbhelper.SqlConnectionString);
                    conn.Open();
                    using (SqlTransaction tran = conn.BeginTransaction())
                    {
                        try
                        {
                            foreach (DataRow item in dt.Rows)
                            {
                                int orgid = _Org.GetIDByName(item["OrgName"]._ToStrTrim());
                                if (orgid == 0)
                                {
                                    ret.result = false;
                                    ret.reason = "第" + (dt.Rows.IndexOf(item) + 1) + "行数据机构填写不正确";
                                    break;
                                }
                                else if (string.IsNullOrEmpty(item["BKDH"]._ToStrTrim()))
                                {
                                    ret.result = false;
                                    ret.reason = "第" + (dt.Rows.IndexOf(item) + 1) + "行数据报刊代号不能为空"; break;
                                }
                                else if (item["OrderNum"]._ToInt32() <= 0)
                                {
                                    ret.result = false;
                                    ret.reason = "第" + (dt.Rows.IndexOf(item) + 1) + "行数据订购数必须大于0"; break;
                                }
                                else if (item["OrderMonths"]._ToInt32() <= 0)
                                {
                                    ret.result = false;
                                    ret.reason = "第" + (dt.Rows.IndexOf(item) + 1) + "行数据订购月数必须大于0"; break;
                                }
                                else if (string.IsNullOrEmpty(item["Indate"]._ToStrTrim()))
                                {
                                    ret.result = false;
                                    ret.reason = "第" + (dt.Rows.IndexOf(item) + 1) + "行数据订购起始日期不能为空"; break;
                                }
                                else if (string.IsNullOrEmpty(item["OrderNo"]._ToStrTrim()))
                                {
                                    ret.result = false;
                                    ret.reason = "第" + (dt.Rows.IndexOf(item) + 1) + "行数据订户单位编号不能为空"; break;
                                }
                                else
                                {
                                    ret = _bll.Insert(item["BKDH"]._ToStrTrim(), item["OrderNum"]._ToInt32(), item["OrderMonths"]._ToInt32(), item["Indate"]._ToStrTrim(), userid._ToStr(),
                                                      0, item["OrderNo"]._ToStrTrim(), item["UnitName"]._ToStrTrim(), item["Address"]._ToStrTrim(), item["Name"]._ToStrTrim(), item["Phone"]._ToStrTrim(), orgid._ToStr(), tran, userid._ToStr());
                                    count++;
                                    if (!ret.result)
                                    {
                                        tran.Rollback();
                                        return(Json(JsonConvert.SerializeObject(ret), JsonRequestBehavior.AllowGet));
                                    }
                                }
                            }
                            if (!ret.result)
                            {
                                tran.Rollback();
                            }
                            else
                            {
                                tran.Commit();
                                ret.result = true;
                                ret.data   = "导入成功";
                            }
                        }
                        catch (Exception ex)
                        {
                            ret.result = false;
                            ret.reason = ex.Message;
                            tran.Rollback();
                        }
                    }
                    conn.Close();
                }
            }
            var js = JsonConvert.SerializeObject(ret);

            return(Json(js, JsonRequestBehavior.AllowGet));
        }