示例#1
0
        protected void btn_Save_Click(object sender, EventArgs e)
        {
            bool issucess = false;
            //if (IsValidate)
            //{

            string[] classCodes = Request.Form.GetValues("clsCode");
            string[] nums = Request.Form.GetValues("num");
            string[] skills = Request.Form.GetValues("skill");
            string[] summarys = Request.Form.GetValues("summary");
            try
            {
                if (IsInputValidate(classCodes, nums, skills, summarys))
                {
                    CY.GFive.Core.Business.SkillStatisticsItem item;
                    for (int i = 0; i < classCodes.Length; i++)
                    {
                        item = new CY.GFive.Core.Business.SkillStatisticsItem();
                        item.ClsCode = classCodes[i];
                        item.Num = Convert.ToInt32(nums[i]);
                        item.SkillLvl = skills[i];
                        item.Summary = summarys[i];
                        item.SkillStatisticeId = IntQueryString;
                        item.Save();
                    }
                    issucess = true;
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {

            }
            //}
            if (issucess)
            {
                Page.ClientScript.RegisterClientScriptBlock(GetType(), "script", "<script type='text/javascript'>alert('修改成功!');window.location.href=window.location.href;</script>");
                return;
            }
            else
            {
                Page.ClientScript.RegisterClientScriptBlock(GetType(), "script", "<script type='text/javascript'>alert('修改失败,请检查输入参数是否正确!');</script>");
                return;
            }
        }
示例#2
0
        private string HandlerData(HttpContext context)
        {
            StringBuilder returnvalue = new StringBuilder();
            bool issucess = false;
            bool isvalid = true;
            try
            {
                string checkcode = context.Request["checkcode"];
                string year = context.Request["year"];
                string term = context.Request["term"];
                string week = context.Request["week"];
                string lsinfo = context.Request["lsinfo"];

                List<SkillStatiticsItem> items = Newtonsoft.Json.JavaScriptConvert.DeserializeObject(lsinfo, typeof(List<SkillStatiticsItem>)) as List<SkillStatiticsItem>;
                if (items.Count > 0)
                {
                    for (int i = 0; i < items.Count; i++)
                    {
                        for (int j = i + 1; j < items.Count; j++)
                        {
                            if (items[i].Skill == items[j].Skill && items[i].ClassCode == items[j].ClassCode)
                            {
                                isvalid = false;
                                break;
                            }
                        }
                        if (!isvalid)
                            break;
                    }
                }
                else
                {
                    isvalid = false;
                }

                if (isvalid)
                {
                    CY.GFive.Core.Business.SkillStatistics skill = new CY.GFive.Core.Business.SkillStatistics();
                    CY.GFive.Core.Business.SkillStatistics tempcheck = CY.GFive.Core.Business.SkillStatistics.GetInstance(checkcode);
                    if (tempcheck != null)
                    {
                        returnvalue.Append("{return:false,errormsg:'skillcheck'}");
                        return returnvalue.ToString();
                    }
                    skill.LftCode = checkcode;

                    skill.CheckedYear = year;

                    skill.Term = term;

                    int temp = 0;
                    if (int.TryParse(week, out temp))
                    {
                        skill.CheckedWeek = temp;

                    }

                    skill.CheckedDepart = CheckedDepart;

                    skill.InputDate = DateTime.Now.ToShortDateString();

                    skill.Inputter = Inputter;

                    skill.Save();

                    for (int i = 0; i < items.Count; i++)
                    {
                        CY.GFive.Core.Business.SkillStatisticsItem item = new CY.GFive.Core.Business.SkillStatisticsItem();
                        item.Num = items[i].Num;
                        item.ClsCode = items[i].ClassCode;
                        item.SkillLvl = items[i].Skill;
                        item.Summary = items[i].Sum;
                        item.SkillStatisticeId = skill.Id;
                        item.Save();
                    }
                    issucess = true;
                }

            }
            catch (Exception ex)
            {
               //throw ex;
            }
            finally
            {
                if (issucess)
                {
                    returnvalue.Append("{result:true}");
                }
                else
                {
                    returnvalue.Append("{return:false}");
                }
            }

            return returnvalue.ToString();
        }