Beispiel #1
0
        public ActionResult Edit(T_QY_Corp t_qy_corp, FormCollection collection)
        {
            if (ModelState.IsValid)
            {
                db.Entry(t_qy_corp).State = EntityState.Modified;
                t_qy_corp.Remark = t_qy_corp.Remark == null ? "" : t_qy_corp.Remark;
                t_qy_corp.UpdateTime = DateTime.Now;

                HttpPostedFileBase file = Request.Files[0];
                //存入文件
                if (file.ContentLength > 0)
                {
                    t_qy_corp.Logo = new byte[Request.Files[0].InputStream.Length];
                    Request.Files[0].InputStream.Read(t_qy_corp.Logo, 0, t_qy_corp.Logo.Length);
                }

                string cyear = collection["FYear"].ToString();
                if (db.T_QY_Financial.Where(f => (f.CorpID == t_qy_corp.ID && f.CurYear == cyear)).Count() > 0)
                {
                    db.T_QY_Financial.Where(f => f.CurYear == cyear).FirstOrDefault().TotalAssets = Convert.ToDecimal(collection["TotalAssets"]);
                    db.T_QY_Financial.Where(f => f.CurYear == cyear).FirstOrDefault().Revenue = Convert.ToDecimal(collection["Revenue"]);
                }
                else
                {
                    T_QY_Financial financial = new T_QY_Financial();
                    financial.CorpID = t_qy_corp.ID;
                    financial.CurYear = cyear;
                    if (collection["TotalAssets"] != "")
                        financial.TotalAssets = Convert.ToDecimal(collection["TotalAssets"]);
                    else
                        financial.TotalAssets = 0;
                    if (collection["Revenue"] != "")
                        financial.Revenue = Convert.ToDecimal(collection["Revenue"]);
                    else
                        financial.Revenue = 0;
                    db.T_QY_Financial.Add(financial);
                }
                if (db.T_QY_Product.Where(f => f.CorpID == t_qy_corp.ID).Count() > 0)
                {
                    db.T_QY_Product.Where(f => f.CorpID == t_qy_corp.ID).FirstOrDefault().ProductName = collection["ProductName"];
                    db.T_QY_Product.Where(f => f.CorpID == t_qy_corp.ID).FirstOrDefault().Content = collection["Content"];
                }
                else
                {
                    T_QY_Product Product = new T_QY_Product();
                    Product.CorpID = t_qy_corp.ID;
                    Product.ProductName = collection["ProductName"];
                    Product.Content = collection["Content"];
                    db.T_QY_Product.Add(Product);
                }
                int result = db.SaveChanges();
                if (result > 0)
                    return ReturnJson(true, "操作成功", "", "", true, "");
                else
                    return ReturnJson(false, "操作失败", "", "", false, "");
            }
            ViewBag.MemberID = new SelectList(db.T_HY_Member, "ID", "LoginName", t_qy_corp.MemberID);
            return Json(new { });
        }
Beispiel #2
0
        public ActionResult Edit(T_QY_Corp t_qy_corp, FormCollection collection)
        {
            if (ModelState.IsValid)
            {
                db.Entry(t_qy_corp).State = EntityState.Modified;
                t_qy_corp.Remark = t_qy_corp.Remark == null ? "" : t_qy_corp.Remark;
                t_qy_corp.UpdateTime = DateTime.Now;
                if (collection["RegTime"].Trim() == "")
                    t_qy_corp.RegTime = DateTime.Now;
                string cyear = collection["FYear"].ToString();
                if (db.T_QY_Financial.Where(f => (f.CorpID == t_qy_corp.ID && f.CurYear == cyear)).Count() > 0)
                {
                    decimal assets = 0;
                    decimal revenue = 0;
                    if (collection["TotalAssets"] != "")
                        assets = Convert.ToDecimal(collection["TotalAssets"]);
                    if (collection["Revenue"] != "")
                        revenue = Convert.ToDecimal(collection["Revenue"]);

                    db.T_QY_Financial.Where(f => (f.CorpID == t_qy_corp.ID && f.CurYear == cyear)).FirstOrDefault().TotalAssets = assets;
                    db.T_QY_Financial.Where(f => (f.CorpID == t_qy_corp.ID && f.CurYear == cyear)).FirstOrDefault().Revenue = revenue;
                }
                else
                {
                    T_QY_Financial financial = new T_QY_Financial();
                    financial.CorpID = t_qy_corp.ID;
                    financial.CurYear = cyear;
                    if (collection["TotalAssets"] != "")
                        financial.TotalAssets = Convert.ToDecimal(collection["TotalAssets"]);
                    else
                        financial.TotalAssets = 0;
                    if (collection["Revenue"] != "")
                        financial.Revenue = Convert.ToDecimal(collection["Revenue"]);
                    else
                        financial.Revenue = 0;
                    db.T_QY_Financial.Add(financial);
                }
                if (db.T_QY_Product.Where(f => f.CorpID == t_qy_corp.ID).Count() > 0)
                {
                    db.T_QY_Product.Where(f => f.CorpID == t_qy_corp.ID).FirstOrDefault().ProductName = collection["ProductName"];
                    db.T_QY_Product.Where(f => f.CorpID == t_qy_corp.ID).FirstOrDefault().Content = collection["Content"];
                }
                else
                {
                    T_QY_Product Product = new T_QY_Product();
                    Product.CorpID = t_qy_corp.ID;
                    Product.ProductName = collection["ProductName"];
                    Product.Content = collection["Content"];
                    db.T_QY_Product.Add(Product);
                }
                db.SaveChanges();

                Logging("更新了企业详细信息", (int)OperateTypes.Edit,  (int)GenerateSystem.Personal);
                return Json(new { statusCode = "200", message = "信息保存成功!", type = "success" });
            }
            return Json(new { statusCode = "200", message = "信息保存失败!", type = "error" });
        }