示例#1
0
        public ActionResult Edit(string seqNo, string searchNo, string unitName, string itemName, string chargeClassify, string chargeTime, string totalExpense, string theoryExpense, string a4total, string a4picPricePer, string a4pic, string a4picTotalFee, string a4word, string a4wordPricePer, string a4wordTotalFee, string a3total, string a3pic, string a3picPricePer, string a3picTotalFee, string a3word, string a3wordPricePer, string a3wordTotalFee, string a2total, string a2pic, string a2picPricePer, string a2picTotalFee, string a1total, string a1pic, string a1picPricePer, string a1picTotalFee, string a0total, string a0pic, string a0picPricePer, string a0picTotalFee, string a1totalLonger, string a1picLonge, string a1picPricePerLonger, string a1picTotalFeeLonger, string a0totalLonger, string a0picLonger, string a0picPricePerLonger, string a0picTotalFeeLonger, string fromDepartment, string @operator, string remarks, string chargeExtra, string buildingArea, string centiCnt, string whereTransfer, string action, long?id)


        {
            Charger charge = db.Charger.Find(id);

            if (action == "修改")
            {
                bool   flag  = false;
                string roles = User.Identity.Name.ToString();
                if (roles == "打印")
                {
                    flag = true;
                }
                if (flag == true)
                {
                    if (chargeClassify.Trim() == "4")
                    {
                        var file = from a in db.FuyinFeeDetail
                                   where a.feeListNo == seqNo
                                   select a;
                        if (file.Count() != 0)
                        {
                            FuyinFeeDetail filefuyin = file.First();
                            if (a4total == "" || a4total == null)
                            {
                                a4total = "0";
                            }
                            int A4pageCnt = int.Parse(a4total.Trim());
                            filefuyin.A4PageCnt = A4pageCnt;
                            if (a4pic == "" || a4pic == null)
                            {
                                a4total = "0";
                            }
                            int A4picCnt = int.Parse(a4pic.Trim());
                            filefuyin.A4DrawingCnt = A4picCnt;
                            if (a4picPricePer == "" || a4picPricePer == null)
                            {
                                a4total = "0";
                            }
                            float A4picprice = float.Parse(a4picPricePer.Trim());
                            filefuyin.A4DrawingUnitPrice = A4picprice;
                            if (a4picTotalFee == "" || a4picTotalFee == null)
                            {
                                a4total = "0";
                            }
                            float A4pictotal = float.Parse(a4picTotalFee.Trim());
                            filefuyin.A4DrawingFee = A4pictotal;
                            if (a4word == "" || a4word == null)
                            {
                                a4total = "0";
                            }

                            int A4wordCnt = int.Parse(a4word.Trim());
                            filefuyin.A4TextCnt = A4wordCnt;
                            if (a4wordPricePer == "" || a4wordPricePer == null)
                            {
                                a4total = "0";
                            }
                            float A4wordprice = float.Parse(a4wordPricePer.Trim());
                            filefuyin.A3TextUnitPrice = A4wordprice;
                            if (a4wordTotalFee == "" || a4wordTotalFee == null)
                            {
                                a4total = "0";
                            }
                            float A4wordtotal = float.Parse(a4wordTotalFee.Trim());
                            filefuyin.A4TextFee = A4wordtotal;
                            if (a3total == "" || a3total == null)
                            {
                                a4total = "0";
                            }
                            int a3pagecn = int.Parse(a3total.Trim());
                            filefuyin.A3PageCnt = a3pagecn;
                            if (a3pic == "" || a3pic == null)
                            {
                                a4total = "0";
                            }
                            int A3piccnt = int.Parse(a3pic.Trim());
                            filefuyin.A3DrawingCnt = A3piccnt;
                            if (a3picPricePer == "" || a3picPricePer == null)
                            {
                                a4total = "0";
                            }
                            float A3picprice = float.Parse(a3picPricePer.Trim());
                            filefuyin.A3DrawingUnitPrice = A3picprice;
                            if (a3picTotalFee == "" || a3picTotalFee == null)
                            {
                                a4total = "0";
                            }
                            float A3pictotal = float.Parse(a3picTotalFee.Trim());
                            filefuyin.A3DrawingFee = A3pictotal;
                            if (a3word == "" || a3word == null)
                            {
                                a4total = "0";
                            }
                            int A3wordcnt = int.Parse(a3word.Trim());
                            filefuyin.A3TextCnt = A3wordcnt;
                            if (a3wordPricePer == "" || a3wordPricePer == null)
                            {
                                a4total = "0";
                            }
                            float A3wordprice = float.Parse(a3wordPricePer.Trim());
                            filefuyin.A3TextUnitPrice = A3wordprice;
                            if (a3wordTotalFee == "" || a3wordTotalFee == null)
                            {
                                a4total = "0";
                            }
                            float A3wordtotal = float.Parse(a3wordTotalFee.Trim());
                            filefuyin.A3TextFee = A3wordtotal;
                            if (a2total == "" || a2total == null)
                            {
                                a4total = "0";
                            }
                            int A2pagecn = int.Parse(a2total.Trim());
                            filefuyin.A4PageCnt = A4pageCnt;
                            if (a2pic == "" || a2pic == null)
                            {
                                a4total = "0";
                            }
                            int A2pageCnt = int.Parse(a2pic.Trim());
                            filefuyin.A2PageCnt = A2pageCnt;
                            if (a2picPricePer == "" || a2picPricePer == null)
                            {
                                a4total = "0";
                            }
                            float A2picprice = float.Parse(a2picPricePer.Trim());
                            filefuyin.A2DrawingUnitPrice = A2picprice;
                            if (a2picTotalFee == "" || a2picTotalFee == null)
                            {
                                a4total = "0";
                            }
                            float A2pictoyal = float.Parse(a2picTotalFee.Trim());
                            filefuyin.A2DrawingFee = A2pictoyal;
                            if (a1total == "" || a1total == null)
                            {
                                a4total = "0";
                            }
                            int A1pageCnt = int.Parse(a1total.Trim());
                            filefuyin.A1PageCnt = A1pageCnt;
                            if (a1pic == "" || a1pic == null)
                            {
                                a4total = "0";
                            }
                            int A1picCnt = int.Parse(a1pic.Trim());
                            filefuyin.A1DrawingCnt = A1picCnt;
                            if (a1picPricePer == "" || a1picPricePer == null)
                            {
                                a4total = "0";
                            }
                            float A1picprice = float.Parse(a1picPricePer.Trim());
                            filefuyin.A1DrawingUnitPrice = A1picprice;
                            if (a1picTotalFee == "" || a1picTotalFee == null)
                            {
                                a4total = "0";
                            }
                            float A1pictotal = float.Parse(a1picTotalFee.Trim());
                            filefuyin.A1DrawingFee = A1pictotal;
                            if (a0total == "" || a0total == null)
                            {
                                a4total = "0";
                            }
                            int A0pageCnt = int.Parse(a0total.Trim());
                            filefuyin.A0PageCnt = A0pageCnt;
                            if (a0pic == "" || a0pic == null)
                            {
                                a4total = "0";
                            }
                            int A0picCnt = int.Parse(a0pic.Trim());
                            filefuyin.A0DrawingCnt = A0picCnt;
                            if (a0picPricePer == "" || a0picPricePer == null)
                            {
                                a4total = "0";
                            }
                            float A0picprice = float.Parse(a0picPricePer.Trim());
                            filefuyin.A0DrawingUnitPrice = A0picprice;
                            if (a0picTotalFee == "" || a0picTotalFee == null)
                            {
                                a4total = "0";
                            }
                            float A0total = float.Parse(a0picTotalFee.Trim());
                            filefuyin.A0DrawingFee = A0total;

                            if (a1totalLonger == "" || a1totalLonger == null)
                            {
                                a4total = "0";
                            }
                            int A1addpageCnt = int.Parse(a1totalLonger.Trim());
                            filefuyin.A1AddDrawingCnt = A1addpageCnt;
                            if (a1picLonge == "" || a1picLonge == null)
                            {
                                a4total = "0";
                            }
                            int A1addpiccnt = int.Parse(a1picLonge.Trim());
                            filefuyin.A1AddDrawingCnt = A1addpiccnt;
                            if (a1picPricePerLonger == "" || a1picPricePerLonger == null)
                            {
                                a4total = "0";
                            }
                            float A1addpicprice = float.Parse(a1picPricePerLonger.Trim());
                            filefuyin.A1AddDrawingUnitPrice = A1addpicprice;
                            if (a1picTotalFeeLonger == "" || a1picTotalFeeLonger == null)
                            {
                                a4total = "0";
                            }
                            float A1addtotal = float.Parse(a1picTotalFeeLonger);
                            filefuyin.A1AddDrawingFee = A1addtotal;
                            if (a0totalLonger == "" || a0totalLonger == null)
                            {
                                a4total = "0";
                            }
                            int a0addpagecnt = int.Parse(a0totalLonger.Trim());
                            filefuyin.A0AddPageCnt = a0addpagecnt;
                            if (a0picLonger == "" || a0picLonger == null)
                            {
                                a4total = "0";
                            }
                            int A0addpiccnt = int.Parse(a0picLonger.Trim());
                            filefuyin.A0AddDrawingCnt = A0addpiccnt;
                            if (a0picPricePerLonger == "" || a0picPricePerLonger == null)
                            {
                                a4total = "0";
                            }
                            float a0addprice = float.Parse(a0picPricePerLonger.Trim());
                            filefuyin.A0AddDrawingFee = a0addprice;
                            if (a0picTotalFeeLonger == "" || a0picTotalFeeLonger == null)
                            {
                                a4total = "0";
                            }
                            float A0addtotal = float.Parse(a0picTotalFeeLonger.Trim());
                            filefuyin.A0AddDrawingFee = A0addtotal;
                            DateTime chargetime = DateTime.Today;
                            filefuyin.dateCharged = chargetime;
                            filefuyin.unitCharged = @operator;
                            if (theoryExpense.Trim() != "" || theoryExpense.Trim() == null)
                            {
                                filefuyin.theoryFee = double.Parse(theoryExpense.Trim());
                            }
                            filefuyin.searchNo = seqNo.Trim();
                            if (totalExpense.Trim() != "")
                            {
                                filefuyin.totalFee = double.Parse(totalExpense.Trim());
                            }
                            db.Entry(filefuyin).State = EntityState.Modified;
                        }
                    }
                }
                if (charge != null)
                {
                    charge.unitName = unitName;
                    charge.itemName = itemName;
                    bool flag1 = false;
                    var  type  = from a in db.ChargeType
                                 where a.value.ToString() == chargeClassify
                                 select a;
                    if (type.Count() != 0)
                    {
                        flag1 = true;
                        charge.chargeClassify = Convert.ToInt32(chargeClassify);
                    }
                    if (flag1 == false)
                    {
                        //将新的收费项添加到列表中区
                        var type1 = from b in db.ChargeType
                                    orderby b.value descending
                                    select b;
                        ChargeType type3 = new ChargeType();
                        type3.value = type1.First().value + 1;
                        type3.text  = chargeClassify;
                        db.ChargeType.Add(type3);
                    }
                    charge.@operator = @operator;
                    charge.seqNo     = seqNo;
                    charge.remarks   = remarks;
                    DateTime time = Convert.ToDateTime(chargeTime);
                    charge.chargeTime = time;
                    if (totalExpense.Trim() != "")
                    {
                        charge.totalExpense = decimal.Parse(totalExpense.Trim());
                    }
                    else
                    {
                        return(Content("<script >alert('实际收费不能为空!');window.history.back();</script >"));
                    }
                    if (theoryExpense.Trim() != "")
                    {
                        charge.theoryExpense = decimal.Parse(theoryExpense.Trim());
                    }
                    else
                    {
                        charge.theoryExpense = charge.totalExpense;
                    }
                    charge.fromDepartment = fromDepartment;
                    charge.whereTransfer  = Int32.Parse(whereTransfer);
                    charge.chargeDetail   = "收取" + charge.unitName + "," + charge.itemName + ",共" + totalExpense.Trim() + "元";
                    charge.isBack         = false;
                    if (charge.fromDepartment.Trim() == "1")//来自业务科
                    {
                        if (chargeExtra == "1")
                        {
                            charge.chargeExtra = "1";
                        }
                        if (chargeExtra == "2")
                        {
                            charge.chargeExtra = "2";
                            if (centiCnt.Trim() == "")
                            {
                                return(Content("<script >alert('公分数不能为空!');window.history.back();</script >"));
                            }
                            charge.centiCnt = float.Parse(centiCnt.Trim());
                        }
                        if (buildingArea.Trim() == "")
                        {
                            return(Content("<script >alert('建筑面积不能为空!');window.history.back();</script >"));
                        }
                        charge.searchNo     = Int32.Parse(searchNo);
                        charge.buildingArea = float.Parse(buildingArea.Trim());
                    }
                    try
                    {
                        db.Entry(charge).State = EntityState.Modified;
                        db.SaveChanges();
                        ViewData["xiugai"] = true;
                        return(Content("<script >alert('收费修改成功');window.history.back();</script >"));
                    }
                    catch (System.Exception ex)
                    {
                        Response.Write("<script language=\'javascript\'>alert('" + ex.Message + "');</script>");
                    }
                }
            }
            if (action == "返回")             //jsy修改
            {
                if (charge.centiCnt != -1)
                {
                    return(RedirectToAction("Create", "ProjectCharge"));
                }
                else
                {
                    return(RedirectToAction("OtherFeiYongChaXun", "Charge"));
                }
            }
            //jsy修改

            return(View());
        }
