Esempio n. 1
0
    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());
        }
    }