protected void rbtnOK_Click(object sender, EventArgs e) { System.Guid KeyIdGuid; string successFlag;//标记数据库操作是否成功 int startCycleIndex = 0; int endCycleIndex = 0; startCycleIndex = rctxtStartingCycle.SelectedIndex; endCycleIndex = rctxtStartingCycle.FindItemIndexByValue(rctxtEndingCycle.SelectedValue); if (rctxtCompany.SelectedValue != "N/A" && rctxtStartingCycle.SelectedValue != "N/A" && rctxtEndingCycle.SelectedValue != "N/A") { if (startCycleIndex < endCycleIndex || startCycleIndex == endCycleIndex) { if (this.KeyId == string.Empty)//新增 { //将数据保存到客户端cookie HttpCookie myCookie = new HttpCookie("Billing"); if (rctxtCompany.SelectedItem != null) { myCookie.Values.Add("Company", rctxtCompany.SelectedItem.Value); } if (rctxtStartingCycle.SelectedItem != null) { myCookie.Values.Add("StartingCycle", rctxtStartingCycle.SelectedItem.Value); } if (rctxtEndingCycle.SelectedItem != null) { myCookie.Values.Add("EndingCycle", rctxtEndingCycle.SelectedItem.Value); } if (rctxtStatusCode.SelectedItem != null) { myCookie.Values.Add("StatusCode", rctxtStatusCode.SelectedItem.Value); } myCookie.Values.Add("AllCycles", chkAllCycles.Checked.ToString()); myCookie.Values.Add("Copy", chkCopy.Checked.ToString()); myCookie.Values.Add("Calc", chkCalc.Checked.ToString()); myCookie.Expires = System.DateTime.Now.AddDays(1); Response.AppendCookie(myCookie); Response.Redirect("~/Schedule Billing/TaskDetailForm.aspx"); } else//更新 { SchedulerObj = new tblScheduler(); HttpCookie UserData = Request.Cookies.Get("UserIdCookies"); if (UserData != null) { SchedulerObj.UTPUser = UserData.Value; } HttpCookie UserPasswordData = Request.Cookies.Get("UserPasswordCookies"); if (UserPasswordData != null) { SchedulerObj.UTPPwd = UserPasswordData.Value; } if (rctxtCompany.SelectedItem != null) { SchedulerObj.Company = rctxtCompany.SelectedItem.Value; } if (rctxtStartingCycle.SelectedItem != null && rctxtEndingCycle.SelectedItem != null) { SchedulerObj.Cycle = rctxtStartingCycle.SelectedItem.Value + "," + rctxtEndingCycle.SelectedItem.Value; } if (rctxtStatusCode.SelectedItem != null) { SchedulerObj.Status = rctxtStatusCode.SelectedItem.Value; } SchedulerObj.Copy = chkCopy.Checked.ToString(); SchedulerObj.Calc = chkCalc.Checked.ToString(); KeyIdGuid = new Guid(this.KeyId);//转换成Guid类型 SchedulerObj.ScheduleID = KeyIdGuid; BLL_ScheduleTasks = new ScheduleTasksBLL(); successFlag = BLL_ScheduleTasks.UpdateInBillingPage(SchedulerObj); if (!successFlag.Equals("InsertError")) { //将数据保存到客户端cookie HttpCookie myCookie = new HttpCookie("Billing"); myCookie.Values.Add("billingEdit", "billingEdit"); myCookie.Expires = System.DateTime.Now.AddDays(1); Response.AppendCookie(myCookie); Response.Redirect("~/Schedule Billing/TaskDetailForm.aspx?KeyGuid=" + this.KeyId); } else { //错误提示信息 MessageBox(false, false, true, GetGlobalResourceObject("WebResource", "BillingForm_SaveMessage_ErrorMessage").ToString()); } } } else//EndCycle<startCycle { MessageBox(false, true, false, GetGlobalResourceObject("WebResource", "BillingForm_SelectCycleMessage_Message").ToString()); } } else//Cycle的数据无效 { MessageBox(false, true, false, GetGlobalResourceObject("WebResource", "BillingForm_ConpanyCycle_Message").ToString()); } }