예제 #1
0
파일: Demand.cs 프로젝트: 7aylor/Unity
 /// <summary>
 /// Updates the necessary vrabiles for the market demand components
 /// </summary>
 /// <param name="newDemand">sets the demand type, ie medium, high, etc.</param>
 /// <param name="newDemandText">sets the market demand text to the demand type</param>
 /// <param name="newDemandColor">sets the new color of the demand text</param>
 /// <param name="newBidTime">sets the new time between bid spawns</param>
 private void SetDemandVarsAndText(demand newDemand, string newDemandText, Color newDemandColor, int newBidTime)
 {
     marketDemand           = newDemand;
     marketDemandText.text  = newDemandText;
     marketDemandText.color = newDemandColor;
     bidManager.UpdateSpawnTime(newBidTime);
 }
예제 #2
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (this.Request.QueryString["op"] != null)
     {
         this.txtOp.Value = this.Request.QueryString["op"].ToString();
     }
     if (this.Request.QueryString["id"] != null)
     {
         this.txtDocid.Value = this.Request.QueryString["id"].ToString();
     }
     if (!this.IsPostBack)
     {
         if (this.txtOp.Value == "order")
         {
             demand demand = new demand();
             demand.GetModel(this.txtDocid.Value);
             this.lb_name.Text = demand.name;
             this.lb_ammount.Text = demand.amount.ToString();
             this.lb_day.Text = demand.days;
             this.lb_detail.Text = demand.detail;
             this.lb_project.Text = demand.projectName;
             this.lb_thirdClass.Text = demand.thirdClass;
             this.txtphone.Value = demand.phone;
             this.txtSummary.Value = demand.summary;
         }
     }
 }
예제 #3
0
 protected void btn_save_Click(object sender, EventArgs e)
 {
     demand demand = new demand();
     demand.GetModel(this.txtDocid.Value);
     demand.ifPay = "1";
     demand.Update();
     ClientScript.RegisterStartupScript(ClientScript.GetType(), "myscript", "<script>success();</script>");
 }
예제 #4
0
 protected void btn_save_Click(object sender, EventArgs e)
 {
     demand demand = new demand();
     demand.GetModel(this.txtDocid.Value);
     demand.phone = this.txtphone.Value;
     demand.summary = this.txtSummary.Value;
     demand.id = this.txtDocid.Value;
     demand.ifPublish = "1";
     demand.Update();
     Response.Redirect("getBountry.aspx?id=" + this.txtDocid.Value + "&rend=" + System.Guid.NewGuid().ToString() + "");
 }
예제 #5
0
        private void button26_Click(object sender, EventArgs e)
        {
            demand d = new demand(Direction.Down, 20);

            if (demands.Contains(d))
            {
                return;
            }
            else
            {
                demands.Enqueue(d);
            }
        }
