Example #1
0
        private void DoTransaction(string TransactionCode)
        {
            TransactionExecution Execution = new TransactionExecution(this.UserContext);
            bool ReturnAfterDcal           = false;

            if (this.UserContext.Status != TroposStatus.AwaitingTransaction)
            {
                Execution.DoReply("N", new ElectronicSignatureData(), int.Parse(this.UserContext.DataValidAttachKey, CultureInfo.InvariantCulture));
            }

            bool?NoUpdate = Session["DcalNoUpdate"] as bool?;

            if (NoUpdate != null && (bool)NoUpdate && TransactionCode == "UCAL")
            {
                // No Update flag is set, so do DCAL instead of UCAL
                TransactionCode = "DCAL";
                ReturnAfterDcal = true;
            }

            Session["CalculatorModeFieldValues"] = DimensionHelper.EvaluateFields(TroposFields.Controls[3].Controls);
            ExecuteReturn ReturnValue;

            ReturnValue = Execution.DoTransaction(TroposFields.Controls[3].Controls, TransactionCode, ScreenCode, false, false);
            {
                Dictionary <string, string> FieldValues  = null;
                Dictionary <string, string> _fieldValues = null;
                object    SessionFieldValues             = null;
                DataTable FieldValuesTable = ReturnValue.FieldValuesTable;
                DataRow   FieldValuesRow   = FieldValuesTable.Rows[0];
                switch (ReturnValue.WaitefReturn)
                {
                case "ExoutvarOk":
                case "Exread":
                case "Exread2":
                    // The DCAL transaction comes here - set up the fields in case we need to return them
                    FieldValuesTable = ReturnValue.FieldValuesTable;
                    FieldValuesRow   = FieldValuesTable.Rows[0];
                    FieldValues      = RowToDictionary(FieldValuesTable, FieldValuesRow);
                    if (ReturnAfterDcal)
                    {
                        TransactionReturn(FieldValues);
                    }
                    break;

                case "ExdoneOk":
                    // UCAL comes here - set up the fields from the pre-update values, then add the result fields
                    SessionFieldValues = Session["CalculatorModeFieldValues"];
                    if (SessionFieldValues != null)
                    {
                        FieldValues = (Dictionary <string, string>)SessionFieldValues;
                        Session.Remove("CalculatorModeFieldValues");
                    }
                    FieldValuesTable = ReturnValue.FieldValuesTable;
                    FieldValuesRow   = FieldValuesTable.Rows[0];
                    _fieldValues     = RowToDictionary(FieldValuesTable, FieldValuesRow);
                    FieldValues["iATTVALFROM-DQ"] = _fieldValues["iATTVALFROM-DQ"];
                    FieldValues["iUOM-ATT1"]      = _fieldValues["iUOM-ATT1"];
                    TransactionReturn(FieldValues);
                    break;

                case "ExoutvarFail":
                    TroposResourceProvider Trp = new TroposResourceProvider(UserContext);
                    if (ReturnValue.Message.Trim() == Trp.GetResource("MSG_NO_CHANGES"))
                    {
                        switch (TransactionCode)
                        {
                        case "UCAL":
                            // set up the fields from the pre-update values, then add the result fields
                            SessionFieldValues = Session["CalculatorModeFieldValues"];
                            if (SessionFieldValues != null)
                            {
                                FieldValues = (Dictionary <string, string>)SessionFieldValues;
                                Session.Remove("CalculatorModeFieldValues");
                            }
                            FieldValuesTable = ReturnValue.FieldValuesTable;
                            FieldValuesRow   = FieldValuesTable.Rows[0];
                            _fieldValues     = RowToDictionary(FieldValuesTable, FieldValuesRow);
                            FieldValues["iATTVALFROM-DQ"] = _fieldValues["iATTVALFROM-DQ"];
                            FieldValues["iUOM-ATT1"]      = _fieldValues["iUOM-ATT1"];
                            TransactionReturn(FieldValues);
                            break;

                        case "DCAL":
                            if (ReturnAfterDcal)
                            {
                                FieldValuesTable = ReturnValue.FieldValuesTable;
                                FieldValuesRow   = FieldValuesTable.Rows[0];
                                FieldValues      = RowToDictionary(FieldValuesTable, FieldValuesRow);
                                TransactionReturn(FieldValues);
                            }
                            break;
                        }
                    }
                    break;
                }
            }

            ValidationResult MandatoryCheckResult = new ValidationResult();

            Execution.LoadScreenFields(
                ReturnValue.FieldValuesTable,
                ReturnValue.Message,
                ReturnValue.ScrollTable,
                ReturnValue.TextTable,
                TroposFields.Controls[3].Controls,
                TransactionCode,
                MandatoryCheckResult);

            Label ErrorField = (Label)TroposFields.FindControl("eError");

            if (ErrorField != null)
            {
                if (ReturnValue.Success)
                {
                    ErrorField.Text     = "";
                    ErrorField.CssClass = "TroposError TroposDisplay TroposField";
                }
                else
                {
                    ErrorField.Text = ReturnValue.Message;
                    if (string.IsNullOrEmpty(ReturnValue.Message))
                    {
                        ErrorField.CssClass = "TroposError TroposDisplay TroposField";
                    }
                    else
                    {
                        ErrorField.CssClass = "TroposErrorPopulated TroposDisplay TroposField";
                    }
                }
            }
        }