Exemplo n.º 1
0
    public override void DoCommand(string command)
    {
        string cmd = HelpForm.GetFieldLower(command, 0);

        if (!cmd.EndsWith("showcase"))
        {
            return;
        }
        object idshowcase = CfgFn.GetNoNullInt32(HelpForm.GetFieldLower(command, 1));
        object idstore    = CfgFn.GetNoNullInt32(HelpForm.GetFieldLower(command, 2));
        string Query;

        Query  = "SELECT stocktotalview.idstore as idstore, list.idlist as idlist,list.intcode as intcode, list.description as description, ";
        Query += " stocktotalview.number as number, stocktotalview.ordered as ordered, stocktotalview.booked as booked,listclass.title as listclasstitle,";
        Query += " listclass.authrequired as authorizationrequired ";
        Query += " FROM showcasedetail join list on (showcasedetail.idlist=list.idlist) ";
        Query += " join stocktotalview on (list.idlist=stocktotalview.idlist) ";
        Query += " join listclass on (list.idlistclass=listclass.idlistclass) ";
        Query += " WHERE showcasedetail.idshowcase=" + idshowcase + " and stocktotalview.idstore=" + idstore;
        Query += " AND list.active='S'";
        //Query += " AND (stocktotalview.number - stocktotalview.booked)>0";  //Solo la merce disponibile
        Query += " order by description asc ";


        //string Query = "select S.idlist,S.idstore, S.intcode,S.list as description,	ST.number,ST.ordered,ST.booked, " +
        //        "S.listclass as listclasstitle,S.authrequired as authorizationrequired," +
        //        "convert(  decimal(19,2),	ROUND(	 ( SUM ( S.residual * S.amount	) /ST.number)	,2	 ))	as avgprice " +
        //        "FROM showcasedetail SC join  stockview S on S.idlist=SC.idlist " +
        //        "join stocktotal ST on S.idlist=ST.idlist and S.idstore=ST.idstore " +
        //        "where "+
        //        QHS.AppAnd(QHS.CmpGt("S.amount",0),QHS.CmpGt("residual",0),QHS.CmpEq("S.idstore",idstore),QHS.CmpEq("SC.idshowcase",idshowcase))+
        //        " group by S.idlist,S.idstore, S.intcode,S.list,ST.number,ST.ordered,ST.booked, S.listclass,S.authrequired " +
        //        " order by description asc";

        if (booking_on_invoice())
        {
            Query = "select S.idlist,S.idstore, S.intcode,S.list as description,	S.available, S.idstock,"+
                    "S.listclass as listclasstitle,S.authrequired as authorizationrequired," +
                    "convert(decimal(19,2),ROUND(S.amount/ S.number,2))	as price " +
                    "FROM showcasedetail SC join  stockview S on S.idlist=SC.idlist " +
                    "where " +
                    QHS.AppAnd(QHS.CmpGt("S.amount", 0), QHS.CmpGt("S.available", 0), QHS.CmpEq("S.idstore", idstore), QHS.CmpEq("SC.idshowcase", idshowcase)) +
                    " order by description asc";
        }



        DataTable DT = Conn.SQLRunner(Query);

        if (DT != null && DT.Rows.Count != 0)
        {
            if (booking_on_invoice())
            {
                foreach (DataRow R1 in DT.Select(null, "idstock"))
                {
                    if (R1.RowState == DataRowState.Deleted)
                    {
                        continue;
                    }
                    string flt2 = QHS.AppAnd(QHC.MCmp(R1, "idlist", "idstore"), QHC.CmpGt("idstock", R1["idstock"]));
                    foreach (DataRow R2 in DT.Select(flt2))
                    {
                        R2.Delete();
                    }
                }

                DT.AcceptChanges();
            }

            RenderCategoryTable(DT);
        }

        string filter;

        filter = QHS.CmpEq("idshowcase", idshowcase);
        DT     = Conn.RUN_SELECT("showcase", "title", null, filter, null, false);
        if (DT == null)
        {
            return;
        }
        titoloVetrina.Text = "<strong>Vetrina attualmente selezionata:</strong>&nbsp;" + DT.Rows[0]["title"].ToString();

        filter = QHS.CmpEq("idstore", idstore);
        DT     = Conn.RUN_SELECT("store", "description,deliveryaddress", null, filter, null, false);
        if (DT == null)
        {
            return;
        }
        lblStore.Text   = "<strong>Magazzino:&nbsp;</strong>" + DT.Rows[0]["description"];
        LabAddress.Text = "<strong>Indirizzo:&nbsp;</strong>" + DT.Rows[0]["deliveryaddress"];
    }