예제 #6
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (this.Request.QueryString["id"] != null)
     {
         this.txtDocid.Value = this.Request.QueryString["id"].ToString();
     }
     if (!this.IsPostBack)
     {
         demand demand = new demand();
         demand.GetModel(this.txtDocid.Value);
         this.lb_amount.Text = demand.amount.ToString();
         this.lb_orderid.Text = demand.orderid;
         this.lb_title.Text = demand.name;
     }
 }
 private void Button_Click_2(object sender, RoutedEventArgs e)
 {
     try
     {
         if (MessageBox.Show("Вы уверены что хотите сохранить данные?", "Сохранение", MessageBoxButton.YesNo, MessageBoxImage.Warning) == MessageBoxResult.Yes)
         {
             RealtorEntities db     = new RealtorEntities();
             demand          demand = db.demand.Find(SecurityContext.idDemand);
             db.demand.Remove(db.demand.Where(dr => dr.IdDemand == SecurityContext.idDemand).FirstOrDefault());
             db.SaveChanges();
             ClientsDemands re = new ClientsDemands();
             this.Hide();
             re.Show();
         }
     }
     catch
     {
         MessageBox.Show("Данная потребность участвует в сделке");
     }
 }
        public JsonResult Demand(demand model)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(Json(new { success = false, responseText = "Sorry! There was error perfoming your action." }, JsonRequestBehavior.AllowGet));
                }

                Demand app = new Demand();
                app.modalYear   = model.modalYear;
                app.carInfo     = model.carInfo;
                app.name        = model.name;
                app.email       = model.email;
                app.phonenumber = model.phonenumber;
                app.itemName    = model.itemName;
                app.itemDetail  = model.itemDetail;
                var filename = Path.GetFileName(model.itemImage.FileName);
                model.itemImage.SaveAs(Server.MapPath("../Images/appointment/" + filename));
                app.itemImage = "/Images/product/" + filename;
                app.date      = DateTime.Now;

                _context.Demands.Add(app);
                _context.SaveChanges();

                var demand_new = _context.Demands.SingleOrDefault(c => c.Id == app.Id);



                return(Json(new { data = demand_new, success = true, responseText = "Your demand has been successfuly placed" }, JsonRequestBehavior.AllowGet));
            }
            catch (JsonException jx)
            {
                throw new JsonException("Unable to place demand", jx);
            }
        }
예제 #9
0
        private void Grid_Loaded(object sender, RoutedEventArgs e)
        {
            ClientLi.ItemsSource = dtClient.DefaultView;
            RealtorEntities db   = new RealtorEntities();
            demand          save = db.demand.Find(SecurityContext.idDemand);

            MaxPr.Text  = save.MaxPrice.ToString();
            MinPri.Text = save.MinPrice.ToString();
            switch (save.NameType)
            {
            case 1:
                TypeCombo.SelectedIndex = 2;
                break;

            case 2:
                TypeCombo.SelectedIndex = 1;
                break;

            case 3:
                TypeCombo.SelectedIndex = 0;
                break;
            }
            for (int i = 0; i < dtClient.Rows.Count; i++)
            {
                if (int.Parse(dtClient.Rows[i].ItemArray[0].ToString()) == save.IdClient)
                {
                    ClientLi.SelectedIndex = i;
                }
            }

            switch (TypeCombo.SelectedIndex)
            {
            case 0:
                for (int i = 0; i < dtApart.Rows.Count; i++)
                {
                    if (int.Parse(dtApart.Rows[i].ItemArray[0].ToString()) == save.TypePropetry)
                    {
                        Type.SelectedIndex = i;
                    }
                }
                break;

            case 1:
                for (int i = 0; i < dtHouse.Rows.Count; i++)
                {
                    if (int.Parse(dtHouse.Rows[i].ItemArray[0].ToString()) == save.TypePropetry)
                    {
                        Type.SelectedIndex = i;
                    }
                }
                break;

            case 2:
                for (int i = 0; i < dtLand.Rows.Count; i++)
                {
                    if (int.Parse(dtLand.Rows[i].ItemArray[0].ToString()) == save.TypePropetry)
                    {
                        Type.SelectedIndex = i;
                    }
                }
                break;
            }
        }
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (MinPri.Text != "" && MaxPr.Text != "")
                {
                    if (int.Parse(MinPri.Text) > 0 && int.Parse(MaxPr.Text) > 0)
                    {
                        if (int.Parse(MinPri.Text) < int.Parse(MaxPr.Text))
                        {
                            if (MessageBox.Show("Вы уверены что хотите сохранить данные?", "Сохранение", MessageBoxButton.YesNo, MessageBoxImage.Warning) == MessageBoxResult.Yes)
                            {
                                RealtorEntities db   = new RealtorEntities();
                                demand          save = db.demand.Find(SecurityContext.idDemand);
                                save.IdRealtor = int.Parse(dtRealtor.Rows[RealtorLi.SelectedIndex].ItemArray[0].ToString());
                                save.IdClient  = SecurityContext.idClient;
                                switch (TypeCombo.SelectedIndex)
                                {
                                case 0:
                                    save.TypePropetry = int.Parse(dtApart.Rows[Type.SelectedIndex].ItemArray[0].ToString());
                                    save.NameType     = 3;
                                    break;

                                case 1:
                                    save.TypePropetry = int.Parse(dtHouse.Rows[Type.SelectedIndex].ItemArray[0].ToString());
                                    save.NameType     = 2;
                                    break;

                                case 2:
                                    save.TypePropetry = int.Parse(dtLand.Rows[Type.SelectedIndex].ItemArray[0].ToString());
                                    save.NameType     = 1;
                                    break;
                                }
                                save.MaxPrice = int.Parse(MaxPr.Text);
                                save.MinPrice = int.Parse(MinPri.Text);
                                db.demand.Create();
                                db.SaveChanges();
                                if (MessageBox.Show("Перейти на форму списка потребностей?", "Данные успешно сохранены", MessageBoxButton.YesNo, MessageBoxImage.Warning) == MessageBoxResult.No)
                                {
                                }
                                else
                                {
                                    ClientsDemands re = new ClientsDemands();
                                    this.Hide();
                                    re.Show();
                                }
                            }
                        }
                        else
                        {
                            MessageBox.Show("Проверьте минимальную и максимальную сумму");
                        }
                    }
                    else
                    {
                        MessageBox.Show("Цена не может быть отрицательной");
                    }
                }
                else
                {
                    MessageBox.Show("Вы не заполнили поле Цена");
                }
            }
            catch
            {
                MessageBox.Show("Проверьте ввденые данные ");
            }
        }
