Exemple #1
0
        private void SaveV_Click(object sender, EventArgs e)
        {
            try
            {
                AX.Enabled = false;
                AY.Enabled = false;
                AZ.Enabled = false;

                BX.Enabled = false;
                BY.Enabled = false;
                BZ.Enabled = false;

                Point p1 = new Point(Int32.Parse(AX.Text), Int32.Parse(AY.Text), Int32.Parse(AZ.Text));
                Point p2 = new Point(Int32.Parse(BX.Text), Int32.Parse(BY.Text), Int32.Parse(BZ.Text));

                Vectors vectros = new Vectors(p1, p2);

                Calculate.AppendText(vectros.Calculate());
                Scalar.AppendText(p1.ScalarV(p2) + ";");
                Collinearity.AppendText(vectros.IsCollinearity());
            }
            catch (Exception exc)
            {
                MessageBox.Show(exc.Message);

                AX.Clear();
                AY.Clear();
                AZ.Clear();

                BX.Clear();
                BY.Clear();
                BZ.Clear();
            }
        }
    private void Start()
    {
        Attack();
        Knife knife = new Knife();
        AX    ax    = new AX();

        SetWeapon(knife);
        Attack();
        SetWeapon(ax);
        Attack();
    }
Exemple #3
0
        private void Reset_Click(object sender, EventArgs e)
        {
            AX.Clear();
            AY.Clear();
            AZ.Clear();

            BX.Clear();
            BY.Clear();
            BZ.Clear();

            Calculate.Clear();
            Scalar.Clear();
            Collinearity.Clear();

            AX.Enabled = true;
            AY.Enabled = true;
            AZ.Enabled = true;

            BX.Enabled = true;
            BY.Enabled = true;
            BZ.Enabled = true;
        }
Exemple #4
0
        private void StatesGrid_PullSelected(DataRowView g)
        {
            this.QueGrid.SelectionChanged -= QueGrid_SelectionChanged;

            int j = QueGrid.Items.Count;

            try
            {
                using (SqlConnection MomCon = new SqlConnection(MomConStr))
                {
                    string h = g.Row.ItemArray[1].ToString();
                    int    JoyStickAssignment = int.Parse(g.Row.ItemArray[3].ToString());
                    if (JoyStickAssignment != -1)
                    {
                        this.Dispatcher.Invoke(() => SelectedQueTextBox.Text = h);
                        Thread.Sleep(1);
                        this.Dispatcher.Invoke(() => PopulateJoystickSelections(!(bool)QueMode, JoyStickAssignment - 1, SelectedQueTextBox.Text));
                    }

                    using (SqlCommand cmd = new SqlCommand("momsql..PullAxisTargets", MomCon))
                    {
                        cmd.Parameters.AddWithValue("@QueName", h);
                        cmd.CommandType = CommandType.StoredProcedure;
                        MomCon.Open();
                        cmd.ExecuteNonQuery();
                        MomCon.Close();
                    }
                    foreach (AxisControl AX in axControl)
                    {
                        this.Dispatcher.Invoke(() => AX.PullSelection());
                        this.Dispatcher.Invoke(() => AX.queControl  = (bool)this.QueMode);
                        this.Dispatcher.Invoke(() => AX.SelectedQue = SelectedQueTextBox.Text);
                    }
                }
            }
            catch { }
            finally { this.QueGrid.SelectionChanged += QueGrid_SelectionChanged; }
        }
