Ejemplo n.º 1
0
        public void Save(object o)
        {
            db db1 = new db();
            character t = (character)o;

            if (t.IsDirty)
            {
                // save dirt to database
                db1 = new MMO.db();
                db1.SetCommand("s_SaveCharacter", CommandType.StoredProcedure);
                db1.AddParam<int>("id", SqlDbType.Int, 4, t.id);
                db1.AddParam<int>("login", SqlDbType.Int, 4, owner.loginID);
                db1.AddParam<string>("charactername", SqlDbType.VarChar, 50, t.name);
                db1.AddParam<int>("charactertype", SqlDbType.Int, 4, 0);
                db1.AddParam<int>("hp", SqlDbType.Int, 4, t.hp);
                db1.AddParam<int>("stamina", SqlDbType.Int, 4, t.stamina);
                db1.AddParam<int>("mana", SqlDbType.Int, 4, t.mana);
                db1.AddParam<int>("x", SqlDbType.Int, 4, t.x);
                db1.AddParam<int>("y", SqlDbType.Int, 4, t.y);

                // return value of runscalar is the new or old id of tile
                t.id = Int32.Parse(db1.RunScalar().ToString());

                // no dirt to save
                t.IsDirty = false;
            }
        }
Ejemplo n.º 2
0
 protected void regDBImage(string[] info)
 {
     string name = info[0];
     string fn = info[1];
     string description = info[2];
     string email = info[3];
     string path = info[4];
     DateTime date = DateTime.Now;
     int UserID = util.getID(email);
     db dbc = new db();
     try
     {
         dbc.cmd.CommandText = "INSERT INTO pictures (name,filename,description,userID,date,path) VALUES(@Name,@FileName,@Description,@UserID,@Date,@Path)";
         dbc.cmd.Parameters.Add(new SqlParameter("Name", name));
         dbc.cmd.Parameters.Add(new SqlParameter("FileName", fn));
         dbc.cmd.Parameters.Add(new SqlParameter("Description", description));
         dbc.cmd.Parameters.Add(new SqlParameter("UserID", UserID));
         dbc.cmd.Parameters.Add(new SqlParameter("Date", date));
         dbc.cmd.Parameters.Add(new SqlParameter("Path", path));
         dbc.cmd.ExecuteNonQuery();
     }
     catch
     {
         Gavan.Global.error = "ההעלה נכשלה נסה שוב.";
     }
 }
Ejemplo n.º 3
0
    //get the order
    protected int getquestionorder()
    {
        int temporder = 0;
        SqlDataReader dreader;
        SqlCommand findorder = new SqlCommand("select Top 1* from " + quizquestionstable + " where quizid=@quizid order by 'questionorder' Desc");
        findorder.Parameters.AddWithValue("quizid", quizId);

        db getorder = new db();
        dreader = getorder.returnDataReader(findorder);

        if (!dreader.HasRows)
        {
            temporder = 1;
        }
        else
        {
            while (dreader.Read())
            {
                string temporderstr = dreader["questionorder"].ToString();
                int itempos = Convert.ToInt32(temporderstr);
                temporder = itempos + 1;
            }
        }
        return temporder;
    }
Ejemplo n.º 4
0
        public List<character> GetCharacters()
        {
            db db1 = new db();

            db1.SetCommand("s_CharactersGet", CommandType.StoredProcedure);
            db1.AddParam<int>("LoginID", SqlDbType.Int, 4, owner.loginID);

            db1.Read();

            // access the datareader within the class
            while (db1.dr.Read())
            {
                character chr1 = new character();

                chr1.id = Int32.Parse(db1.dr["id"].ToString());
                chr1.hp = Int32.Parse(db1.dr["hp"].ToString());
                chr1.mana = Int32.Parse(db1.dr["mana"].ToString()); 
                chr1.owner = owner.loginName;
                chr1.stamina = Int32.Parse(db1.dr["stamina"].ToString());
                //chr1.tile_on = Int32.Parse(db1.dr["tile_on"].ToString());
                chr1.x = Int32.Parse(db1.dr["x"].ToString());
                chr1.y = Int32.Parse(db1.dr["y"].ToString());
                chr1.name = db1.dr["charactername"].ToString();

                list.Add(
                    chr1
                );
            }

            return list;
        }
Ejemplo n.º 5
0
    protected void bindentries()
    {
        DataTable dTable = new DataTable();
        SqlCommand getresponses = new SqlCommand("select id, email, name, correctanswers, wronganswers from " + quizresponsestable + " where quizid=@quizid");
        getresponses.Parameters.AddWithValue("quizid", quizId);

        db getresponseslist = new db();
        dTable = getresponseslist.returnDataTable(getresponses);

        if (dTable.Rows.Count > 0)
        {
            responsesdiv.Visible = true;
            responsesrpt.Visible = true;
            exportdiv.Visible = true;
            lblmessage.Visible = false;

            responsesrpt.DataSource = dTable;
            responsesrpt.DataBind();

            lblmessage.Visible = true;
            lblmessage.Text = "Total Entries: " + dTable.Rows.Count.ToString() + "<br />";
        }
        else
        {
            responsesdiv.Visible = false;
            responsesrpt.Visible = false;
            exportdiv.Visible = false;
            lblmessage.Visible = true;
            lblmessage.Text = "Nothing available at the moment" + "<br /><br />";
        }
    }
Ejemplo n.º 6
0
 protected void LoadData()
 {
     db dbc = new db();
     string query = "SELECT * FROM pages ORDER BY id DESC";
     dbc.cmd.CommandText = query;
     SqlDataAdapter da = new SqlDataAdapter(dbc.cmd);
     DataTable dt = new DataTable();
     da.Fill(dt);
     PagedDataSource pgitems = new PagedDataSource();
     DataView dv = new DataView(dt);
     pgitems.DataSource = dv;
     pgitems.AllowPaging = true;
     pgitems.PageSize = 9;
     pgitems.CurrentPageIndex = PageNumber;
     if (pgitems.PageCount > 1)
     {
         rptPages.Visible = true;
         ArrayList pages = new ArrayList();
         for (int i = 0; i < pgitems.PageCount; i++)
             pages.Add((i + 1).ToString());
         rptPages.DataSource = pages;
         rptPages.DataBind();
     }
     else
         rptPages.Visible = false;
     rptContent.DataSource = pgitems;
     rptContent.DataBind();
 }
