Ejemplo n.º 1
0
        public ActionResult DoEditProject(string projectID, string ProjectName, string ddlCounty,
                                          string tbPartyA, string ddlPartyB, string tbResponsiblePerson,
                                          string tbContact, string nbMoney, string ddlMoneyUnit,
                                          string dpDate)
        {
            if (Session["username"] == null || Session["username"].Equals(""))
            {
                return(RedirectToAction("Index", "Session"));
            }


            if (String.IsNullOrEmpty(projectID) || String.IsNullOrEmpty(ddlCounty) ||
                String.IsNullOrEmpty(tbPartyA) || String.IsNullOrEmpty(ddlPartyB) ||
                String.IsNullOrEmpty(nbMoney) || String.IsNullOrEmpty(dpDate))
            {
                return(RedirectToAction("LackOfJS", "Home"));
            }


            using (var db = new ProjectManagementEntities())
            {
                int pid = Convert.ToInt32(projectID);
                var p   = db.Project.Where(u => u.ID == pid).FirstOrDefault();
                if (p != null)
                {
                    p.Name     = ProjectName;
                    p.CountyID = Convert.ToInt32(ddlCounty);

                    p.PartyAName        = tbPartyA;
                    p.PartyBID          = Convert.ToInt32(ddlPartyB);
                    p.ResponsiblePerson = tbResponsiblePerson;
                    p.ContactPhone      = tbContact;

                    p.Money = computeMoney(nbMoney, ddlMoneyUnit);
                    p.Date  = DateTime.ParseExact(dpDate, "yyyy-MM-dd", System.Globalization.CultureInfo.CurrentCulture);
                }
                try
                {
                    var rowCount = db.SaveChanges();
                    if (rowCount > 0)
                    {
                        ShowNotify("项目修改成功", MessageBoxIcon.Success);
                    }
                    else
                    {
                        ShowNotify("项目未修改", MessageBoxIcon.Information);
                    }
                    ActiveWindow.Hide();
                }
                catch (System.Data.Entity.Validation.DbEntityValidationException)
                {
                    ShowNotify("数据无效,请检查表单!", MessageBoxIcon.Error);
                }
                catch (Exception)
                {
                    ShowNotify("服务器发生了未能处理的异常,请联系技术人员进行检测。", MessageBoxIcon.Error);
                }
            }
            return(UIHelper.Result());
        }
Ejemplo n.º 2
0
 public static bool HideActiveWindow()
 {
     if (isShowingWindow)
     {
         ActiveWindow.Hide();
         return(true);
     }
     return(false);
 }