Exemple #1
0
        private void ShowInfo(int _id)
        {
            BLL.carbll    bll   = new BLL.carbll();
            Model.carinfo model = bll.GetModel(_id);

            txtCar_Number.Text         = model.Car_Number;
            txtCar_Name.Text           = model.Car_Name;
            ddlDept_Pros.SelectedValue = model.Dept_Pros;
            ddlCar_Type.SelectedValue  = model.Car_Type.Type_Code;
            ddlDriver.SelectedValue    = model.Driver.Driver_Code;
            txtBuy_Date.Text           = model.Buy_Date.Replace(" 0:00:00", "");
            txtPrice.Text         = model.Price.ToString();
            txtMileage_First.Text = model.Mileage_First.ToString();
            //ddlStatus.SelectedValue = model.Status.ToString();
            txtOil_Consumption.Text = model.Oil_Consumption.ToString();
            txtEngine_Number.Text   = model.Engine_Number;
            txtFrame_Number.Text    = model.Frame_Number;
            txtWeight.Text          = model.Weight.ToString();
            txtSeat.Text            = model.Seat.ToString();
            txtcContent.Text        = model.cContent;
            string s1 = model.Image1;
            string s2 = model.Image2;

            Image1.ImageUrl = "~/" + s1.Replace("~/", "");
            Image2.ImageUrl = "~/" + s2.Replace("~/", "");
            //FileUpload1.FileName=model.Image1;
            //FileUpload2.FileName = model.Image2;
        }
Exemple #2
0
        private bool DoEdit(int _id)
        {
            bool result = true;

            BLL.carbll    bll   = new BLL.carbll();
            Model.carinfo model = bll.GetModel(_id);

            model.Car_Number         = txtCar_Number.Text.Trim();
            model.Car_Name           = txtCar_Name.Text;
            model.Dept_Pros          = ddlDept_Pros.SelectedValue;
            model.Car_Type.Type_Code = ddlCar_Type.SelectedValue;
            model.Driver.Driver_Code = ddlDriver.SelectedValue;
            model.Buy_Date           = txtBuy_Date.Text;
            model.Price         = Convert.ToDouble(txtPrice.Text.Trim() == "" ? "0" : txtPrice.Text.Trim());
            model.Mileage_First = Convert.ToInt32(txtMileage_First.Text.Trim() == "" ? "0" : txtMileage_First.Text.Trim());
            //model.Status = Convert.ToInt32(ddlStatus.SelectedValue);

            model.Oil_Consumption = float.Parse(txtOil_Consumption.Text.Trim() == "" ? "0" : txtOil_Consumption.Text.Trim());
            model.Engine_Number   = txtEngine_Number.Text;
            model.Frame_Number    = txtFrame_Number.Text;
            model.Weight          = float.Parse(txtWeight.Text.Trim() == "" ? "0" : txtWeight.Text.Trim());
            model.Seat            = Convert.ToInt32(txtSeat.Text.Trim() == "" ? "0" : txtSeat.Text.Trim());
            model.cContent        = txtcContent.Text;
            model.Image1          = Image1.ImageUrl;
            model.Image2          = Image2.ImageUrl;
            model.Image1          = model.Image1.Replace("~/", "");
            model.Image2          = model.Image2.Replace("~/", "");
            string        savepath = HttpRuntime.AppDomainAppPath + "upload";
            List <string> files    = new List <string>();
            bool          b        = ControlCenter.saveFile(savepath, ref files, Request.Files, admin_info.user_name);

            if (b)
            {
                for (int i = 0; i < files.Count; i++)
                {
                    string s = files[i];
                    if (s.Contains("FileUpload1"))
                    {
                        model.Image1    = s;
                        Image1.ImageUrl = s;
                    }
                    else if (s.Contains("FileUpload2"))
                    {
                        model.Image2    = s;
                        Image2.ImageUrl = s;
                    }
                }
            }
            if (!bll.Update(model))
            {
                result = false;
            }
            return(result);
        }