Ejemplo n.º 7
0
 protected void deleteUserPicturesFromDB(int id)
 {
     db dbc = new db();
     string query = "DELETE FROM pictures WHERE userID = @Id";
     dbc.cmd.Parameters.Add(new SqlParameter("Id", id));
     dbc.cmd.CommandText = query;
     dbc.cmd.ExecuteNonQuery();
 }
        public AuthWindow()
        {
            InitializeComponent();

            DataContext = new db();
//            InitAuth();

        }
Ejemplo n.º 9
0
 protected void DeleteInfo(int id)
 {
     db dbc = new db();
     string query = "DELETE FROM Info WHERE id=@Id";
     dbc.cmd.Parameters.Add(new SqlParameter("Id", id));
     dbc.cmd.CommandText = query;
     dbc.cmd.ExecuteNonQuery();
 }
Ejemplo n.º 10
0
        //
        // GET: /Product/Edit/5
        public ActionResult Edit(int id)
        {
            var db = new db();

            var product = db.Products.SingleOrDefault(x => x.Id == id);

            return View(product);
        }
Ejemplo n.º 11
0
 protected void UpdatePicture(int PictureID, string picname, string description)
 {
     db dbc = new db();
     dbc.cmd.Parameters.Add(new SqlParameter("Name", picname));
     dbc.cmd.Parameters.Add(new SqlParameter("Description", description));
     dbc.cmd.Parameters.Add(new SqlParameter("PictureID", PictureID));
     dbc.cmd.CommandText = "UPDATE pictures SET name = @Name, description = @Description WHERE id = @PictureID";
     dbc.cmd.ExecuteNonQuery();
 }
Ejemplo n.º 12
0
        private int GetLoginID(string username)
        {
            MMO.db db1 = new db();

            /* if not exist, create and then return id */
            db1.SetCommand("s_LoginIDGet", CommandType.StoredProcedure);
            db1.AddParam<string>("Login", SqlDbType.NVarChar, 50, username);

            return Int32.Parse(db1.RunScalar().ToString());
        }
Ejemplo n.º 13
0
 protected void SendInfo(string name, string content, string url)
 {
     db dbc = new db();
     string query = "INSERT INTO pages(title, content,url) VALUES(@Name, @Content, @URL)";
     dbc.cmd.Parameters.Add(new SqlParameter("Name", name));
     dbc.cmd.Parameters.Add(new SqlParameter("Content",content));
     dbc.cmd.Parameters.Add(new SqlParameter("URL",url));
     dbc.cmd.CommandText = query;
     dbc.cmd.ExecuteNonQuery();
 }
Ejemplo n.º 14
0
 protected void UpdateInfo(string name, string content,int id)
 {
     db dbc = new db();
     string query = "UPDATE Info SET name=@Name, content=@Content WHERE id=@Id";
     dbc.cmd.Parameters.Add(new SqlParameter("Name", name));
     dbc.cmd.Parameters.Add(new SqlParameter("Content",content));
     dbc.cmd.Parameters.Add(new SqlParameter("Id", id));
     dbc.cmd.CommandText = query;
     dbc.cmd.ExecuteNonQuery();
 }
Ejemplo n.º 15
0
    protected void bindquestion()
    {
        SqlDataReader dreader;
        SqlCommand getquestioncmd = new SqlCommand("select id, quizid, type, title from " + quizquestionstable + " where id=@questionid");
        getquestioncmd.Parameters.AddWithValue("questionid", qId);

        db getquestion = new db();
        dreader = getquestion.returnDataReader(getquestioncmd);

        if (!dreader.HasRows)
        {
            editquestiondiv.InnerHtml = "<br /><span style='color:#FF0000; font-size:15px;'>Sorry! we could not complete your request at this time. please try again later.</span><br />";
        }
        else
        {
            while (dreader.Read())
            {
                //set the home link
                string quizidstr = dreader["quizid"].ToString();
                HyperLink homelink = (HyperLink)Master.FindControl("homelnk");
                if (homelink != null)
                {
                    homelink.NavigateUrl = "setquestions?q=" + quizidstr;
                }

                //detect question type and set the template
                qtype = dreader["type"].ToString();

                if (qtype == "single")
                {
                    singleoptiondiv.Visible = true;
                    textoptiondiv.Visible = false;

                    questionstr = dreader["title"].ToString();
                    txtsingleoption.Text = questionstr;

                    populateoptions(qId);
                }
                else if (qtype == "text")
                {
                    singleoptiondiv.Visible = false;
                    textoptiondiv.Visible = true;

                    questionstr = dreader["title"].ToString();

                    txttextoption.Text = questionstr;
                    txttextoptionanswer.Text = textoptionstr;
                }
                else
                {
                    //do nothing for time being
                }
            }
        }
    }
Ejemplo n.º 16
0
 public FaceSetBrowser(String faceSetName, Manager fm, db.TrainingRunInfo modelInfo)
 {
     InitializeComponent();
     faceGridControl1.initColumns(2);
     faceGridControl1._fm = fm;
     _faces = fm.GetFaceSet(faceSetName);
     this.Text = "Face Set: " + faceSetName + ", " + _faces.Count + " faces.";
     faceGridControl1.Init(_faces);
     _modelInfo = modelInfo;
     _fm = fm;
     _faceSetName = faceSetName;
 }