Exemple #5
0
        private void StatesGridTimer_tick(object myObject, EventArgs e)
        {
            // UpdateSQL.Refresh();
            int x = 0;

            foreach (AxisControl AX in axControl)
            {
                if (AX == null)
                {
                    return;
                }
                AX.queControl = (bool)QueMode;
                if (!(bool)QueMode && AX.AssignedJoyStick != -1)
                {
                    if (qControl[AX.AssignedJoyStick].QueName != AX.AxisNameTextBox.Text)
                    {
                        qControl[AX.AssignedJoyStick].QueName = AX.AxisNameTextBox.Text;
                    }
                }
                if (UpdateSQL.ADT != null && UpdateSQL.ADT.Rows.Count > x)
                {
                    if (!AX.HasKeyBoardFocus)
                    {
                        AX.DataContext = UpdateSQL.ADT.Rows[x];
                        AX.UpdateLayout();
                        AX.AxisNumber = (int)UpdateSQL.ADT.Rows[x].ItemArray[1];
                    }
                    else
                    {
                        Debug.Print("EAT SHIT");
                    }
                }
                x++;
            }
            Task k = Task.Run(() => UpdateSQL.Refresh());
        }
Exemple #6
0
        public bool Run()
        {
            while (PC < program.Count)
            {
                if (debug)
                {
                    this.ShowProgram();
                    this.ShowHeap();
                    this.ShowStack();
                }
                switch (program[PC])
                {
                case (int)IS.NOP: ++PC; break;

                case (int)IS.IMOV: ++PC; AX = program[PC]; ++PC; break;

                case (int)IS.PUSH: datStack.Set(SP++, AX); ++PC; break;

                case (int)IS.IPUSH: ++PC; datStack.Set(SP++, program[PC]); ++PC; break;

                case (int)IS.TOP: AX = datStack[SP - 1]; ++PC; break;

                case (int)IS.POP: --SP; ++PC; break;

                case (int)IS.LFS: AX = datStack[SP - 1 + datStack[SP - 1]]; ++PC; break;

                case (int)IS.STS: datStack.Set(SP - 1 + datStack[SP - 1], AX); ++PC; break;

                case (int)IS.LFH: AX = datHeap.Get(datStack[SP - 1]); ++PC; break;

                case (int)IS.STH: datHeap.Set(datStack[SP - 1], AX); ++PC; break;

                case (int)IS.JMP: ++PC; PC = program[PC]; break;

                case (int)IS.JZ: ++PC; PC = AX == 0 ? program[PC] : PC + 1; break;

                case (int)IS.JNZ: ++PC; PC = AX != 0 ? program[PC] : PC + 1; break;

                case (int)IS.CALL: ++PC; datStack.Set(SP++, PC + 1); PC = program[PC]; break;

                case (int)IS.CALLS: ++PC; int addr = datStack[--SP]; datStack.Set(SP++, PC); PC = addr; break;

                case (int)IS.RET: PC = datStack[--SP]; break;

                case (int)IS.ADD: datStack[SP - 1] = datStack[SP - 1] + AX; ++PC; break;

                case (int)IS.SUB: datStack[SP - 1] = datStack[SP - 1] - AX; ++PC; break;

                case (int)IS.NEG: datStack.Set(SP++, -AX); ++PC; break;

                case (int)IS.MUL: datStack[SP - 1] = datStack[SP - 1] * AX; ++PC; break;

                case (int)IS.DIV: datStack[SP - 1] = datStack[SP - 1] / AX; ++PC; break;

                case (int)IS.MOD: datStack[SP - 1] = datStack[SP - 1] % AX; ++PC; break;

                case (int)IS.POW: datStack[SP - 1] = LuaVMHelper.Pow(datStack[SP - 1], AX); ++PC; break;

                case (int)IS.AND: datStack[SP - 1] = (datStack[SP - 1] != 0 && AX != 0) ? 1 : 0; ++PC; break;

                case (int)IS.OR: datStack[SP - 1] = (datStack[SP - 1] != 0 || AX != 0) ? 1 : 0; ++PC; break;

                case (int)IS.NOT: datStack.Set(SP, (AX != 0) ? 0 : 1); ++SP; ++PC; break;

                case (int)IS.EQ: datStack[SP - 1] = (datStack[SP - 1] == AX) ? 1 : 0;; ++PC; break;

                case (int)IS.NEQ: datStack[SP - 1] = (datStack[SP - 1] != AX) ? 1 : 0;; ++PC; break;

                case (int)IS.LT: datStack[SP - 1] = (datStack[SP - 1] < AX) ? 1 : 0;; ++PC; break;

                case (int)IS.LE: datStack[SP - 1] = (datStack[SP - 1] <= AX) ? 1 : 0;; ++PC; break;

                case (int)IS.GT: datStack[SP - 1] = (datStack[SP - 1] > AX) ? 1 : 0;; ++PC; break;

                case (int)IS.GE: datStack[SP - 1] = (datStack[SP - 1] >= AX) ? 1 : 0;; ++PC; break;

                case (int)IS.STRSUB:
                    strStack.Add(strStack[AX].Substring(datStack[SP - 2], datStack[SP - 1]));
                    SP -= 2;
                    AX  = strStack.Count - 1;
                    ++PC;
                    break;

                case (int)IS.STRCON:
                    strStack[AX] = strStack[AX] + strStack[datStack[--SP]];
                    ++PC;
                    break;

                case (int)IS.STRLEN:
                    AX = strStack[AX].Length;
                    ++PC;
                    break;

                case (int)IS.STRCPY:
                    strStack.Add(strStack[AX]);
                    AX = strStack.Count - 1;
                    ++PC;
                    break;

                case (int)IS.STRADD:
                    strStack[AX] += (char)datStack[--SP];
                    ++PC;
                    break;

                case (int)IS.STRCMP:
                    AX = LuaVMHelper.StrCmp(strStack[datStack[--SP]], strStack[AX]);
                    ++PC;
                    break;

                case (int)IS.STRFMT:
                    strStack.Add(AX.ToString());
                    AX = strStack.Count - 1;
                    ++PC;
                    break;

                case (int)IS.PRINT:
                    Console.WriteLine(strStack[AX]);
                    ++PC;
                    break;
                }
                if (debug)
                {
                    Console.ReadKey();
                }
            }
            return(true);
        }