예제 #11
0
        static void Elevator_Schedule()
        {
            List <Elevator> elevators = new List <Elevator>();

            elevators.Add(elevator1);
            elevators.Add(elevator2);
            elevators.Add(elevator3);
            elevators.Add(elevator4);
            elevators.Add(elevator5);
            while (true)
            {                  //持续接受指令并操作
                //将楼层的需求分配给各电梯
                int count = 5; //若超过五次仍无法分配任务,则跳过
                while (demands.Count > 0 && count > 0)
                {              //需求队列中有需求
                    for (int i = 0; i < 5; ++i)
                    {
                        if (demands.Count == 0)
                        {
                            break;
                        }
                        demand d = demands.First(); //获取需求队列的第一个元素
                        if (elevators[i].Get_Direction() == Direction.Stop)
                        {                           //电梯空闲
                            elevators[i].Add_Target(d.tar_floor);
                            demands.Dequeue();
                            continue;
                        }
                        else if (elevators[i].Get_Direction() == d.tar_direction)
                        {                          //需求方向与电梯运行方向相同
                            if (d.tar_direction == Direction.Up && d.tar_floor > elevators[i].Get_Current_Floor())
                            {                      //需求在电梯运行方向上,加入电梯任务队列
                                elevators[i].Add_Target(d.tar_floor);
                                demands.Dequeue(); //从需求队列中去除
                                continue;
                            }
                            else if (d.tar_direction == Direction.Down && d.tar_floor < elevators[i].Get_Current_Floor())
                            {
                                elevators[i].Add_Target(d.tar_floor);
                                demands.Dequeue();
                                continue;
                            }
                        }
                    }
                    if (demands.Count > 0)
                    { //若所有电梯均忙碌,需求得不到解决,则等待
                        if (demands.Count == 1)
                        {
                            //只有一个需求无法解决,则等待
                            break;
                        }
                        else
                        {//若队列中还有其他需求,则将无法解决的需求排到队尾
                            demand d = demands.Dequeue();
                            demands.Enqueue(d);
                            count -= 1;
                        }
                    }
                }
                //各电梯执行自己的调度算法
                elevator1.dispatch();
                elevator2.dispatch();
                elevator3.dispatch();
                elevator4.dispatch();
                elevator5.dispatch();
                //等待1s
                Thread.Sleep(1000);
            }
        }