Ejemplo n.º 17
0
        private db dba; //-> Persistent database handler objecct in form memory

        #endregion Fields

        #region Constructors

        public form1()
        {
            InitializeComponent();
            try
            {
                dba = new db();
            }
            catch(Exception e)
            {
                MetroFramework.MetroMessageBox.Show(this, "Database Connection Failure: " + e.Message.ToString() , "MySQL Error",
                    MessageBoxButtons.OK, MessageBoxIcon.Error);
                throw;
            }
        }
Ejemplo n.º 18
0
 protected void deleteFromPics(int pictureID)
 {
     db dbc = new db();
     try
     {
         string query = "DELETE FROM pictures WHERE id = @PictureID";
         dbc.cmd.Parameters.Add(new SqlParameter("PictureID", pictureID));
         dbc.cmd.CommandText = query;
         dbc.cmd.ExecuteNonQuery();
     }
     catch
     {
         Response.Write("ישנה בעיה.");
     }
 }
Ejemplo n.º 19
0
        protected void deleteComment(int commentID)
        {
            try
            {

                db dbc = new db();
                string query = "DELETE FROM comments WHERE id = @CommentID";
                dbc.cmd.Parameters.Add(new SqlParameter("CommentID", commentID));
                dbc.cmd.CommandText = query;
                dbc.cmd.ExecuteNonQuery();
            }
            catch
            {
                Response.Write("ישנה בעיה..");
            }
        }
Ejemplo n.º 20
0
 protected bool existComment(int commentID)
 {
     int counter = 0;
     db dbc = new db();
     string query = "SELECT * FROM comments WHERE id = @CommentID";
     dbc.cmd.Parameters.Add(new SqlParameter("CommentID", commentID));
     dbc.cmd.CommandText = query;
     SqlDataReader reader = dbc.cmd.ExecuteReader();
     if (reader.Read())
     {
         counter++;
     }
     if (counter == 1)
         return true;
     return false;
 }
Ejemplo n.º 21
0
        protected void UpdateUser(string[] data)
        {
            db dbc = new db();
            string query = "UPDATE users SET name = @Name, email = @Email, password = @Password, status = @Status, grade = @Grade WHERE id = @ID";
            if(String.IsNullOrEmpty(data[2]) && data[2] == data[3])
                query = "UPDATE users SET name = @Name, email=@Email, status = @Status, grade = @Grade WHERE id = @ID";

            dbc.cmd.Parameters.Add(new SqlParameter("Name", data[0]));
            dbc.cmd.Parameters.Add(new SqlParameter("Email", data[1]));
            dbc.cmd.Parameters.Add(new SqlParameter("Password", util.hashSalt(data[2])));
            dbc.cmd.Parameters.Add(new SqlParameter("Status", data[4]));
            dbc.cmd.Parameters.Add(new SqlParameter("Grade", data[5]));
            dbc.cmd.Parameters.Add(new SqlParameter("ID", data[6]));
            dbc.cmd.CommandText = query;
            dbc.cmd.ExecuteNonQuery();
        }
Ejemplo n.º 22
0
 protected internal string[] getDetails(int id)
 {
     db dbc = new db();
     dbc.cmd.CommandText = "SELECT name,content FROM Info WHERE id = @Id";
     dbc.cmd.Parameters.Add(new SqlParameter("Id", id));
     SqlDataAdapter adapter = new SqlDataAdapter(dbc.cmd);
     DataSet ds = new DataSet();
     adapter.Fill(ds);
     string[] info = new string[2];
     DataTable dataTable = ds.Tables["info"];
     foreach (DataRow dr in ds.Tables[0].Rows)
     {
         info[0] = Convert.ToString(dr["name"]);
         info[1] = Convert.ToString(dr["content"]);
     }
     return info;
 }
Ejemplo n.º 23
0
 protected void insertRank(int rank, int userID, int pictureID)
 {
     db dbc = new db();
     dbc.cmd.Parameters.Add(new SqlParameter("UserID", userID));
     dbc.cmd.Parameters.Add(new SqlParameter("Rank", rank));
     dbc.cmd.Parameters.Add(new SqlParameter("PictureID", pictureID));
     string query = "INSERT INTO rank(userID,rank,pictureID) VALUES(@UserID, @Rank, @PictureID)";
     try
     {
         dbc.cmd.CommandText = query;
         dbc.cmd.ExecuteNonQuery();
     }
     catch
     {
          Gavan.Global.error = "משהו השתבש...";
     }
 }
Ejemplo n.º 24
0
 protected void sendComment(int pictureID,int userID, string message)
 {
     try
     {
         db dbc = new db();
         string query = "INSERT INTO comments(userID ,pictureID, message) VALUES(@UserID, @PictureID, @Message)";
         dbc.cmd.Parameters.Add(new SqlParameter("PictureID", pictureID));
         dbc.cmd.Parameters.Add(new SqlParameter("UserID", userID));
         dbc.cmd.Parameters.Add(new SqlParameter("Message", message));
         dbc.cmd.CommandText = query;
         dbc.cmd.ExecuteNonQuery();
     }
     catch
     {
         Response.Write("יש פה בעיה..");
     }
 }
Ejemplo n.º 25
0
 protected internal string[] getDataFromDB(int id)
 {
     db dbc = new db();
     string query  = "SELECT * FROM users WHERE id = @ID";
     dbc.cmd.Parameters.Add(new SqlParameter("ID", id));
     dbc.cmd.CommandText = query;
     SqlDataReader reader = dbc.cmd.ExecuteReader();
     string[] Data = new string[4];
     while (reader.Read())
     {
         Data[0] = reader[1].ToString(); // Name
         Data[1] = reader[2].ToString(); // Email
         Data[2] = reader[4].ToString(); // Status
         Data[3] = reader[5].ToString(); // Grade
     }
     return Data;
 }