Exemple #7
0
        /* Generate the action table and its associates:
        **
        **  yy_action[]        A single table containing all actions.
        **  yy_lookahead[]     A table containing the lookahead for each entry in
        **                     yy_action.  Used to detect hash collisions.
        **  yy_shift_ofst[]    For each state, the offset into yy_action for
        **                     shifting terminals.
        **  yy_reduce_ofst[]   For each state, the offset into yy_action for
        **                     shifting non-terminals after a reduce.
        **  yy_default[]       Default action for each state.
        */
        public static EmitterActionTable Make(Context ctx, out int maxTokenOffset, out int minTokenOffset, out int maxNonTerminalOffset, out int minNonTerminalOffset)
        {
            /* Compute the actions on all states and count them up */
            var ax = new AX[ctx.States * 2];

            for (var i = 0; i < ctx.States; i++)
            {
                var state = ctx.Sorted[i];
                ax[i * 2] = new AX {
                    State = state, Token = true, Actions = state.TokenActions
                };
                ax[i * 2 + 1] = new AX {
                    State = state, Token = false, Actions = state.NonTerminalActions
                };
            }
            maxTokenOffset       = minTokenOffset = 0;
            maxNonTerminalOffset = minNonTerminalOffset = 0;
            /* Compute the action table.  In order to try to keep the size of the action table to a minimum, the heuristic of placing the largest action sets first is used. */
            for (var i = 0; i < ctx.States * 2; i++)
            {
                ax[i].iOrder = i;
            }
            Array.Sort(ax, _keyComparer);
            var actionTable = new EmitterActionTable();

            for (var i = 0; i < ctx.States * 2 && ax[i].Actions > 0; i++)
            {
                var state = ax[i].State;
                if (ax[i].Token)
                {
                    foreach (var action in state.Actions)
                    {
                        if (action.Symbol.ID >= ctx.Terminals)
                        {
                            continue;
                        }
                        var actionID = action.ComputeID(ctx);
                        if (actionID < 0)
                        {
                            continue;
                        }
                        actionTable.Action(action.Symbol.ID, actionID);
                    }
                    state.TokenOffset = actionTable.Insert();
                    if (state.TokenOffset < minTokenOffset)
                    {
                        minTokenOffset = state.TokenOffset;
                    }
                    if (state.TokenOffset > maxTokenOffset)
                    {
                        maxTokenOffset = state.TokenOffset;
                    }
                }
                else
                {
                    foreach (var action in state.Actions)
                    {
                        if (action.Symbol.ID < ctx.Terminals)
                        {
                            continue;
                        }
                        if (action.Symbol.ID == ctx.Symbols.Length - 1)
                        {
                            continue;
                        }
                        var actionID = action.ComputeID(ctx);
                        if (actionID < 0)
                        {
                            continue;
                        }
                        actionTable.Action(action.Symbol.ID, actionID);
                    }
                    state.NonTerminalOffset = actionTable.Insert();
                    if (state.NonTerminalOffset < minNonTerminalOffset)
                    {
                        minNonTerminalOffset = state.NonTerminalOffset;
                    }
                    if (state.NonTerminalOffset > maxNonTerminalOffset)
                    {
                        maxNonTerminalOffset = state.NonTerminalOffset;
                    }
                }
            }
            ax = null;
            return(actionTable);
        }
    public static void mgmres(double[] a, int[] ia, int[] ja, ref double[] x, double[] rhs,
                              int n, int nz_num, int itr_max, int mr, double tol_abs, double tol_rel)

    //****************************************************************************80
    //
    //  Purpose:
    //
    //    MGMRES applies the restarted GMRES iteration to a linear system.
    //
    //  Discussion:
    //
    //    The linear system A*X=B is solved iteratively.
    //
    //    The matrix A is assumed to be sparse.  To save on storage, only
    //    the nonzero entries of A are stored.  For instance, the K-th nonzero
    //    entry in the matrix is stored by:
    //
    //      A(K) = value of entry,
    //      IA(K) = row of entry,
    //      JA(K) = column of entry.
    //
    //    The "matrices" H and V are treated as one-dimensional vectors
    //    which store the matrix data in row major form.
    //
    //    This requires that references to H[I][J] be replaced by references
    //    to H[I+J*(MR+1)] and references to V[I][J] by V[I+J*N].
    //
    //  Licensing:
    //
    //    This code is distributed under the GNU LGPL license.
    //
    //  Modified:
    //
    //    13 July 2007
    //
    //  Author:
    //
    //    Original C version by Lili Ju.
    //    C++ version by John Burkardt.
    //
    //  Reference:
    //
    //    Richard Barrett, Michael Berry, Tony Chan, James Demmel,
    //    June Donato, Jack Dongarra, Victor Eijkhout, Roidan Pozo,
    //    Charles Romine, Henk van der Vorst,
    //    Templates for the Solution of Linear Systems:
    //    Building Blocks for Iterative Methods,
    //    SIAM, 1994,
    //    ISBN: 0898714710,
    //    LC: QA297.8.T45.
    //
    //    Tim Kelley,
    //    Iterative Methods for Linear and Nonlinear Equations,
    //    SIAM, 2004,
    //    ISBN: 0898713528,
    //    LC: QA297.8.K45.
    //
    //    Yousef Saad,
    //    Iterative Methods for Sparse Linear Systems,
    //    Second Edition,
    //    SIAM, 2003,
    //    ISBN: 0898715342,
    //    LC: QA188.S17.
    //
    //  Parameters:
    //
    //    Input, double A[NZ_NUM], the matrix values.
    //
    //    Input, int IA[NZ_NUM], JA[NZ_NUM], the row and column indices
    //    of the matrix values.
    //
    //    Input/output, double X[N]; on input, an approximation to
    //    the solution.  On output, an improved approximation.
    //
    //    Input, double RHS[N], the right hand side of the linear system.
    //
    //    Input, int N, the order of the linear system.
    //
    //    Input, int NZ_NUM, the number of nonzero matrix values.
    //
    //    Input, int ITR_MAX, the maximum number of (outer) iterations to take.
    //
    //    Input, int MR, the maximum number of (inner) iterations to take.
    //    MR must be less than N.
    //
    //    Input, double TOL_ABS, an absolue tolerance applied to the
    //    current residual.
    //
    //    Input, double TOL_REL, a relative tolerance comparing the
    //    current residual to the initial residual.
    //
    {
        const double delta = 1.0e-03;
        int          itr;
        int          k_copy  = 0;
        double       rho     = 0;
        double       rho_tol = 0;
        const bool   verbose = true;

        double[] c = new double[mr];
        double[] g = new double[mr + 1];
        double[] h = new double[(mr + 1) * mr];
        double[] r = new double[n];
        double[] s = new double[mr];
        double[] v = new double[n * (mr + 1)];
        double[] y = new double[mr + 1];

        int itr_used = 0;

        if (n < mr)
        {
            Console.WriteLine("");
            Console.WriteLine("MGMRES - Fatal error!");
            Console.WriteLine("  N < MR.");
            Console.WriteLine("  N = " + n + "");
            Console.WriteLine("  MR = " + mr + "");
            return;
        }

        for (itr = 1; itr <= itr_max; itr++)
        {
            AX.ax(a, ia, ja, x, ref r, n, nz_num);

            int i;
            for (i = 0; i < n; i++)
            {
                r[i] = rhs[i] - r[i];
            }

            rho = Math.Sqrt(typeMethods.r8vec_dot_product(n, r, r));

            switch (verbose)
            {
            case true:
                Console.WriteLine("  ITR = " + itr + "  Residual = " + rho + "");
                break;
            }

            rho_tol = itr switch
            {
                1 => rho * tol_rel,
                _ => rho_tol
            };

            for (i = 0; i < n; i++)
            {
                v[i + 0 * n] = r[i] / rho;
            }

            g[0] = rho;
            for (i = 1; i <= mr; i++)
            {
                g[i] = 0.0;
            }

            int j;
            for (i = 0; i < mr + 1; i++)
            {
                for (j = 0; j < mr; j++)
                {
                    h[i + j * (mr + 1)] = 0.0;
                }
            }

            int k;
            for (k = 1; k <= mr; k++)
            {
                k_copy = k;

                AX.ax(a, ia, ja, v, ref v, n, nz_num, xIndex:  +(k - 1) * n, wIndex:  +k * n);

                double av = Math.Sqrt(typeMethods.r8vec_dot_product(n, v, v, a1Index: +k * n, a2Index: +k * n));

                for (j = 1; j <= k; j++)
                {
                    h[j - 1 + (k - 1) * (mr + 1)] =
                        typeMethods.r8vec_dot_product(n, v, v, a1Index: +k * n, a2Index: +(j - 1) * n);
                    for (i = 0; i < n; i++)
                    {
                        v[i + k * n] -= h[j - 1 + (k - 1) * (mr + 1)] * v[i + (j - 1) * n];
                    }
                }

                h[k + (k - 1) * (mr + 1)] =
                    Math.Sqrt(typeMethods.r8vec_dot_product(n, v, v, a1Index: +k * n, a2Index: +k * n));

                if (Math.Abs(av + delta * h[k + (k - 1) * (mr + 1)] - av) <= double.Epsilon)
                {
                    for (j = 1; j <= k; j++)
                    {
                        double htmp = typeMethods.r8vec_dot_product(n, v, v, a1Index: +k * n, a2Index: +(j - 1) * n);
                        h[j - 1 + (k - 1) * (mr + 1)] += htmp;
                        for (i = 0; i < n; i++)
                        {
                            v[i + k * n] -= htmp * v[i + (j - 1) * n];
                        }
                    }

                    h[k + (k - 1) * (mr + 1)] =
                        Math.Sqrt(typeMethods.r8vec_dot_product(n, v, v, a1Index: +k * n, a2Index: +k * n));
                }

                if (h[k + (k - 1) * (mr + 1)] != 0.0)
                {
                    for (i = 0; i < n; i++)
                    {
                        v[i + k * n] /= h[k + (k - 1) * (mr + 1)];
                    }
                }

                switch (k)
                {
                case > 1:
                {
                    for (i = 1; i <= k + 1; i++)
                    {
                        y[i - 1] = h[i - 1 + (k - 1) * (mr + 1)];
                    }

                    for (j = 1; j <= k - 1; j++)
                    {
                        Helpers.mult_givens(c[j - 1], s[j - 1], j - 1, ref y);
                    }

                    for (i = 1; i <= k + 1; i++)
                    {
                        h[i - 1 + (k - 1) * (mr + 1)] = y[i - 1];
                    }

                    break;
                }
                }

                double mu = Math.Sqrt(Math.Pow(h[k - 1 + (k - 1) * (mr + 1)], 2)
                                      + Math.Pow(h[k + (k - 1) * (mr + 1)], 2));
                c[k - 1] = h[k - 1 + (k - 1) * (mr + 1)] / mu;
                s[k - 1] = -h[k + (k - 1) * (mr + 1)] / mu;
                h[k - 1 + (k - 1) * (mr + 1)] = c[k - 1] * h[k - 1 + (k - 1) * (mr + 1)]
                                                - s[k - 1] * h[k + (k - 1) * (mr + 1)];
                h[k + (k - 1) * (mr + 1)] = 0;
                Helpers.mult_givens(c[k - 1], s[k - 1], k - 1, ref g);

                rho = Math.Abs(g[k]);

                itr_used += 1;

                switch (verbose)
                {
                case true:
                    Console.WriteLine("  K =   " + k + "  Residual = " + rho + "");
                    break;
                }

                if (rho <= rho_tol && rho <= tol_abs)
                {
                    break;
                }
            }

            k    = k_copy - 1;
            y[k] = g[k] / h[k + k * (mr + 1)];

            for (i = k; 1 <= i; i--)
            {
                y[i - 1] = g[i - 1];
                for (j = i + 1; j <= k + 1; j++)
                {
                    y[i - 1] -= h[i - 1 + (j - 1) * (mr + 1)] * y[j - 1];
                }

                y[i - 1] /= h[i - 1 + (i - 1) * (mr + 1)];
            }

            for (i = 1; i <= n; i++)
            {
                for (j = 1; j <= k + 1; j++)
                {
                    x[i - 1] += v[i - 1 + (j - 1) * n] * y[j - 1];
                }
            }

            if (rho <= rho_tol && rho <= tol_abs)
            {
                break;
            }
        }

        switch (verbose)
        {
        case true:
            Console.WriteLine("");
            Console.WriteLine("MGMRES");
            Console.WriteLine("  Number of iterations = " + itr_used + "");
            Console.WriteLine("  Final residual = " + rho + "");
            break;
        }
    }