示例#2
0
        // GET: ProjectCharge/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            var test = from ad in db.vw_charge
                       where (ad.ID == id)
                       select ad;
            vw_charge charge = test.First();

            var test1 = from a in db.FuyinFeeDetail
                        where a.feeListNo == charge.seqNo
                        select a;

            //jsy添加
            if (charge.isCharge == true)
            {
                Response.Write("<script>alert('此费用已经收取,不能进行修改 !');window.history.back();</script>");
            }

            //jsy添加
            if (charge == null)
            {
                return(HttpNotFound());
            }

            else
            {
                if (charge.chargeExtra.Trim() == "1" || charge.chargeExtra == "")
                {
                    charge.chargeExtra = "1";
                }

                //相关控件的初始化
                ViewBag.chargeClassify = new SelectList(db.ChargeType, "value", "text", charge.chargeClassify);
                ViewBag.fromDepartment = new SelectList(db.DepartmentCode, "value", "text", charge.fromDepartment);
                ViewBag.operator1      = new SelectList(user.AspNetUsers, "UserName", "UserName", charge.@operator);
                //费用转向
                List <SelectListItem> list = new List <SelectListItem> {
                    new SelectListItem {
                        Text = "转向复印室", Value = "0"
                    },
                    new SelectListItem {
                        Text = "转向财务科", Value = "1"
                    },
                };

                ViewBag.whereTransfer = new SelectList(list, "Value", "Text", charge.whereTransfer);
                if (test1.Count() != 0)
                {
                    FuyinFeeDetail charge1 = test1.First();


                    ViewData["a4total"]             = charge1.A4PageCnt;
                    ViewData["a4word"]              = charge1.A4TextCnt;
                    ViewData["a4pic"]               = charge1.A4DrawingCnt;
                    ViewData["a4wordTotalFee"]      = charge1.A4TextFee;
                    ViewData["a4picTotalFee"]       = charge1.A4DrawingFee;
                    ViewData["a3total"]             = charge1.A3PageCnt;
                    ViewData["a3word"]              = charge1.A3TextCnt;
                    ViewData["a3pic"]               = charge1.A3DrawingCnt;
                    ViewData["a3wordTotalFee"]      = charge1.A3TextFee;
                    ViewData["a3picTotalFee"]       = charge1.A4DrawingFee;
                    ViewData["a2total"]             = charge1.A2PageCnt;
                    ViewData[" a2pic"]              = charge1.A2DrawingCnt;
                    ViewData["a2picTotalFee"]       = charge1.A2DrawingFee;
                    ViewData["a1total"]             = charge1.A1PageCnt;
                    ViewData["a1pic"]               = charge1.A1DrawingCnt;
                    ViewData["a1picTotalFee"]       = charge1.A1DrawingFee;
                    ViewData["a0total"]             = charge1.A0PageCnt;
                    ViewData["a0pic"]               = charge1.A1AddDrawingCnt;
                    ViewData["a0picTotalFee"]       = charge1.A0DrawingFee;
                    ViewData["a0totalLonger"]       = charge1.A0AddPageCnt;
                    ViewData["a0picLonger"]         = charge1.A0DrawingCnt;
                    ViewData["a0picTotalFeeLonger"] = charge1.A0AddDrawingFee;
                    ViewData["a1totalLonger"]       = charge1.A1AddPageCnt;
                    ViewData["a1picLonger"]         = charge1.A1DrawingCnt;
                    ViewData["a1picTotalFeeLonger"] = charge1.A1AddDrawingFee;
                }
            }

            return(View(charge));
        }