Ejemplo n.º 26
0
 protected void updateRankPics(int rank, int userID, int pictureID)
 {
     db dbc = new db();
     dbc.cmd.Parameters.Add(new SqlParameter("UserID", userID));
     dbc.cmd.Parameters.Add(new SqlParameter("Rank", rank));
     dbc.cmd.Parameters.Add(new SqlParameter("PictureID", pictureID));
     try
     {
         string query = "UPDATE pictures SET rank = rank+1 WHERE id = @PictureID";
         dbc.cmd.CommandText = query;
         dbc.cmd.ExecuteNonQuery();
     }
     catch
     {
          Gavan.Global.error = "משהו פה לא בסדר.";
     }
 }
Ejemplo n.º 27
0
 protected internal string[] getDetails(int id)
 {
     db dbc = new db();
     dbc.cmd.CommandText = "SELECT title,content,url FROM pages WHERE id = @Id";
     dbc.cmd.Parameters.Add(new SqlParameter("Id", id));
     SqlDataAdapter adapter = new SqlDataAdapter(dbc.cmd);
     DataSet ds = new DataSet();
     adapter.Fill(ds);
     string[] pgData = new string[3];
     DataTable dataTable = ds.Tables["pgData"];
     foreach (DataRow dr in ds.Tables[0].Rows)
     {
         pgData[0] = Convert.ToString(dr["title"]);
         pgData[1] = Convert.ToString(dr["content"]);
         pgData[2] = Convert.ToString(dr["url"]);
     }
     return pgData;
 }
Ejemplo n.º 28
0
 protected void deleteFromComments(int pictureID)
 {
     db dbc = new db();
     try
     {
         if (existComment(pictureID))
         {
             string query = "DELETE FROM comments WHERE pictureID = @PictureID";
             dbc.cmd.Parameters.Add(new SqlParameter("PictureID", pictureID));
             dbc.cmd.CommandText = query;
             dbc.cmd.ExecuteNonQuery();
         }
     }
     catch
     {
         Gavan.Global.error = "ישנה בעיה.";
     }
 }
Ejemplo n.º 29
0
 protected void delteFromRanks(int pictureID)
 {
     db dbc = new db();
     try
     {
         if (existRank(pictureID))
         {
             string query = "DELETE FROM ranks WHERE pictureID = @PictureID";
             dbc.cmd.Parameters.Add(new SqlParameter("PictureID", pictureID));
             dbc.cmd.CommandText = query;
             dbc.cmd.ExecuteNonQuery();
         }
     }
     catch
     {
         Response.Write("ישנה בעיה. ");
     }
 }
Ejemplo n.º 30
0
        protected internal string[] getDetails(int PictureID)
        {
            db dbc = new db();
            dbc.cmd.CommandText = "SELECT name,description FROM pictures WHERE id = @PictureID";
            dbc.cmd.Parameters.Add(new SqlParameter("PictureID", PictureID));

            SqlDataAdapter adapter = new SqlDataAdapter(dbc.cmd);
            DataSet ds = new DataSet();
            adapter.Fill(ds);
            string[] pic = new string[2];
            DataTable dataTable = ds.Tables["pictures"];
            foreach (DataRow dr in ds.Tables[0].Rows)
            {
                pic[0] = Convert.ToString(dr["name"]);
                pic[1] = Convert.ToString(dr["description"]);
            }
            return pic;
        }
Ejemplo n.º 31
0
        private void btnDeleteTask_Click(object sender)
        {
            if (project_taskViewSource.View != null)
            {
                project_taskViewSource.View.Filter = null;
                List <project_task> _project_task = treeProject.ItemsSource.Cast <project_task>().ToList();

                ProjectTaskDB.NumberOfRecords = 0;
                foreach (project_task task in _project_task.Where(x => x.IsSelected == true))
                {
                    if (task.status == Status.Project.Pending)
                    {
                        using (db db = new db())
                        {
                            if (task.id_project_task != 0)
                            {
                                db.project_task.Remove(db.project_task.Where(x => x.id_project_task == task.id_project_task).FirstOrDefault());
                                db.SaveChanges();
                            }
                            else
                            {
                                ProjectTaskDB.Entry(task).State = EntityState.Detached;
                            }
                        }

                        ProjectTaskDB.NumberOfRecords += 1;
                    }
                    else
                    {
                        //ProjectTaskDB.SaveChanges();
                        toolBar_btnAnull_Click(sender);
                    }
                }
                ProjectTaskDB = new entity.ProjectTaskDB();
                ProjectTaskDB.projects.Where(a => a.is_active == true && a.id_company == CurrentSession.Id_Company).Load();//.Include(x => x.project_task).Load();
                projectViewSource.Source           = ProjectTaskDB.projects.Local;
                project_taskViewSource.View.Filter = null;
                project_taskViewSource.View.Refresh();
                filter_task();

                //treeProject.UpdateLayout();
            }
        }
Ejemplo n.º 32
0
    protected void btnNext_Clicksingle(object sender, EventArgs e)
    {
        answer         = Page.Session["answer"].ToString();
        question       = Page.Session["question"].ToString();
        quizId         = Convert.ToInt32(Page.Session["quizid"]);
        selectedanswer = Page.Session["selectedanswer"].ToString();
        quizname       = Page.Session["quizname"].ToString();


        string accurateanswer = "";

        if (selectedanswer.ToLower().Trim().Replace(" ", "") == answer.ToLower().Trim().Replace(" ", ""))
        {
            accurateanswer = "Y";
        }
        else
        {
            accurateanswer = "N";
        }


        SqlCommand insertnew = new SqlCommand("insert into " + quizresponsestable + " (quizid, userid, question, user_answer, correct_answer, accurate_answer, quiz_name, lastupdated) values (@quizid, '*****@*****.**', @question, @user_answer, @correct_answer, @accurate_answer, @quiz_name, @lastupdated);SELECT CAST(scope_identity() AS int)");

        insertnew.Parameters.AddWithValue("quizid", quizId);
        //insertnew.Parameters.AddWithValue("userid", userid);
        insertnew.Parameters.AddWithValue("question", question);
        insertnew.Parameters.AddWithValue("user_answer", selectedanswer);
        insertnew.Parameters.AddWithValue("correct_answer", answer);
        insertnew.Parameters.AddWithValue("accurate_answer", accurateanswer);
        insertnew.Parameters.AddWithValue("quiz_name", quizname);
        insertnew.Parameters.AddWithValue("lastupdated", updatedate);

        db insertnewquestion = new db();

        insertnewquestion.ExecuteQuery(insertnew);

        lberror.Visible = false;
        Image.Visible   = false;
        txtanswer.Text  = null;
        questcounter    = Convert.ToInt32(Page.Session["questcounter"]);
        numques         = Convert.ToInt32(Page.Session["numques"]);
        LoadQuestion();
    }