Exemple #9
0
        public static void ConflictResolution(FuzzyModel fm, float preserveThr, float ratioThr)
        {
            List <FuzzyEdge> toRemove = new List <FuzzyEdge>();

            foreach (FuzzyEdge AB in fm.GetEdges())
            {
                FuzzyEdge BA    = fm.GetEdge(AB.GetToNode(), AB.GetFromNode());
                float     relAB = 0;
                float     relBA = 0;
                if (BA != null)
                {
                    if (AB.Equals(BA))
                    {
                        toRemove.Add(AB);
                    }
                    if (toRemove.Contains(AB) || toRemove.Contains(BA))
                    {
                        continue;
                    }
                    FuzzyNode A = AB.GetFromNode();
                    FuzzyNode B = AB.GetToNode();
                    // compute relative significance of edge A->B
                    float sigAB = AB.GetFrequencySignificance();
                    float sigAX = 0;
                    foreach (FuzzyEdge AX in A.GetOutEdges())
                    {
                        sigAX += AX.GetFrequencySignificance();
                    }
                    float sigXB = 0;
                    foreach (FuzzyEdge XB in B.GetInEdges())
                    {
                        sigXB += XB.GetFrequencySignificance();
                    }
                    relAB = (0.5F * (sigAB / sigAX)) + (0.5F * (sigAB / sigXB));
                    Console.WriteLine("{0}, Relative significance: {1}", AB.ToString(), relAB);

                    // compute relative significance of edge B->A
                    float sigBA = BA.GetFrequencySignificance();
                    float sigBX = 0;
                    foreach (FuzzyEdge BX in B.GetOutEdges())
                    {
                        sigBX += BX.GetFrequencySignificance();
                    }
                    float sigXA = 0;
                    foreach (FuzzyEdge XA in A.GetInEdges())
                    {
                        sigXA += XA.GetFrequencySignificance();
                    }
                    relBA = (0.5F * (sigBA / sigBX)) + (0.5F * (sigBA / sigXA));
                    Console.WriteLine("{0}, Relative significance: {1}", BA.ToString(), relBA);


                    // Decide preservation
                    if (relAB < preserveThr || relBA < preserveThr)
                    {
                        float ofsAB = Math.Abs(relAB - relBA);
                        if (ofsAB < ratioThr)
                        {
                            toRemove.Add(AB);
                            toRemove.Add(BA);
                        }
                        else
                        {
                            if (relAB > relBA)
                            {
                                toRemove.Add(BA);
                            }
                            else
                            {
                                toRemove.Add(AB);
                            }
                        }
                    }
                }
            }

            foreach (FuzzyEdge fe in toRemove)
            {
                fm.RemoveEdge(fe);
            }
        }
