示例#1
0
        public void RequestLicense(Object sender, EventArgs e)
        {
            if (ProductList.SelectedItem != null && LicenseTypeList.SelectedItem != null && Cost.Text != "0")
            {
                string locProductListID = ProductList.SelectedItem.Value;
                string locLicenseType   = LicenseTypeList.SelectedItem.Value;
                if (locProductListID != "" && locLicenseType != "")
                {
                    Database locDB = new Database();
                    locDB.ConectDB("SendRequestLicense( '" + (string)Session["UserName"] + "', " + Inventions.GetInstance().CurrentProductID +
                                   ", " + Inventions.GetInstance().LicenseType + ")", ReaderRequestLicense);

                    if (IsOk1 == "1")
                    {
                        Error1.Visible = false;
                        Error2.Visible = false;
                    }
                    if (IsOk1 == "-1")
                    {
                        Error1.Visible = true;
                        Error2.Visible = false;
                    }
                    if (IsOk1 == "-2")
                    {
                        Error1.Visible = false;
                        Error2.Visible = true;
                    }

                    DataBind();
                }
            }
        }
示例#2
0
        public void AddFastAction(Object sender, EventArgs e)
        {
            if ((IsIfAction.Checked == false && ProductList.SelectedItem != null && ProductList2.SelectedItem != null &&
                 ActionList2.SelectedItem != null && CountIndex1.Text != "") ||
                (IsIfAction.Checked == true && ProductList.SelectedItem != null && ActionList2.SelectedItem != null))
            {
                string locProductListID  = ProductList.SelectedItem.Value;
                string locProductList2ID = ProductList2.SelectedItem.Value;
                string locActionList2ID  = ActionList2.SelectedItem.Value;

                if (IsIfAction.Checked == true && locProductList2ID == "-")
                {
                    locProductList2ID = "0";
                }


                if ((IsIfAction.Checked == false && locProductListID != "" && locProductList2ID != "" && locActionList2ID != "") ||
                    (IsIfAction.Checked == true && locProductListID != "" && locActionList2ID != ""))
                {
                    Database locDB = new Database();
                    locDB.ConectDB("AddReceivingProduct( '" + (string)Session["UserName"] + "', " + locProductListID + ", " +
                                   locActionList2ID + ", " + locProductList2ID + ", " + CountIndex1.Text + ", " +
                                   IsIfAction.Checked + ")", null);

                    locDB.ConectDB("CalcLicenseCost( '" + (string)Session["UserName"] + "', " + Inventions.GetInstance().CurrentProductID +
                                   ", " + Inventions.GetInstance().LicenseType + ")", ReaderCost);

                    Inventions.GetInstance().GetFastAction((string)Session["UserName"]);
                    DataBind();
                    IfActionsNumberList1.DataSource = CreateIfActionsNumberListDataSource2();
                    IfActionsNumberList1.DataBind();
                }
            }
        }
示例#3
0
        public JsonResult UpdateInvention(Inventions _invention)
        {
            var response = new UpdateInventionResponse()
            {
                Result = false
            };

            #region Update
            using (var session = DatabaseModule.OpenSession())
            {
                using (var tran = session.BeginTransaction())
                {
                    if (!string.IsNullOrEmpty(_invention.Description.ToString().Trim()) || _invention.ScientistID.ID > 0)
                    {
                        session.Update(_invention); //Update
                        tran.Commit();
                        response.Result        = true;
                        response.ResultMessage = "Updated succesfully"; // TODO : Make dynamic and localized
                    }
                }
            }
            return(Json(response));

            #endregion
        }
示例#4
0
        DataView CreateIfActionsNumberListDataSource2()
        {
            Database locDB = new Database();

            return(locDB.GetDataSource("GetIfActionsNumber ('" + (string)Session["UserName"] + "', " +
                                       Inventions.GetInstance().CurrentProductID + ")"));
        }
