Ejemplo n.º 1
0
        public ActionResult detailPrest(string prestOTID, string mode, string prestDetailID = "")
        {
            mj = new MAJ();

            var prestModel = new PrestationModel();

            var prestType     = "";
            var prestEtat     = "";
            var IsPrestGroupe = false;

            var prestProduit      = "";
            var prestPrix         = "";
            var prestRefCmdClient = "";
            var prestNbrPeriode   = "0";

            if (mode == "Ajouter")
            {
                prestEtat = "00";

                DataTable dtN = Configs._query.executeProc("prestGetPrestationNbr", "OTID@int@" + prestOTID);
                if (Tools.verifyDataTable(dtN))
                {
                    //if (dtN.Rows[0][1].ToString() == "0")fix it
                    prestRefCmdClient = dtN.Rows[0][0].ToString();
                }
            }

            else if (mode == "Modifier")
            {
                DataTable dtPrest = Configs._query.executeProc("prestGetDetailPrest", "otid@int@" + prestOTID + "#type@string@0" + "#detailID@int@" + prestDetailID, true);

                if (dtPrest != null)
                {
                    prestProduit      = dtPrest.Rows[0]["Produit"].ToString();
                    prestPrix         = dtPrest.Rows[0]["Prix"].ToString();
                    prestEtat         = dtPrest.Rows[0]["Etat"].ToString();
                    prestType         = dtPrest.Rows[0]["type"].ToString();
                    prestRefCmdClient = dtPrest.Rows[0]["RefCmdClient"].ToString();
                    prestNbrPeriode   = dtPrest.Rows[0]["ProduitPeriodes"].ToString();
                    IsPrestGroupe     = dtPrest.Rows[0]["PDG"] != DBNull.Value;
                }
            }

            ViewData["prestListPrestation"] = prestModel.listDTPrestation(prestType, prestOTID, prestProduit);
            if (!string.IsNullOrEmpty(prestDetailID) && prestDetailID != "-1")
            {
                ViewData["prestListPrestation"] = Configs._query.executeProc("prestGetpresMemeFamille", "id@int@" + prestDetailID);
            }

            ViewData["presStatus"] = Configs._query.executeProc("prestGetPropStatusPack", "etat@int@" + prestEtat);


            ViewData["RefCmdClient"] = prestRefCmdClient;
            ViewData["Etat"]         = prestEtat;
            ViewData["Type"]         = prestType;
            ViewData["Produit"]      = prestProduit;
            ViewData["Prix"]         = prestPrix;

            ViewData["mode"]            = mode;
            ViewData["OTID"]            = prestOTID;
            ViewData["prestDetailID"]   = prestDetailID;
            ViewData["prestNbrPeriode"] = prestNbrPeriode;
            ViewData["IsPrestGroupe"]   = IsPrestGroupe;

            return(View());
        }
Ejemplo n.º 2
0
        public string operationPrestation(string prestOtID, string prestMode, string prestPrix, string prestRefClient, string prestValList
                                          , string prestValStatut, string prestEtat, string prestID, string prestOldServ = "", string prestHeur = "", string prestMin = "")
        {
            string          res         = "";
            PrestationModel prestModele = new PrestationModel();

            int nbrPeriode = 0;
            int h, m;

            if (Int32.TryParse(prestHeur, out h) && Int32.TryParse(prestMin, out m))
            {
                nbrPeriode = (h * 2) + (m / 30);
            }

            if (prestMode == "Ajouter")
            {
                res = prestModele.addPrestation(prestOtID, prestValList, prestPrix, prestRefClient, prestValStatut, nbrPeriode.ToString());
                if (res != "")
                {
                    res = "Prestation ajoutée";
                }
                else
                {
                    res = "";
                }
            }

            else if (prestMode == "Modifier")
            {
                //string otid, string prestation, string prix, string oldPrestation, string refClient, string status, string idServ
                string user            = Session["login"].ToString();
                string CurrentAgenceID = Session["agenceID"] != null ? Session["agenceID"].ToString() : null;
                prestModele.updatePrestation(prestOtID, prestValList, prestPrix, prestOldServ, prestRefClient, prestValStatut, prestID, nbrPeriode.ToString(), user, CurrentAgenceID);
                res = "Prestation modifiée";
            }

            else if (prestMode == "Supprimer")
            {
                //string otid, string prestation
                res = prestModele.deletePrestation(prestID, prestValList);
                if (res == "1")
                {
                    res = "Prestation supprimée";
                }
                else
                {
                    res = "";
                }
            }

            else if (prestMode == "Annuler")
            {
                // string otid, string prestation, string etat, string code, string planID
                prestModele.annulerPrestation(prestOtID, prestValList, "30", " update OT set codestock = '' where OTID = 0 ", "-1");
                res = "Prestation annulée";
            }

            else if (prestMode == "Activer")
            {
                prestModele.annulerPrestation(prestOtID, prestValList, "00", " update OT set codestock = '' where OTID = 0 ", "-1");
                res = "Prestation activée";
            }



            return(res);
        }