Пример #1
0
        protected int Save()
        {
            int intDone = 1;

            oForecast.DeleteAnswerPlatform(intID);
            foreach (string strForm in Request.Form)
            {
                if (strForm.StartsWith("hdnQ_"))
                {
                    if (intID == 0)
                    {
                        int intPlatform = Int32.Parse(lblPlatform.Text);
                        intID = oForecast.AddAnswer(intForecast, intPlatform, 0, intProfile);
                    }
                    int    intQuestion      = Int32.Parse(strForm.Substring(5));
                    string strInitalDisplay = GetDisplay(intQuestion);
                    if (strInitalDisplay == "inline")
                    {
                        string strTemp   = Request.Form[strForm];
                        int    intAnswer = 0;
                        int    intCustom = 0;
                        if (strTemp.Contains("|"))
                        {
                            while (strTemp != "")
                            {
                                if (strTemp.Contains("_"))
                                {
                                    intAnswer = Int32.Parse(strTemp.Substring(0, strTemp.IndexOf("_")));
                                }
                                else
                                {
                                    intAnswer = Int32.Parse(strTemp.Substring(0, strTemp.IndexOf("|")));
                                }
                                strTemp   = strTemp.Substring(strTemp.IndexOf("|") + 1);
                                intCustom = Int32.Parse(oForecast.GetResponse(intAnswer, "custom"));
                                if (intCustom > 0)
                                {
                                    oForecast.AddAnswerPlatform(intID, intQuestion, intAnswer, Request.Form["hdnC_" + intAnswer.ToString()]);
                                }
                                else
                                {
                                    oForecast.AddAnswerPlatform(intID, intQuestion, intAnswer, "");
                                }
                            }
                        }
                        else if (strTemp != "" && strTemp != "0")
                        {
                            intAnswer = Int32.Parse(strTemp);
                            intCustom = Int32.Parse(oForecast.GetResponse(intAnswer, "custom"));
                            if (intCustom > 0)
                            {
                                oForecast.AddAnswerPlatform(intID, intQuestion, intAnswer, Request.Form["hdnC_" + intAnswer.ToString()]);
                            }
                            else
                            {
                                oForecast.AddAnswerPlatform(intID, intQuestion, intAnswer, "");
                            }
                        }
                        else
                        {
                            if (oForecast.GetQuestion(intQuestion, "required") == "1")
                            {
                                DataSet dsAffects = oForecast.GetAffectsByAffected(intQuestion);
                                foreach (DataRow drAffect in dsAffects.Tables[0].Rows)
                                {
                                    int     intQ     = Int32.Parse(drAffect["questionid"].ToString());
                                    DataSet dsAnswer = oForecast.GetAnswerPlatform(intID, intQ);
                                    bool    boolOK   = false;
                                    foreach (DataRow drAnswer in dsAnswer.Tables[0].Rows)
                                    {
                                        string strDisplay = oForecast.GetAffects(intQ, intQuestion, Int32.Parse(drAnswer["responseid"].ToString()));
                                        if (strDisplay != "")
                                        {
                                            strDisplay = (strDisplay == "1" ? "inline" : "none");
                                        }
                                        if (strDisplay == "none")
                                        {
                                            boolOK = true;
                                        }
                                    }
                                    if (boolOK == false)
                                    {
                                        intDone = 0;
                                    }
                                }
                            }
                        }
                    }
                }
            }
            bool boolRecoveryOne  = oForecast.IsDROneToOne(intID);
            bool boolRecoveryMany = oForecast.IsDRManyToOne(intID);
            bool boolRecoveryNone = oForecast.IsDROver48(intID, false);
            int  intRecovery      = (boolRecoveryNone ? 0 : (boolRecoveryOne ? Int32.Parse(lblQuantity.Text) : (boolRecoveryMany ? Int32.Parse(lblRecovery.Text) : 0)));

            oForecast.UpdateAnswerRecovery(intID, intRecovery);

            if (boolProduction == true)
            {
                oForecast.EnforceRecovery(intID, intDRHourQuestion, intDRHourResponse, intDRRecoveryQuestion, intDRRecoveryResponse, Int32.Parse(lblQuantity.Text));
            }

            return(intDone);
        }