public ActionResult Create([Bind(Include = "intEquipmentID,intGarageRoom,intManufacturerID,intModelID,strManufYear,intSNPrefixID,strSerialNo,intEquipmentTypeID,intSMCSFamilyID,intSizeID,CreateDate,intMetered,LastDate,intLastMetered,intTotalMetered,intlimitDay,intlimitWeek,bitActive,bitPreservation,bitMeter,bitKTG,isDelete,intLocationId,strDescription,floatCostTires,intCostTiresCurrency,floatAverageDivergence,floatFullPrice,intFullPriceCurrency,dateStartUpDate,intServiceLife,intHoweverOddsAcceleration,bitMethodAmortization")] newEquipment newEquipment)
        {
            if (ModelState.IsValid)
            {
                db.newEquipments.Add(newEquipment);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.intManufacturerID = new SelectList(db.TablesManufacturers, "intManufacturerID", "strManufacturerChecklistId", newEquipment.intManufacturerID);
            ViewBag.intModelID        = new SelectList(db.TablesModels, "intModelID", "strName", newEquipment.intModelID);
            return(View(newEquipment));
        }
Esempio n. 2
0
 public void Set_Data(int ManID, int ModID, int locID)
 {
     try
     {
         using (MCSEntities db = new MCSEntities())
         {
             newEquipment Eq = new newEquipment
             {
                 //intEquipmentID = 847,                                                      //[intEquipmentID] [int] IDENTITY(1,1) NOT NULL,
                 intGarageRoom              = null,                                            //[intGarageRoom] [nvarchar](50) NULL,
                 intManufacturerID          = ManID,                                           //[intManufacturerID] [int] NOT NULL,
                 intModelID                 = ModID,                                           //****                                                //[intModelID] [int] NOT NULL,
                 strManufYear               = DateTime.Now.Year.ToString(),                    //[strManufYear] [nvarchar](4) NULL,
                 intSNPrefixID              = (int)DateTime.Now.Second,                        //[intSNPrefixID] [int] NOT NULL,
                 strSerialNo                = null,                                            //[strSerialNo] [nvarchar](20) NULL,
                 intEquipmentTypeID         = (new Random()).Next(1, 999),                     //[intEquipmentTypeID] [int] NOT NULL,
                 intSMCSFamilyID            = (new Random()).Next(1, 999),                     //[intSMCSFamilyID] [int] NOT NULL,
                 intSizeID                  = (new Random()).Next(300, 9999),                  //[intSizeID] [int] NOT NULL,
                 CreateDate                 = null,                                            //[CreateDate] [date] NULL,
                 intMetered                 = ((double)(new Random()).Next(1000, 9999)) / 100, //[intMetered] [float] NOT NULL,
                 LastDate                   = DateTime.Now,                                    //[LastDate] [date] NOT NULL,
                 intLastMetered             = ((double)(new Random()).Next(1000, 9999)) / 100, //[intLastMetered] [float] NOT NULL,
                 intTotalMetered            = ((double)(new Random()).Next(1000, 9999)) / 100, //[intTotalMetered] [float] NOT NULL,
                 intlimitDay                = (new Random()).Next(1, 30),                      //[intlimitDay] [int] NULL,
                 intlimitWeek               = (new Random()).Next(1, 7),                       //[intlimitWeek] [int] NULL,
                 bitActive                  = Convert.ToBoolean((new Random()).Next(0, 1)),    //[bitActive] [bit] NOT NULL,
                 bitPreservation            = Convert.ToBoolean((new Random()).Next(0, 1)),    //[bitPreservation] [bit] NOT NULL,
                 bitMeter                   = Convert.ToBoolean((new Random()).Next(0, 1)),    //[bitMeter] [bit] NOT NULL,
                 bitKTG                     = Convert.ToBoolean((new Random()).Next(0, 1)),    //[bitKTG] [bit] NOT NULL,
                 isDelete                   = Convert.ToBoolean((new Random()).Next(0, 1)),    //[isDelete] [bit] NOT NULL CONSTRAINT [DF_newEquipment_isDelete]  DEFAULT ((0)),
                 intLocationId              = locID,                                           //[intLocationId] [int] NOT NULL,
                 strDescription             = null,                                            //[strDescription] [nvarchar](1050) NULL,
                 floatCostTires             = null,                                            //[floatCostTires] [float] NULL,
                 intCostTiresCurrency       = null,                                            //[intCostTiresCurrency] [int] NULL,
                 floatAverageDivergence     = null,                                            //[floatAverageDivergence] [float] NULL,
                 floatFullPrice             = null,                                            //[floatFullPrice] [float] NULL,
                 intFullPriceCurrency       = null,                                            //[intFullPriceCurrency] [int] NULL,
                 dateStartUpDate            = null,                                            //[dateStartUpDate] [date] NULL,
                 intServiceLife             = null,                                            //[intServiceLife] [int] NULL,
                 intHoweverOddsAcceleration = null,                                            //[intHoweverOddsAcceleration] [int] NULL,
                 bitMethodAmortization      = true                                             //[bitMethodAmortization] [bit] NOT NULL,
                                                                                               //TablesLocation = null,
                                                                                               //TablesManufacturer = null,
                                                                                               //TablesModel = null
             };
             db.newEquipment.Add(Eq);
             db.SaveChanges();
             MessageBox.Show("Данные записаны");
         }
     }
     catch (Exception)
     {
         MessageBox.Show("Невозможно записать данные");
     }
 }
Esempio n. 3
0
        private void EditBtn_OnClick(object sender, RoutedEventArgs e)
        {
            if (intManufacturerIDBox.Text == "" || strNameBox.Text == "")
            {
                MessageBox.Show("Чтобы изменить данные, выберите их из списка!");
            }
            else
            {
                TablesManufacturer tm = new TablesManufacturer();

                tm.intManufacturerID          = int.Parse(intManufacturerIDBox.Text);
                tm.strManufacturerChecklistId = strManufacturerChecklistIdBox.Text;
                tm.strName = strNameBox.Text;

                db.TablesManufacturer.Add(tm);
                db.SaveChanges();
                Clear();
                MessageBox.Show("Объекты изменены");
            }
        }