当前位置: 首页>>代码示例>>C#>>正文


C# City.GetCenterID方法代码示例

本文整理汇总了C#中City.GetCenterID方法的典型用法代码示例。如果您正苦于以下问题:C# City.GetCenterID方法的具体用法?C# City.GetCenterID怎么用?C# City.GetCenterID使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在City的用法示例。


在下文中一共展示了City.GetCenterID方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ButtonSubmit_Click

    protected void ButtonSubmit_Click(object sender, EventArgs e)
    {
        //השגת הנתונים לגבי המשתמש
        int clientID = Convert.ToInt32(Session["UserID"]);

        Client orderingClient = new Client(clientID);
        City collectingCity = new City(orderingClient.GetCityID());
        string collectingCityName = collectingCity.GetCityName();
        int collectingCityID = orderingClient.GetCityID();
        string collectingAddress = orderingClient.GetAddress();

        string date = DateTime.Now.ToShortDateString();
        string item = this.TextBoxItemDescription.Text;
        string itemWeight = this.TextBoxItemWeight.Text;

        int destinationCityID = Convert.ToInt32(this.DropDownListDestinationCities.SelectedValue);
        string destinationCityName = this.DropDownListDestinationCities.SelectedItem.ToString();
        string destinationAddress = this.TextBoxAddress.Text;
        string destinationDate = DateTime.Now.AddDays(30).ToShortDateString();

        //חישוב המחיר
        CityService cs=new CityService();

        int collectingCenterID = collectingCity.GetCenterID();
        int destinationCenterID = cs.GetCenterIDByCityID(destinationCityID);
        int temp = destinationCenterID - collectingCenterID;

        if (temp < 0)
            temp *= -1;
        temp += 1;
        double price;
        price= 5 * Math.Log(double.Parse(itemWeight)) + 10 + (temp * 10);
        if (this.CheckBoxUrgent.Checked)
        {
            price += 10;
        }
        if (price < 20)
            price = 20;
        int roundedPrice = Convert.ToInt32(price);
        try
        {
            string sqlCommand = "INSERT INTO Orders (CollectingCityID,CollectingCityName,CollectingAddress,OrderingDate,DestinationCityID,DestinationCityName,DestinationAddress,DestinationDate,Item,ItemWeight,WorkerID,ClientID,Price,Status) VALUES (" + collectingCityID + ",'" + collectingCityName + "','" + collectingAddress + "','" + date + "'," + destinationCityID + ",'" + destinationCityName + "','" + destinationAddress + "','" + destinationDate + "','" + item + "'," + itemWeight + ",0," + clientID + "," + roundedPrice + ",'New');";

            OleDbConnection myCon = new OleDbConnection(Connect.getConnectionString());
            OleDbCommand cmd = new OleDbCommand(sqlCommand, myCon);
            myCon.Open();
            cmd.ExecuteNonQuery();
            myCon.Close();
            Response.Redirect("HomePage.aspx");
        }
        catch (Exception ex)
        {
            throw ex;
        }
    }
开发者ID:N1vS,项目名称:School-Project,代码行数:55,代码来源:MakeOrder.aspx.cs

示例2: CalculatePrice

    public int CalculatePrice(int num)
    {
        if (num == 1)
        {
            int clientID = Convert.ToInt32(Session["UserID"]);

            Client orderingClient = new Client(clientID);
            City collectingCity = new City(orderingClient.GetCityID());

            string itemWeight = this.TextBoxItemWeight.Text;

            int destinationCityID = Convert.ToInt32(this.DropDownListDestinationCities.SelectedValue);

            //חישוב המחיר
            CityService cs = new CityService();

            int collectingCenterID = collectingCity.GetCenterID();
            int destinationCenterID = cs.GetCenterIDByCityID(destinationCityID);
            int temp = destinationCenterID - collectingCenterID;

            if (temp < 0)
                temp *= -1;
            temp += 1;
            double price;
            price = 5 * Math.Log(double.Parse(itemWeight)) + 10 + (temp * 10);
            if (this.CheckBoxUrgent.Checked)
            {
                price += 10;
            }
            if (price < 20)
                price = 20;
            int roundedPrice = Convert.ToInt32(price);
            return roundedPrice;
        }
        else if (num == 2)
        {

            int collectingCityID = Convert.ToInt32(this.DropDownListCollectingCities.SelectedValue);
            City collectingCity = new City(collectingCityID);

            string itemWeight = this.TextBoxItemWeight2.Text;

            int destinationCityID = Convert.ToInt32(this.DropDownListDestinationCities2.SelectedValue);

            //חישוב המחיר
            CityService cs = new CityService();

            int collectingCenterID = collectingCity.GetCenterID();
            int destinationCenterID = cs.GetCenterIDByCityID(destinationCityID);
            int temp = destinationCenterID - collectingCenterID;

            if (temp < 0)
                temp *= -1;
            temp += 1;
            double price;
            price = 5 * Math.Log(double.Parse(itemWeight)) + 10 + (temp * 10);
            if (this.CheckBoxUrgent2.Checked)
            {
                price += 10;
            }
            if (price < 20)
                price = 20;
            int roundedPrice = Convert.ToInt32(price);
            return roundedPrice;
        }
        else return 0;
    }
开发者ID:N1vS,项目名称:School-Project,代码行数:67,代码来源:CreateOrder.aspx.cs


注:本文中的City.GetCenterID方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。