Пример #1
0
        public int editOrder()
        {
            string       external   = GlobFuncs.convertExtensionToString(this.extetions);
            editExtOrder ext        = new editExtOrder(this.externalOrderId, this.person.IdNumber, this.person.FullName, this.person.PhoneNumber, this.person.PhoneNumber, this.person.LiccensNumber, this.PickupBranch, this.ReturnBranch, this.PickupDate, this.ReturnDate, this.CarId, 18, external, this.CreditCard.number, this.CreditCard.month, this.CreditCard.year, this.CreditCard.digitNo, this.CreditCard.ownerId, this.notes);
            string       ApiAddress = GlobFuncs.GetApiAddress(this.Company, "editOrderBll");
            string       Json       = JsonConvert.SerializeObject(ext);
            string       returnFlag = GetApi.PostApi(Json, ApiAddress);

            if (returnFlag != 0.ToString())
            {
                string     b          = GlobFuncs.GetDetails(this.Company, this.CarId);
                CarDetails carDetails = new CarDetails();
                string[]   arr        = b.Split('#');
                string     str        = arr[0].Substring(2, arr[0].Length - 3).Replace("\\", "");
                carDetails = JsonConvert.DeserializeObject <CarDetails>(str);
                string   pickBr = GlobFuncs.GetBranchName(this.PickupBranch, this.Company);
                string   RetBr  = GlobFuncs.GetBranchName(this.ReturnBranch, this.Company);
                DataBase db     = new DataBase();
                string   sql    = "update OrderTable set creditCardId = '" + this.CreditCard.id + "' where RentId = " + this.orderId + ";delete from ExtensInOrder where OrderId = " + this.orderId;
                db.ExecuteNonQuery(sql);
                if (this.extetions.Count > 0)
                {
                    sql = "insert into ExtensInOrder (OrderId,ExtentionId,description,price) values";
                    foreach (Extention extention in this.extetions)
                    {
                        sql += "(" + int.Parse(db.GetMaxId("OrderTable", "RentId").ToString()) + "," + extention.id + ",'" + extention.description + "'," + extention.Price + "),";
                    }
                    sql = sql.Substring(0, sql.Length - 1);
                    db.ExecuteNonQuery(sql);
                }
                return(1);
            }
            return(0);
        }
Пример #2
0
        public string GetDetails()
        {
            string ObjId   = JsonConvert.SerializeObject(this.id);
            string Address = GlobFuncs.GetApiAddress(int.Parse(this.Company), "CarDetail");
            string ret     = GetApi.PostApi(ObjId, Address);

            return(ret);
        }
Пример #3
0
        public List <string> CreateExtOrder()
        {
            string        external   = GlobFuncs.convertExtensionToString(this.extetions);
            ExtOrder      ext        = new ExtOrder(this.person.IdNumber, this.person.FullName, this.person.PhoneNumber, this.person.PhoneNumber, this.person.LiccensNumber, this.PickupBranch, this.ReturnBranch, this.PickupDate, this.ReturnDate, this.CarId, 18, external, this.CreditCard.number, this.CreditCard.month, this.CreditCard.year, this.CreditCard.digitNo, this.CreditCard.ownerId, this.notes);
            string        ApiAddress = GlobFuncs.GetApiAddress(this.Company, "OrderBll");
            string        Json       = JsonConvert.SerializeObject(ext);
            string        a          = GetApi.PostApi(Json, ApiAddress);
            List <string> ordNo      = new List <string>();

            if (a != null)
            {
                a = a.Substring(1, a.Length - 2);
                ordNo.Add(a);
                string     b          = GlobFuncs.GetDetails(this.Company, this.CarId);
                CarDetails carDetails = new CarDetails();
                string[]   arr        = b.Split('#');
                string     str        = arr[0].Substring(2, arr[0].Length - 3).Replace("\\", "");
                carDetails = JsonConvert.DeserializeObject <CarDetails>(str);
                string   pickBr = GlobFuncs.GetBranchName(this.PickupBranch, this.Company);
                string   RetBr  = GlobFuncs.GetBranchName(this.ReturnBranch, this.Company);
                DataBase db     = new DataBase();
                string   sql    = "insert into OrderTable (CustomId,ExternalRentId,totalPrice,CarName,CarId,CarLevel,CompanyId,Seats,GearBox,EngineCapacity,Doors,Beags,PickupBranch,PickupBranchText,PickupDate,ReturnBranch,ReturnBranchText,ReturnDate,creditCardId,Status,notes)values" +
                                  " ('" + this.person.CustomId + "','" + a + "'," + this.totalPrice + ",'" + carDetails.CarName + "'," + this.CarId + ",'" + carDetails.CarLevel + "','" + this.Company + "','" + carDetails.Seats + "','" + carDetails.GearBox + "','" + carDetails.EngineCapacity + "','" + carDetails.Doors + "','" + carDetails.Baegs + "','" + this.PickupBranch + "','" + pickBr + "','" + this.PickupDate + "','" + this.ReturnBranch + "','" + RetBr + "','" + this.ReturnDate + "','" + this.CreditCard.id + "','2','" + this.notes + "')";
                int SuccessFlag = db.ExecuteNonQuery(sql);
                if (SuccessFlag > 0)
                {
                    ordNo.Add(db.GetMaxId("OrderTable", "RentId").ToString());
                    if (this.extetions.Count > 0)
                    {
                        sql = "insert into ExtensInOrder (OrderId,ExtentionId,description,price) values";
                        foreach (Extention extention in this.extetions)
                        {
                            sql += "(" + int.Parse(db.GetMaxId("OrderTable", "RentId").ToString()) + "," + extention.id + ",'" + extention.description + "'," + extention.Price + "),";
                        }
                        sql = sql.Substring(0, sql.Length - 1);
                        db.ExecuteNonQuery(sql);
                    }
                    return(ordNo);
                }
                ordNo.Add("Error");
            }
            else
            {
                ordNo.Add("Error");
            }
            return(ordNo);
        }