示例#5
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Inventions.GetInstance() == null)
            {
                Inventions locInventions = new Inventions(1);
            }
            QueryStringParameter locParameters = (QueryStringParameter)FastActionList.SelectParameters[0];

            locParameters.DefaultValue = (string)Session["UserName"];
            QueryStringParameter locParameters2 = (QueryStringParameter)IfActionList.SelectParameters[0];

            locParameters2.DefaultValue = (string)Session["UserName"];


            int OldIndex3 = ActionList2.SelectedIndex;

            ActionList2.DataSource     = CreateActionListDataSource();
            ActionList2.DataTextField  = "TextField";
            ActionList2.DataValueField = "ValueField";
            ActionList2.DataBind();
            ActionList2.SelectedIndex = OldIndex3;

            int OldIndex5 = ProductList.SelectedIndex;

            ProductList.DataSource     = CreateProductListDataSource();
            ProductList.DataTextField  = "TextField";
            ProductList.DataValueField = "ValueField";
            ProductList.DataBind();
            ProductList.SelectedIndex = OldIndex5;
            int OldIndex6 = ProductList2.SelectedIndex;

            ProductList2.DataSource     = CreateProductListDataSource2();
            ProductList2.DataTextField  = "TextField";
            ProductList2.DataValueField = "ValueField";
            ProductList2.DataBind();
            ProductList2.SelectedIndex = OldIndex6;
            int OldIndex7 = ProductList3.SelectedIndex;

            ProductList3.DataSource     = CreateProductListDataSource2();
            ProductList3.DataTextField  = "TextField";
            ProductList3.DataValueField = "ValueField";
            ProductList3.DataBind();
            ProductList3.SelectedIndex = OldIndex7;

            int OldIndex8 = IfActionsNumberList1.SelectedIndex;

            IfActionsNumberList1.DataSource     = CreateIfActionsNumberListDataSource2();
            IfActionsNumberList1.DataTextField  = "TextField";
            IfActionsNumberList1.DataValueField = "ValueField";
            IfActionsNumberList1.DataBind();
            IfActionsNumberList1.SelectedIndex = OldIndex8;

            int OldIndex9 = LicenseTypeList.SelectedIndex;

            LicenseTypeList.DataSource     = CreateLicenseTypeSource();
            LicenseTypeList.DataTextField  = "TextField";
            LicenseTypeList.DataValueField = "ValueField";
            LicenseTypeList.DataBind();
            LicenseTypeList.SelectedIndex = OldIndex9;
        }
示例#6
0
        public ActionResult DeleteConfirmed(int id)
        {
            Inventions invention = db.Inventions.Find(id);

            db.Inventions.Remove(invention);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
示例#7
0
 public ActionResult Edit([Bind(Include = "Num_invention,description,resume")] Inventions invention)
 {
     if (ModelState.IsValid)
     {
         db.Entry(invention).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(invention));
 }
示例#8
0
 public void LicenseTypeChange(Object sender, EventArgs e)
 {
     if (LicenseTypeList.SelectedItem != null)
     {
         Inventions.GetInstance().LicenseType = LicenseTypeList.SelectedItem.Value;
         Database locDB = new Database();
         locDB.ConectDB("CalcLicenseCost( '" + (string)Session["UserName"] + "', " + Inventions.GetInstance().CurrentProductID +
                        ", " + Inventions.GetInstance().LicenseType + ")", ReaderCost);
     }
 }
示例#9
0
        public ActionResult Create([Bind(Include = "Num_invention,description,resume")] Inventions invention)
        {
            if (ModelState.IsValid)
            {
                db.Inventions.Add(invention);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(invention));
        }
示例#10
0
        public bool DropInvention(Invention pInvention)
        {
            if (!Inventions.Contains(pInvention))
            {
                Console.WriteLine("You haven't got this invention! Cheater?");
                return(false);
            }

            Inventions.Remove(pInvention);
            Console.WriteLine($"{Name} изобрёл [{pInvention.ID}]{pInvention.Name}");

            return(true);
        }
示例#11
0
        // GET: Inventions/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Inventions invention = db.Inventions.Find(id);

            if (invention == null)
            {
                return(HttpNotFound());
            }
            return(View(invention));
        }
示例#12
0
        public void ProductListChange(Object sender, EventArgs e)
        {
            if (ProductList.SelectedItem != null)
            {
                string locProductListID = ProductList.SelectedItem.Value;

                Inventions.GetInstance().CurrentProductID = locProductListID;
                Inventions.GetInstance().GetFastAction((string)Session["UserName"]);
                Database locDB = new Database();
                locDB.ConectDB("CalcLicenseCost( '" + (string)Session["UserName"] + "', " + Inventions.GetInstance().CurrentProductID +
                               ", " + Inventions.GetInstance().LicenseType + ")", ReaderCost);
                DataBind();
            }
            IfActionsNumberList1.DataSource = CreateIfActionsNumberListDataSource2();
            IfActionsNumberList1.DataBind();
        }
