示例#1
0
        public string Create(Ver ver)
        {
            try
            {
                dbContext.Vers.Add(ver);
                dbContext.SaveChanges();

                return Constants.AJAX_CREATE_SUCCESS_RETURN;
            }
            catch (Exception e1)
            {
                return "<p class='alert alert-danger'>出错了: " + e1.Message + "</p>";
            }
        }
示例#2
0
        public string QuickVer(Ver ver)
        {
            try
            {
                // 根据起始日期和频率,确定要制定多少条
                string[] firstDate = ver.VerYear.Split('/');
                string verYear = firstDate[0];
                int verMonth = int.Parse(firstDate[1]);
                int freq = ver.ReleaseFreq;

                int num = (12 - verMonth) / freq + 1; // 版本数量

                string[] verNos = ver.VerNo.Split('.');
                int changeVerNo = int.Parse(verNos[1]); //要变化的版本号为小数点后的数字

                for (int i = 0; i < num; i++)
                {
                    Ver v = new Ver()
                    {
                        SysID = ver.SysID,
                        VerYear = verYear,
                        ReleaseFreq = freq,
                        PublishTime = GetFourthThursday(verYear, verMonth.ToString()), // 自动设计为每月第四个周四
                        VerNo = verNos[0] + "." + changeVerNo,
                        DraftPersonID = ver.DraftPersonID,
                        VerType = "计划版本"
                    };
                    dbContext.Vers.Add(v);

                    // 月份变化
                    verMonth += freq;
                    // 版本号变化
                    changeVerNo++;
                }

                dbContext.SaveChanges();

                return Constants.AJAX_CREATE_SUCCESS_RETURN;
            }

            catch (Exception e1)
            {
                return "<p class='alert alert-danger'>出错了: " + e1.Message + "</p>";
            }
        }
示例#3
0
        public string Edit(Ver ver)
        {
            try
            {
                dbContext.Entry(ver).State = System.Data.Entity.EntityState.Modified;
                dbContext.SaveChanges();

                return Constants.AJAX_EDIT_SUCCESS_RETURN;
            }
            catch (Exception e1)
            {
                return "<p class='alert alert-danger'>出错了: " + e1.Message + "</p>";
            }
        }