예제 #1
0
        public Form_VersionInfo(int ShopID, int VersionID, string[] starttime, string[] endtime)
        {
            InitializeComponent();
            CarSummery_Client   = (CarSummeryClient)ClientFactory.GetClient(ClientType.Type.CarSummery);
            OrderSummery_Client = (OrderSummeryClient)ClientFactory.GetClient(ClientType.Type.OrderSummery);
            Car_ViewModel SelectCar    = CarSummery_Client.SelectAllCar().Where(P => P.Version_ID == VersionID).Single();
            int           Versiontotal = SelectCar.Version_Count;

            int Car_Count = OrderSummery_Client.SelectRentaledCarCount_TimeAndVersion(
                ShopID, VersionID,
                Convert.ToInt32(starttime[0]),
                Convert.ToInt32(starttime[1]),
                Convert.ToInt32(starttime[2]),
                Convert.ToInt32(endtime[0]),
                Convert.ToInt32(endtime[1]),
                Convert.ToInt32(endtime[2])
                );
            int nokosite = Versiontotal - Car_Count;

            Label_BaseKM.Text            = SelectCar.Version_BaseKM.ToString();
            Label_Brand.Text             = SelectCar.Brand_Name.ToString();
            Label_Count.Text             = nokosite.ToString();
            Label_Info.Text              = SelectCar.Version_Info;
            Label_Person.Text            = SelectCar.Version_Person.ToString();
            Label_PriceDeposit.Text      = SelectCar.Version_Price_Deposit.ToString();
            Label_PriceMemberCatch.Text  = SelectCar.Version_Price_Member_Catch.ToString();
            Label_PriceMemberRental.Text = SelectCar.Version_Price_Member_Rental.ToString();
            Label_PriceNormalCatch.Text  = SelectCar.Version_Price_Normal_Catch.ToString();
            Label_PriceNormalRental.Text = SelectCar.Version_Price_Normal_Rental.ToString();
            Label_PriceOver.Text         = SelectCar.Version_Price_Over.ToString();
            Label_PriceOverRiding.Text   = SelectCar.Version_Price_Over_Riding.ToString();
            Label_PriceRiding.Text       = SelectCar.Version_Price_Riding.ToString();
            Label_Type.Text              = SelectCar.Type_Name;
            Label_Version.Text           = SelectCar.Version_Name;
            try
            {
                string[] imgArr = SelectCar.Version_IMG.ToString().Split(new char[] { ',' });

                byte[] bty = Array.ConvertAll <string, byte>(imgArr, delegate(string s) { return(byte.Parse(s)); });

                Bitmap bmp = new Bitmap(bty.FromBytes(520, null));
                PB_Pic.Image = bmp;
            }
            catch
            {
                MessageBox.Show("载入图片出现错误,请重新上传图片更新数据库或联系管理员!", "错误!!", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1);
            }
        }
예제 #2
0
        private void BT_AddOrder_Click(object sender, EventArgs e)
        {
            if (LB_Version.SelectedIndex < 0)
            {
                MessageBox.Show("请选择您要预定的车型!");
                return;
            }
            int VersionID    = List_Version.Where(P => P.Version_Name == LB_Version.SelectedItem.ToString()).Single().Version_ID;
            int Versiontotal = List_Version.Where(P => P.Version_Name == LB_Version.SelectedItem.ToString()).Single().Version_Count;

            string[] starttime = TM_Start.Value.ToShortDateString().Split('/');
            string[] endtime   = TM_Back.Value.ToShortDateString().Split('/');
            int      Car_Count = OrderSummery_Client.SelectRentaledCarCount_TimeAndVersion(
                ShopID, VersionID,
                Convert.ToInt32(starttime[0]),
                Convert.ToInt32(starttime[1]),
                Convert.ToInt32(starttime[2]),
                Convert.ToInt32(endtime[0]),
                Convert.ToInt32(endtime[1]),
                Convert.ToInt32(endtime[2])
                );
            int nokosite = Versiontotal - Car_Count;

            if (nokosite < Convert.ToInt32(TB_Count.Text))
            {
                MessageBox.Show(String.Format("该车型目前只剩下{0}辆,您预定的数量超过库存数量!", nokosite));
                return;
            }
            else
            {
                DialogResult res =
                    MessageBox.Show("您是否确定要将这条订单添加到数据库?", "警告!", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2);
                if (res == DialogResult.Cancel)
                {
                    return;
                }
                bool iscatch;
                int  RentalType;
                int  ActionID = List_Action.Where(P => P.Action_Name == CB_Action.SelectedItem.ToString()).Single().Action_ID;
                if (RB_Self.Checked)
                {
                    iscatch = false;
                }
                else
                {
                    iscatch = true;
                }
                if (RB_SelfGet.Checked)
                {
                    RentalType = 1;
                }
                else
                {
                    RentalType = 2;
                }
                OrderService.Car_Order Temp = new OrderService.Car_Order()
                {
                    Order_Action     = ActionID,
                    Order_Count      = Convert.ToInt32(TB_Count.Text),
                    Order_End_Time   = new DateTime(Convert.ToInt32(endtime[0]), Convert.ToInt32(endtime[1]), Convert.ToInt32(endtime[2])),
                    Order_Start_Time = new DateTime(Convert.ToInt32(starttime[0]), Convert.ToInt32(starttime[1]), Convert.ToInt32(starttime[2])),
                    Order_IsCatch    = iscatch,
                    Order_Message    = TB_Message.Text,
                    Order_RentalType = RentalType,
                    Order_Shop       = ShopID,
                    Order_User       = List_User.Where(P => P.UserName == Label_User.Text).Single().UserID,
                    Order_Version    = VersionID,
                    Order_Time       = DateTime.Now
                };
                if (Order_Client.AddOrder(Temp))
                {
                    MessageBox.Show("提交订单成功!");
                    List_Version = Version_Client.SelectAllVersions().Where(P => P.Version_Shop == ShopID).ToList();
                }
                else
                {
                    MessageBox.Show("提交订单失败!请检查拼写,如错误依旧,请联系管理员!", "错误!", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1);
                }
            }
        }