Ejemplo n.º 33
0
        public AdminMenu(User user)
        {
            db        = new db();
            this.user = user;
            InitializeComponent();
            for (int i = 0; i < 24; i++)
            {
                cbTimeH.Items.Add($"{i}");
            }
            for (int i = 0; i < 60; i++)
            {
                cbTimeM.Items.Add($"{i}");
                cbTimeS.Items.Add($"{i}");
            }
            cbTimeH.SelectedIndex = 0;
            cbTimeM.SelectedIndex = 0;
            cbTimeS.SelectedIndex = 0;
            MessageBox.Show($"{helper.WelcomeTime(DateTime.Now)}, {helper.WelcomeText(user.getsex())} {user.getname()}!");
            lWelcome.Content = $"Привет, {user.getname()}";
            MySqlConnection conn = db.newConnection();
            MySqlCommand    cmd  = new MySqlCommand("SELECT * FROM Event LIMIT 1", conn);

            try
            {
                MySqlDataReader reader = cmd.ExecuteReader();
                if (reader.HasRows)
                {
                    while (reader.Read())
                    {
                        @event = new Event(reader.GetValue(0).ToString(), reader.GetValue(1).ToString(), reader.GetDateTime(2));
                    }
                }
                lAdHeader.Content = @event.getname();
                lAdBody.Text      = "Мероприятие: " + @event.getdescription();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            timer.Tick    += new EventHandler(timerTick);
            timer.Interval = new TimeSpan(0, 0, 1);
            timer.Start();
        }
 public List <ListHistorial> GetLista(int id)
 {
     using (var ctx = new db())
     {
         var query = from servicios in ctx.Servicios
                     join historial in ctx.Historial on servicios.IDservicio equals historial.IDservicio
                     where servicios.IDservicio == id
                     select new ListHistorial
         {
             IDservicio = servicios.IDservicio,
             IDhistoria = historial.IDhistoria,
             IDequipo   = servicios.IDequipo,
             Fecha      = historial.Fecha,
             Comentario = historial.Comentario,
             IDusuario  = historial.IDusuario
         };
         return(query.ToList());
     }
 }
    protected void btnUpdate_Click(object sender, EventArgs e)
    {
        if (TextBox1.Text.Trim() == "")
        {
            Label1.Text = "You entered an empty caption, please fill the caption field";
        }
        if (Session["picid"] == null)
        {
            Response.Redirect("pictures.aspx");
        }
        string s = TextBox1.Text.Trim();
        db     d = new db();

        d.update("UPDATE [familyPhoto].[dbo].[photo] SET  [pCaption] = '" + s + "' WHERE pid=" + Session["picid"].ToString());

        d.updatenews(Convert.ToInt32(Session["id"]), Session["name"].ToString(), "updated", "the caption of an image");

        Label1.Text = "The caption is updated successfully";
    }
Ejemplo n.º 36
0
    public void config()
    {
        db     d1   = new db();
        string path = d1.accessdb();

        OleDbConnection conn = new OleDbConnection(path);

        conn.Open();
        string          sql  = "select * from config";
        OleDbCommand    comm = new OleDbCommand(sql, conn);
        OleDbDataReader odr  = comm.ExecuteReader();

        while (odr.Read())
        {
            title = odr[0].ToString();
        }
        odr.Close();
        conn.Close();
    }
Ejemplo n.º 37
0
    private void show()
    {
        db     d1   = new db();
        string path = d1.accessdb();

        conn = new OleDbConnection(path);
        string sql = "select * from page where page_id=3";

        conn.Open();
        OleDbCommand    comm = new OleDbCommand(sql, conn);
        OleDbDataReader odr  = comm.ExecuteReader();

        while (odr.Read())
        {
            Label1.Text = odr[2].ToString();
        }
        odr.Close();
        conn.Close();
    }
Ejemplo n.º 38
0
    //get the recent quizes
    protected void Bindquizes()
    {
        SqlDataReader dReader;
        SqlCommand    getquizescmd = new SqlCommand("select id, name, description, startdate, enddate, termsandconditions from " + quizdetailstable);

        db getquizeslist = new db();

        dReader = getquizeslist.returnDataReader(getquizescmd);

        if (!dReader.HasRows)
        {
            lblmessage.Visible = true;
            lblmessage.Text    = "Nothing available at the moment" + "<br /><br />";
        }
        else
        {
            while (dReader.Read())
            {
                //get and store quizid
                quizfield.Value = dReader["id"].ToString();
                quizId          = Convert.ToInt32(quizfield.Value);

                //quiz details
                quizname    = dReader["name"].ToString();
                description = dReader["description"].ToString();
                start       = Convert.ToDateTime(dReader["startdate"].ToString());
                end         = Convert.ToDateTime(dReader["enddate"].ToString());
                terms       = dReader["termsandconditions"].ToString();

                //show quiz if start/end date is valid
                if ((updatedate < start) && (updatedate > end))
                {
                    lblmessage.Visible = true;
                    lblmessage.Text    = "Sorry! We could not process your request. please try later.";
                }
                else
                {
                    lblquizname.Text    = quizname;
                    lbldescription.Text = description;
                }
            }
        }
    }
Ejemplo n.º 39
0
    public void show()
    {
        db     d1   = new db();
        string path = d1.accessdb3();

        OleDbConnection conn = new OleDbConnection(path);

        conn.Open();
        string          sql  = "select * from type where type_type=2";
        OleDbCommand    comm = new OleDbCommand(sql, conn);
        OleDbDataReader odr  = comm.ExecuteReader();

        while (odr.Read())
        {
            DropDownList1.Items.Add(odr[1].ToString());
        }
        odr.Close();
        conn.Close();
    }
Ejemplo n.º 40
0
    public void dataview(int id)
    {
        db     d1   = new db();
        string path = d1.accessdb3();

        conn = new OleDbConnection(path);
        conn.Open();
        string          sql = "select * from edit where edit_id=" + id;
        OleDbCommand    ocm = new OleDbCommand(sql, conn);
        OleDbDataReader odr = ocm.ExecuteReader();

        while (odr.Read())
        {
            TextBox1.Text     = string.Format("{0}", odr[1]);
            FreeTextBox1.Text = string.Format("{0}", odr[3]);
        }
        odr.Close();
        conn.Close();
    }
Ejemplo n.º 41
0
 private int save_Rate(int id_currency)
 {
     using (db db = new db())
     {
         if (db.app_currency.Where(x => x.id_currency == id_currency).FirstOrDefault() != null)
         {
             app_currencyfx app_currencyfx = new app_currencyfx();
             app_currencyfx.id_currency  = id_currency;
             app_currencyfx.app_currency = db.app_currency.Where(x => x.id_currency == id_currency).FirstOrDefault();
             app_currencyfx.buy_value    = Rate_Current;
             app_currencyfx.sell_value   = Rate_Current;
             app_currencyfx.is_active    = false;
             db.app_currencyfx.Add(app_currencyfx);
             db.SaveChanges();
             return(app_currencyfx.id_currencyfx);
         }
         return(0);
     }
 }
Ejemplo n.º 42
0
        public static decimal get_activeRate(int id_currency, App.Names application)
        {
            decimal r = 0;

            using (db db = new db())
            {
                if (application == App.Names.SalesOrder ||
                    application == App.Names.SalesInvoice)
                {
                    r = db.app_currencyfx.Where(x => x.id_currency == id_currency && x.is_active == true).FirstOrDefault().buy_value;
                }
                else if (application == App.Names.PurchaseOrder ||
                         application == App.Names.PurchaseInvoice)
                {
                    r = db.app_currencyfx.Where(x => x.id_currency == id_currency && x.is_active == true).FirstOrDefault().sell_value;
                }
            }
            return(r);
        }
Ejemplo n.º 43
0
        protected void Page_Load(object sender, EventArgs e)
        {
            vConexion = new db();
            if (!Page.IsPostBack)
            {
                if (Convert.ToBoolean(Session["AUTH"]))
                {
                    generales vGenerales = new generales();
                    DataTable vDatos     = (DataTable)Session["AUTHCLASS"];
                    if (!vGenerales.PermisosRecursosHumanos(vDatos))
                    {
                        Response.Redirect("/default.aspx");
                    }

                    Cargar();
                }
            }
            DDLEmpleado.CssClass = "fstdropdown-select form-control";
        }
Ejemplo n.º 44
0
        public ActionResult AddMaskForm(AdminAddMaskModel model)
        {
            db db = new db();

            //string FileMask = db.singleItemSelect("maskFile", maskTable, "bakeryId='" + bakeryId + "' AND maskFile='" + model.Mask + "'").ToString();
            if (model.bakeryId != null)
            {
                int bakeryId = int.Parse(model.bakeryId.ToString());
                db.singleItemInsertAsync(maskTable, "bakeryId,maskFile,maskName,maskRole", bakeryId + ",'" + model.Mask + "','" + model.maskName + "','" + model.maskRole + "'");
                Session["success"] = "Mask: " + model.Mask + " has been successfully added to bakery: " + model.bakeryId + ".";
            }
            else
            {
                db.singleItemInsertAsync(maskTable, "bakeryId,maskFile,maskName,maskRole", Session["id"].ToString() + ",'" + model.Mask + "','" + model.maskName + "','" + model.maskRole + "'");
                Session["success"] = "Mask: " + model.Mask + " has been successfully added to bakery: " + Session["id"].ToString() + ".";
            }

            return(RedirectToAction("AddMask", "Admin"));
        }
Ejemplo n.º 45
0
    protected void StartQuiz()
    {
        SqlDataReader dreader;
        SqlCommand    question = new SqlCommand("select title, type, data from " + quizquestionstable + " where id=@qID ");

        question.Parameters.AddWithValue("qID", questionID[questcounter]);

        db getorder = new db();

        dreader = getorder.returnDataReader(question);

        while (dreader.Read())
        {
            lbQuestion.Text          = dreader["title"].ToString();
            Page.Session["question"] = dreader["title"].ToString();
            Byte[] tempdata = dreader["data"] as byte[];
            type = dreader["type"].ToString();
            Page.Session["type"] = type;


            if (tempdata != null)
            {
                string base64String = Convert.ToBase64String(tempdata, 0, tempdata.Length);
                Image.ImageUrl = "data:image/jpeg;base64," + base64String;
                Image.Visible  = true;
            }

            if (type == "multiple")
            {
                multipleoptiondiv.Visible = true;
                BindQuestionsMultipleOption();
            }
            else
            {
                singleoptiondiv.Visible = true;
                BindQuestionsSingleOption();
            }

            questcounter++;
            Page.Session["questcounter"] = questcounter;
        }
    }
Ejemplo n.º 46
0
    protected void btnAdd_Click(object sender, EventArgs e)
    {
        Label1.Visible = false;

        // get the variables
        String caption = TextBox1.Text.Trim();

        try
        {
            string imgContentType = FileUpload1.PostedFile.ContentType;

            //check if an image
            if (imgContentType.ToLower().StartsWith("image"))
            {
                //get the image from upload stream
                System.Drawing.Bitmap b = (System.Drawing.Bitmap)System.Drawing.Image.FromStream(FileUpload1.PostedFile.InputStream);

                int img_pk = 0;
                //store the image in database, and also ccheck to see if it was successful, and if so create
                //a thumnail here of the stored image
                img_pk = dbAccess.SaveImageToDB(BmpToBytes(b), caption, Convert.ToInt32(Session["albumid"]));

                db d = new db();
                d.updatenews(Convert.ToInt32(Session["id"]), Session["name"].ToString(), "inserted new", "picture");

                Label1.Visible = true;

                Label1.Text   = "Your image is added to  album successfully";
                TextBox1.Text = "";
            }
            else
            {
                Label1.Visible = true;
                Label1.Text    = ("The file is not an image");
            }
        }
        catch (Exception ex)
        {
            Label1.Visible = true;
            Label1.Text    = "ERROR: " + ex.Message.ToString();
        }
    }
Ejemplo n.º 47
0
        public async Task <JsonResult> getData()
        {
            string json = null;
            GraphReportResponse response = new GraphReportResponse();
            StreamReader        stream   = new StreamReader(Request.InputStream);

            if (json == null)
            {
                json = stream.ReadToEnd();
            }
            if (json != "")
            {
                //ReportModel RVM = new ReportModel();
                GraphReport.Models.DataRequest dataRequest = JsonConvert.DeserializeObject <GraphReport.Models.DataRequest>(json);
                switch (dataRequest.requestType)
                {
                case RequestType.batches:
                    db conn = new db("InternDelights", 12);

                    break;

                case RequestType.frequency:

                    break;

                case RequestType.differences:

                    break;

                case RequestType.absoulteScale:
                    GraphReportHelper graphReportHelper = new GraphReportHelper();
                    response = await graphReportHelper.GetAbsoulteScale(dataRequest);

                    break;
                }
            }
            else
            {
                return(null);
            }
            return(Json(response, "application/json", JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 48
0
        public ActionResult Login(LoginViewModel model)
        {
            string OldHASHValue = string.Empty;

            try
            {
                using (db db = new db())
                {
                    // Ensure we have a valid viewModel to work with
                    if (!ModelState.IsValid)
                    {
                        return(View(model));
                    }

                    //Retrive Stored HASH Value From Database According To Username (one unique field)
                    var userInfo = pocoDb.Fetch <tblUser>(" WHERE userName = @0 and userPassword=@1", model.UserName, model.UserPassword).FirstOrDefault();
                    if (userInfo != null)
                    {
                        //Login Success
                        //For Set Authentication in Cookie (Remeber ME Option)
                        SignInRemember(model.UserName);

                        //Set A Unique ID in session
                        Session["userId"] = userInfo.userID;

                        // If we got this far, something failed, redisplay form
                        // return RedirectToAction("Index", "Dashboard");
                        return(RedirectToAction("Index", "Issues"));
                    }
                    else
                    {
                        //Login Fail
                        TempData["ErrorMSG"] = "Access Denied! Wrong Credential";
                        return(RedirectToAction("Login", "Home"));
                    }
                }
            }
            catch
            {
                throw;
            }
        }
Ejemplo n.º 49
0
    protected void btnSend_Click(object sender, EventArgs e)
    {
        String subject, com;

        txtComment.ReadOnly = false;
        txtSubject.ReadOnly = false;
        subject             = txtSubject.Text;
        com = txtComment.Text;

        if ((subject.Length == 0) || (com.Trim().Length == 0))
        {
            Label1.Text     = "Enter a subject and comment Please";
            txtSubject.Text = "";
            txtComment.Text = "";
            txtSubject.Focus();
        }
        else
        {
            Label1.Text = "";
            int id = 0;
            if (Session["id"] != null)
            {
                id = int.Parse(Session["id"].ToString());
            }

            //add to db
            db d = new db();
            d.update("INSERT INTO [familyPhoto].[dbo].[contact] ([subject],[comment],[memid])VALUES ('" + subject + "' , '" + com + "' ," + id + ")");
            if (Session["id"] == null)
            {
                d.updatenews(0, "Guest", "inserted new", "comment");
            }
            else
            {
                d.updatenews(Convert.ToInt32(Session["id"]), Session["name"].ToString(), "inserted new", "comment");
            }
            txtComment.ReadOnly = true;
            txtSubject.ReadOnly = true;
            Label1.Text         = "Your comment is sent successfully move to another page please.";
            btnSend.Enabled     = false;
        }
    }
Ejemplo n.º 50
0
    public void photo()
    {
        db     d1   = new db();
        string path = d1.accessdb();

        conn = new OleDbConnection(path);
        string sql = "select top 1 type_id from type where type_type=2";

        conn.Open();
        OleDbCommand    com = new OleDbCommand(sql, conn);
        OleDbDataReader odr = com.ExecuteReader();

        while (odr.Read())
        {
            HyperLink2.NavigateUrl = "photo.aspx?type=" + odr[0];
        }

        odr.Close();
        conn.Close();
    }
Ejemplo n.º 51
0
    public void dataview(int id)
    {
        db     d1   = new db();
        string path = d1.accessdb();

        conn = new OleDbConnection(path);
        string           sql = "select * from edit where edit_id=" + id;
        OleDbDataAdapter oda = new OleDbDataAdapter(sql, conn);
        DataSet          ds  = new DataSet();

        oda.Fill(ds, "title");
        PagedDataSource pds = new PagedDataSource();

        pds.DataSource       = ds.Tables[0].DefaultView;
        pds.CurrentPageIndex = 0;
        pds.AllowPaging      = true;
        pds.PageSize         = 8;//设置每个页面显示的数量
        DataList1.DataSource = pds;
        DataList1.DataBind();
    }
Ejemplo n.º 52
0
    public void show()
    {
        db     d1   = new db();
        string path = d1.accessdb2();

        OleDbConnection conn = new OleDbConnection(path);

        conn.Open();
        string          sql  = "select * from admin";
        OleDbCommand    comm = new OleDbCommand(sql, conn);
        OleDbDataReader odr  = comm.ExecuteReader();

        while (odr.Read())
        {
            TextBox1.Text = odr[1].ToString();
            TextBox2.Text = odr[0].ToString();
        }
        odr.Close();
        conn.Close();
    }
Ejemplo n.º 53
0
        protected void Page_Load(object sender, EventArgs e)
        {
            vConexion = new db();
            if (!Page.IsPostBack)
            {
                if (Convert.ToBoolean(Session["AUTH"]))
                {
                    generales vGenerales = new generales();
                    DataTable vDatos     = (DataTable)Session["AUTHCLASS"];
                    if (!vGenerales.PermisosRecursosHumanos(vDatos))
                    {
                        Response.Redirect("/default.aspx");
                    }

                    CargarEmpleados();
                    CargarGrupos();
                    CargarRelojes();
                }
            }
        }
Ejemplo n.º 54
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            db     d1   = new db();
            string path = d1.accessdb();

            OleDbConnection conn = new OleDbConnection(path);
            conn.Open();
            string          sql  = "select * from config";
            OleDbCommand    comm = new OleDbCommand(sql, conn);
            OleDbDataReader odr  = comm.ExecuteReader();
            while (odr.Read())
            {
                footer1 = odr[1].ToString();
            }
            odr.Close();
            conn.Close();
        }
    }
Ejemplo n.º 55
0
        private void toolBar_btnNew_Click(object sender)
        {
            item item = ItemDB.New();

            item.id_item_type = entity.item.item_type.FixedAssets;


            using (db db = new db())
            { item.id_vat_group = db.app_vat_group.Where(x => x.is_default && x.id_company == CurrentSession.Id_Company).FirstOrDefault().id_vat_group; }

            item_asset item_asset = new item_asset();

            item.item_asset.Add(item_asset);
            ItemDB.items.Add(item);

            itemViewSource.View.Refresh();
            itemViewSource.View.MoveCurrentTo(item);
            itemitem_capitalViewSource.View.Refresh();
            itemitem_capitalViewSource.View.MoveCurrentTo(item_asset);
        }
Ejemplo n.º 56
0
        public static void Show(db s)
        {
            List <homework> howeworkdata = new List <homework>();

            howeworkdata = s.Readhomework();

            int j = 1;

            howeworkdata.ForEach(x =>
            {
                Console.WriteLine("第" + j + "筆資料");
                Console.WriteLine("書店名:\t" + x.name);
                Console.WriteLine("地址:\t" + x.address);
                Console.WriteLine("開店時間:\t" + x.openTime);
                Console.WriteLine("連絡電話:\t" + x.phone);
                Console.WriteLine("\n");
                Console.WriteLine("----------");
                j++;
            });
        }
Ejemplo n.º 57
0
        public static decimal return_ValueWithVAT(int id_vat_group, decimal ValueWithoutVAT)
        {
            decimal VAT_Value = 0;

            if (id_vat_group != 0)
            {
                using (db db = new db())
                {
                    List <app_vat_group_details> app_vat_group_details = new List <entity.app_vat_group_details>();
                    app_vat_group_details = db.app_vat_group_details.Where(x => x.id_vat_group == id_vat_group).ToList();

                    foreach (app_vat_group_details app_vat_group in app_vat_group_details)
                    {
                        VAT_Value = VAT_Value + calculate_Vat(ValueWithoutVAT, app_vat_group.app_vat.coefficient);
                    }
                }
            }

            return(ValueWithoutVAT + VAT_Value);
        }
Ejemplo n.º 58
0
    public void dataview(int id)
    {
        db     d1   = new db();
        string path = d1.accessdb3();

        conn = new OleDbConnection(path);
        conn.Open();
        string          sql = "select * from photo where photo_id=" + id;
        OleDbCommand    ocm = new OleDbCommand(sql, conn);
        OleDbDataReader odr = ocm.ExecuteReader();

        while (odr.Read())
        {
            TextBox1.Text   = string.Format("{0}", odr[0]);
            TextBox2.Text   = string.Format("{0}", odr[5]);
            Image1.ImageUrl = "../../updata/small/" + string.Format("{0}", odr[2]);
        }
        odr.Close();
        conn.Close();
    }
Ejemplo n.º 59
0
        public IActionResult GetPayments(string userid)
        {
            using (var db = new db())
            {
                var payments = (from payment in db.payments
                                where payment.UserId == userid
                                select payment).ToList();

                if (payments != null || payments.Count > 0)
                {
                    PaymentsHelper      helper   = new PaymentsHelper(payments);
                    double              balance  = helper.Balance;
                    PaymentsResponseDto response = new PaymentsResponseDto();
                    response.AccountBalance = balance;
                    response.Payments       = payments;
                    return(Ok(response));
                }
            }
            return(NotFound());
        }
Ejemplo n.º 60
0
 public int get_Location(item_product item_product, app_branch app_branch)
 {
     try
     {
         return(get_ProductLocation(item_product, app_branch));
     }
     catch
     {
         app_location app_location = new app_location();
         app_location.id_branch  = app_branch.id_branch;
         app_location.name       = "Default of " + app_branch.name;
         app_location.is_default = true;
         using (db db = new db())
         {
             db.app_location.Add(app_location);
             db.SaveChangesAsync();
             return(app_location.id_location);
         }
     }
 }