Example #1
0
        public ActionResult Update(Model.Data Data, string ID, string submit, string[] Pdt, string[] UnitPrice, string[] Qty)
        {
            if (submit == "true")
            {
                submit = "存檔";
            }
            else
            {
                submit = "刪除本筆訂單";
            }
            switch (submit)
            {
            case "存檔":
                Service.SQL_Inquire SI    = new Service.SQL_Inquire();
                Service.SQL_Update  SU    = new Service.SQL_Update();
                Service.SQL_Insert  SIt   = new Service.SQL_Insert();
                List <Model.Data>   LData = new List <Model.Data>();
                Model.Data          NData = new Model.Data();

                NData.CustomerID = Data.CustName;
                NData.EmployeeID = "null";
                NData.ShipperID  = "null";
                LData            = SI.GetData(NData);
                Data.CustName    = LData[0].CustName;
                Data.CustomerID  = LData[0].CustomerID;

                NData            = new Model.Data();
                NData.EmployeeID = Data.EmpName;
                NData.ShipperID  = "null";
                LData            = SI.GetData(NData);
                Data.EmpName     = LData[0].EmpName;
                Data.EmployeeID  = LData[0].EmployeeID;

                NData            = new Model.Data();
                NData.ShipperID  = Data.CpyName;
                NData.EmployeeID = "null";
                LData            = SI.GetData(NData);
                Data.CpyName     = LData[0].CpyName;
                Data.ShipperID   = LData[0].ShipperID;

                Data.OrderId = ID;
                SU.Update(Data);


                SU.Delete(Data.OrderId);
                if (Pdt != null)
                {
                    for (int i = 0; i < Pdt.Length; i++)
                    {
                        Data.ProductID = Pdt[i];
                        Data.UnitPrice = UnitPrice[i];
                        Data.Qty       = Qty[i];
                        SIt.Product(Data);
                    }
                }


                return(RedirectToAction("index", "Inquire", new { OrderId = ID, ShipperID = "null", EmployeeID = "null" }));

            case "刪除本筆訂單":
                Service.SQL_Delete SD = new Service.SQL_Delete();
                SD.Delete(ID);
                return(RedirectToAction("Index", "Inquire", new { OrderId = Data.OrderId }));
            }
            return(null);
        }
Example #2
0
        public ActionResult Insert(Model.Data Data, string[] Pdt, string[] UnitPrice, string[] Qty)
        {
            Service.SQL_Inquire SI  = new Service.SQL_Inquire();
            Service.SQL_Insert  SIt = new Service.SQL_Insert();

            List <Model.Data> LData = new List <Model.Data>();

            Model.Data NData = new Model.Data();

            NData.CustomerID = Data.CustName;
            NData.EmployeeID = "null";
            NData.ShipperID  = "null";
            LData            = SI.GetData(NData);
            Data.CustName    = LData[0].CustName;
            Data.CustomerID  = LData[0].CustomerID;

            NData            = new Model.Data();
            NData.EmployeeID = Data.EmpName;
            NData.ShipperID  = "null";
            LData            = SI.GetData(NData);
            Data.EmpName     = LData[0].EmpName;
            Data.EmployeeID  = LData[0].EmployeeID;

            NData            = new Model.Data();
            NData.ShipperID  = Data.CpyName;
            NData.EmployeeID = "null";
            LData            = SI.GetData(NData);
            if (Data.CpyName == "null")
            {
                Data.CpyName   = "無";
                Data.ShipperID = "";
            }
            else
            {
                Data.CpyName   = LData[0].CpyName;
                Data.ShipperID = LData[0].ShipperID;
            }
            if (Data.ShipCountry == null)
            {
                Data.ShipCountry = "無";
            }
            if (Data.Freight == null)
            {
                Data.Freight = "0";
            }
            Data.Freight = "100";
            if (Data.ShipAddress == null)
            {
                Data.ShipAddress = "無";
            }
            if (Data.ShipCity == null)
            {
                Data.ShipCity = "無";
            }

            Data.OrderId = SIt.Insert(Data);
            if (Pdt != null)
            {
                for (int i = 0; i < Pdt.Length; i++)
                {
                    Data.ProductID = Pdt[i];
                    Data.UnitPrice = UnitPrice[i];
                    Data.Qty       = Qty[i];
                    SIt.Product(Data);
                }
            }
            return(RedirectToAction("index", "Inquire", new { OrderId = Data.OrderId, ShipperID = "null", EmployeeID = "null" }));
        }