示例#13
0
        public static void ClearDictionaries()
        {
            States.Clear();
            Continents.Clear();
            PopTypes.Clear();
            Goods.Clear();
            CountryTags.Clear();
            Religions.Clear();
            Cultures.Clear();
            CultureGroups.Clear();
            Ideologies.Clear();
            Buildings.Clear();
            PolicyGroups.Clear();
            SubPolicies.Clear();
            Schools.Clear();
            Techs.Clear();
            Inventions.Clear();
            Units.Clear();
            Governments.Clear();
            Crimes.Clear();
            EventModifiers.Clear();
            NationalValues.Clear();
            Terrain.Clear();

            States         = null;
            Continents     = null;
            PopTypes       = null;
            Goods          = null;
            CountryTags    = null;
            Religions      = null;
            Cultures       = null;
            CultureGroups  = null;
            Ideologies     = null;
            Buildings      = null;
            PolicyGroups   = null;
            SubPolicies    = null;
            Schools        = null;
            Techs          = null;
            Inventions     = null;
            Units          = null;
            Governments    = null;
            Crimes         = null;
            EventModifiers = null;
            NationalValues = null;
            Terrain        = null;
        }
示例#14
0
        public ActionResult About(Inventions _dataModel)
        {
            #region Insert
            using (var session = DatabaseModule.OpenSession())
            {
                using (var tran = session.BeginTransaction())
                {
                    Inventions inventionsEntities = new Inventions {
                        InventionID = _dataModel.InventionID, ScientistID = _dataModel.ScientistID
                    };
                    session.Save(inventionsEntities);
                    tran.Commit();

                    return(View());
                }
            }
            #endregion
        }
示例#15
0
        public void CheckAnswer()
        {
            var selectedInventor = Inventors.First(i => i.Id == SelectedInventor);

            if (selectedInventor.Invention == SelectedInvention)
            {
                Inventors.Remove(selectedInventor);
                Inventions.Remove(selectedInventor.Invention);

                SelectedInventor  = null;
                SelectedInvention = null;

                Points++;
            }
            else
            {
                Points = Points - 2;
            }
        }
示例#16
0
 public ActionResult Contact(Invention _invention)
 {
     #region Insert
     using (var session = DatabaseModule.OpenSession())
     {
         using (var tran = session.BeginTransaction())
         {
             if (_invention.Description != null || _invention.ScientistID != null)
             {
                 Inventions inventions = new Inventions {
                     ScientistID = _invention.ScientistID, Description = _invention.Description.ToString()
                 };
                 session.Save(inventions);
                 tran.Commit();
             }
             return(View());
         }
     }
     #endregion
 }
示例#17
0
        public void DeleteIfActions(Object sender, EventArgs e)
        {
            for (int i = 0; i < IfActionList1.Items.Count; i++)
            {
                CheckBox locCheckBox = IfActionList1.Items[i].FindControl("CheckIfAction") as CheckBox;
                if (locCheckBox.Checked == true)
                {
                    Label locLabelN1 = IfActionList1.Items[i].FindControl("N1") as Label;
                    Label locLabelN2 = IfActionList1.Items[i].FindControl("N2") as Label;
                    //Label locLabelN3 = IfActionList1.Items[i].FindControl("N3") as Label;

                    Database locDB = new Database();
                    locDB.Exec("DeleteIfAction (" + locLabelN1.Text + ", " + locLabelN2.Text + ")");
                    locDB.ConectDB("CalcLicenseCost( '" + (string)Session["UserName"] + "', " + Inventions.GetInstance().CurrentProductID +
                                   ", " + Inventions.GetInstance().LicenseType + ")", ReaderCost);
                }
            }
            Inventions.GetInstance().GetIfAction((string)Session["UserName"]);
            DataBind();
        }
示例#18
0
        public void AddIFAction(Object sender, EventArgs e)
        {
            if (IfActionsNumberList1.SelectedItem != null && ProductList3.SelectedItem != null &&
                CountIndex2.Text != "")
            {
                string locIfActionsNumber = IfActionsNumberList1.SelectedItem.Value;
                string locProductList3ID  = ProductList3.SelectedItem.Value;


                if (locIfActionsNumber != "" && locProductList3ID != "")
                {
                    Database locDB = new Database();
                    locDB.ConectDB("AddIfAction( '" + (string)Session["UserName"] + "', " + Inventions.GetInstance().CurrentProductID + ", " +
                                   locIfActionsNumber + ", " + locProductList3ID + ", " + CountIndex2.Text + ")", null);
                    locDB.ConectDB("CalcLicenseCost( '" + (string)Session["UserName"] + "', " + Inventions.GetInstance().CurrentProductID +
                                   ", " + Inventions.GetInstance().LicenseType + ")", ReaderCost);

                    Inventions.GetInstance().GetIfAction((string)Session["UserName"]);
                    DataBind();
                }
            }
        }
示例#19
0
 public int GetInventionsCount()
 {
     return(Inventions.Count());
 }