Exemple #10
0
 get => new Vector2(AX, AY);
        public ActionResult CCenterList()
        {
            int userId = (int)Session[CDictionary.SK_LOGINED_USER_ID];
            var w      = (
                from o in db.OrderList
                where o.cId == userId
                join p in db.Product on o.pId equals p.pId
                select new CartVM
            {
                totalPrice = ((decimal)(o.oQty * p.pPrice))
            });

            if (db.OrderList.FirstOrDefault(o => o.cId == userId) != null)
            {
                Session[CDictionary.TK_Cart_TOTALPRICE] = w.Sum(p => p.totalPrice).ToString("0.##");
            }
            else
            {
                Session[CDictionary.TK_Cart_TOTALPRICE] = 0;
            }


            var user = (from c in db.Customer
                        join a in db.Admin on c.cId equals a.cId into AX
                        join cp in db.Company on c.CPId equals cp.CPId into AY
                        from x in AX.DefaultIfEmpty()
                        from y in AY.DefaultIfEmpty()


                        where c.cId == userId

                        select new vMemberCenterVM
            {
                firstName = c.cFName,
                lastName = c.cLName,
                email = c.cEmail,
                phoneNumber = c.cPhone,
                avatar = c.cAvatar,
                point = c.cPoint,
                birthday = c.cBD,
                companyId = c.CPId,
                companyAdd = y.CPAdd,
                companyBranch = y.CPBranch,
                companyName = y.CPName,
                aId = x.aId,
                adminDepartment = x.aDepartment,
                tp = w.Sum(p => p.totalPrice).ToString(),
                // tax=( w.Sum(p => p.totalPrice)*(decimal)0.12).ToString("0.##")
            }).FirstOrDefault();


            // Session[CDictionary.TK_Cart_TOTALPRICE] = x.Sum(a=>a.totalPrice).ToString();
            // Session[CDictionary.TK_Cart_TOTALPRICE] = w.Select(a => a.totalPrice).ToString();

            if (Session[CDictionary.SK_LOGINED_USER_ID] != null && Session[CDictionary.SK_LOGINED_ADMIN_ID] != null)
            {
                Session[CDictionary.SK_LOGINED_ADMIN_ID] = user.aId;
            }

            return(View(user));
        }