Ejemplo n.º 1
0
Archivo: UI.cs Proyecto: tbdye/css475
 public UI()
 {
     throwAway = false;
     DB = new DBHandler();
     curPlayer = new Player();
     DrawTrain();
     SetUpPlayer();
 }
Ejemplo n.º 2
0
Archivo: App.xaml.cs Proyecto: bdr27/c-
 public App()
     : base ()
 {
     serverMiniCheckers = new MainWindow();
     serverMiniCheckers.UpdateMenuState(serverState);
     dbHandler = new MOCKDBHandler();
     dbHandler.LoadHighScores();
     serverMiniCheckers.LoadLeaderboard(dbHandler.GetHighScores());
     WireHandlers();
     serverMiniCheckers.Show();
     
     LoadMOCK();
 }
Ejemplo n.º 3
0
        private static IEnumerable <Client> LoadAllConditionally(bool onlyActive, bool onlyRestricted = false)
        {
            using (var conn = DBHandler.Connection())
            {
                conn.Open();
                var results = conn.Query <Client, Contact, Client>(@"
                    SELECT c.*, con.* FROM clients c
                    LEFT JOIN contacts con ON c.DefaultPayerContactId = con.Id" +
                                                                   " WHERE c.Restricted = " + (onlyRestricted ? "1" : "0") +
                                                                   (onlyActive ? " AND c.Active = 1;" : ";"),
                                                                   (c, con) => {
                    c.DefaultPayer = con;
                    return(c);
                });

                return(results);
            }
        }
Ejemplo n.º 4
0
 private void btn_check_DBServer_Click(object sender, EventArgs e)
 {
     try
     {
         if (DBHandler.CheckConnetion(DBHandler.GetDBConnectionString(tb_DBServer.Text, Int32.Parse(tb_DBPort.Text), tb_DBDatabase.Text, tb_DBUser.Text, tb_DBPassword.Text)))
         {
             Functions.ShowMessgeInfo("Kết nối thành công");
         }
         else
         {
             Functions.ShowMessgeError("Không thể kết nối DB với cấu hình này");
         }
     }
     catch
     {
         Functions.ShowMessgeError("Có thông số cấu hình nào đó không đúng");
     }
 }
Ejemplo n.º 5
0
        public void UpdateRenteeTest()
        {
            // ARRANGE
            string    connectionString = @"Data Source=(localdb)\MSSQLLocalDB;Initial Catalog=CybellesCykler.S2Eksamen;Integrated Security=True;Connect Timeout=30;Encrypt=False;TrustServerCertificate=True;ApplicationIntent=ReadWrite;MultiSubnetFailover=False";
            DBHandler dB     = new DBHandler(connectionString);
            Rentee    rentee = new Rentee("John Doe", "StreetName 101", "12345678", new DateTime(), 1); // Has to match rentee in DB
            // Name changed from "John Doe" to "Jane Doe"
            Rentee expected = new Rentee("Jane Doe", "StreetName 101", "12345678", new DateTime(), 1);

            // ACT
            bool isUpdated = dB.UpdateRentee(expected);

            //Rentee actual = dB.GetRentee(1);

            // ASSERT
            Assert.IsTrue(isUpdated, "Rentee not updated");
            //Assert.AreEqual(expected, actual, "Rentee not equal");
        }
Ejemplo n.º 6
0
        public ActionResult Register(RegisterDTO oDTO)
        {
            if (!validateRegistration(oDTO))
            {
                return(View(oDTO));
            }

            if (DBHandler.registerUser(oDTO))
            {
                return(RedirectToAction("Login"));
            }
            else
            {
                // If we got this far, something failed, redisplay form
                ModelState.AddModelError("", "The user name is already taken.");
                return(View(oDTO));
            }
        }
Ejemplo n.º 7
0
 public MainWindow()
 {
     InitializeComponent();
     handler                = new DBHandler(@"Data Source = (localdb)\MSSQLLocalDB; Initial Catalog = EksamenM2E2017.OpskrifterDB; Integrated Security = True; Connect Timeout = 30; Encrypt = False; TrustServerCertificate = False; ApplicationIntent = ReadWrite; MultiSubnetFailover = False");
     ingredients            = handler.GetAllIngredients();
     recipes                = handler.GetAllRecipes();
     recipeNames            = new List <string>();
     ingredientsInNewRecipe = new List <Ingredient>();
     foreach (Recipe r in recipes)
     {
         recipeNames.Add(r.Name);
     }
     DtgAllIngredients.ItemsSource     = ingredients;
     DtgAddIngredients.ItemsSource     = ingredients;
     DtgItemsInNewRecipe.ItemsSource   = ingredientsInNewRecipe;
     ListBoxRecipeList.ItemsSource     = recipeNames;
     CmbBoxIngredientTypes.ItemsSource = Enum.GetValues(typeof(IngredientType)).Cast <IngredientType>();
 }
Ejemplo n.º 8
0
        public bool endLogin(long id)
        {
            bool result = false;

            try
            {
                if (DBHandler.updateDataBase(ref conn, "`order_admin_tracking_login`", "`logoutdate` = NOW()", "`id` = " + id + ""))
                {
                    result = true;
                }
            }
            catch (Exception ex)
            {
                LogFile.writeLog(LogFile.DIR, "Exception" + LogFile.getTimeStringNow() + ".txt", LogFile.Filemode.GHIDE, ex.Message);
            }

            return(result);
        }
Ejemplo n.º 9
0
    public static void GuardaImagen(string path)
    {
        SqlConnection con = new SqlConnection(DBHandler.GetConnectionString());   //connection to the your database
        FileStream    FS  = new FileStream(path, FileMode.Open, FileAccess.Read); //create a file stream object associate to user selected file

        byte[] img = new byte[FS.Length];                                         //create a byte array with size of user select file stream length
        FS.Read(img, 0, Convert.ToInt32(FS.Length));                              //read user selected file stream in to byte array

        if (con.State == ConnectionState.Closed)                                  //check whether connection to database is close or not
        {
            con.Open();                                                           //if connection is close then only open the connection
        }
        SqlCommand cmd = new SqlCommand("SaveImage", con);                        //create a SQL command object by passing name of the stored procedure and database connection

        cmd.CommandType = CommandType.StoredProcedure;                            //set command object command type to stored procedure type
        cmd.Parameters.Add("@img", SqlDbType.Image).Value = img;                  //add parameter to the command object and set value to that parameter
        cmd.ExecuteNonQuery();                                                    //execute command
    }
Ejemplo n.º 10
0
        public void UpdateBikeTest()
        {
            // ARRANGE
            string    connectionString = @"Data Source=(localdb)\MSSQLLocalDB;Initial Catalog=CybellesCykler.S2Eksamen;Integrated Security=True;Connect Timeout=30;Encrypt=False;TrustServerCertificate=True;ApplicationIntent=ReadWrite;MultiSubnetFailover=False";
            DBHandler dB   = new DBHandler(connectionString);
            Bike      bike = new Bike(20.5M, "Some description of the bike", BikeKind.Mountain, 1);
            // PricePerDay changed from "20.5M" to "30.5M"
            Bike expected = new Bike(30.5M, "Some description of the bike", BikeKind.Mountain, 1);

            // ACT
            bool isUpdated = dB.UpdateBike(expected);

            //Bike actual = dB.GetBike(1);

            // ASSERT
            Assert.IsTrue(isUpdated, "Bike not updated");
            //Assert.AreEqual(expected, actual, "Bike not equal");
        }
Ejemplo n.º 11
0
        public bool ChangePass(string username, string pass)
        {
            bool result = false;

            try
            {
                if (DBHandler.updateDataBase(ref conn, "`order_admin_user`", "`password` = '" + pass + "'", "`username` = '" + username + "'"))
                {
                    result = true;
                }
            }
            catch (Exception ex)
            {
                LogFile.writeLog(LogFile.DIR, "Exception" + LogFile.getTimeStringNow() + ".txt", LogFile.Filemode.GHIDE, ex.Message);
            }

            return(result);
        }
Ejemplo n.º 12
0
        private async Task LinkSteam(ICommandContext Context, ulong id)
        {
            using (var uow = DBHandler.UnitOfWork())
            {
                if (uow.User.GetSteamID(Context.User.Id) == 0)
                {
                    uow.User.SetSteamID(Context.User.Id, id);
                }
                else
                {
                    await Context.Channel.SendErrorAsync("You have already set your SteamID");

                    return;
                }
            }

            await Context.Channel.SendSuccessAsync($"Set steamd ID for {Context.User.Username} to {id}");
        }
Ejemplo n.º 13
0
        /// <summary>
        /// 复选框点击事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void checkBoxFlag_CheckedChanged(object sender, EventArgs e)
        {
            // 获取窗体中CheckBox的状态(选中状态为1,未选中状态未0)
            string shoriFlg = checkBoxFlag.Checked ? "1" : "0";

            // 根据checkBox的状态去更改csv按钮的状态
            if ("1".Equals(shoriFlg))
            {
                printCSV.Enabled = false;
            }
            else
            {
                printCSV.Enabled = true;
            }

            string    sql       = $@"
                SELECT
                  [id]
                  , [torihikiCd]
                  , [toriNm]
                  , [torirkNm]
                  , [torijyusyo]
                  , [yubin]
                  , [telNo]
                  , [faxNo]
                  , [tantoNm]
                  , [shoriFlg]
                  , [kousinYMD]
                  , [kosinCd] 
                FROM
                  [dbo].[batch_csvDataStart] 
                WHERE
                  [shoriFlg] = '{shoriFlg}' 
                ORDER BY
                  [id]
            ";
            DBHandler dbHandler = new DBHandler();
            DataSet   dataSet   = dbHandler.executeQuery(sql);

            // 清空原有的数据
            dataGridView1.DataSource = null;
            // 把从数据库查询到的数据保存到表格控件中
            dataGridView1.DataSource = dataSet.Tables[0];
        }
Ejemplo n.º 14
0
        public ListModel GetList(int list_id)
        {
            DBHandler       db         = new DBHandler();
            MySqlConnection connection = db.ConnectDB();
            MySqlCommand    cmd;
            ListModel       list = new ListModel();

            try
            {
                cmd             = connection.CreateCommand();
                cmd.CommandText = "SELECT * FROM lists WHERE list_id=@list_id";
                cmd.Parameters.AddWithValue("@list_id", list_id);

                MySqlDataReader reader = cmd.ExecuteReader();

                while (reader.Read())
                {
                    int    id           = (int)reader["list_id"];
                    string list_name    = (string)reader["list_name"];
                    int    list_user_id = (int)reader["list_user_id"];
                    int    list_fronts  = (int)reader["list_fronts"];
                    bool   new_list     = (bool)reader["new_list"];

                    list.List_id      = id;
                    list.List_name    = list_name;
                    list.List_user_id = list_user_id;
                    list.List_fronts  = list_fronts;
                    list.New_List     = new_list;
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.GetBaseException());
            }
            finally
            {
                if (connection.State == System.Data.ConnectionState.Open)
                {
                    db.CloseDB(connection);
                }
            }

            return(list);
        }
Ejemplo n.º 15
0
        public void Poblar()
        {
            Filtro.ClearFilters();
            if (!string.IsNullOrEmpty(input.Text.Trim()))
            {
                Filtro.AddLike("NOMBRE", input.Text.Trim());
            }
            if (estado.CheckState != CheckState.Indeterminate)
            {
                Filtro.AddEquals("estado", Convert.ToInt32(estado.Checked).ToString());
            }

            try
            {
                var newset = DBHandler.Query(Filtro.Build()).Select(row =>
                {
                    var orig = new List <string>()
                    {
                        row["idRol"].ToString(),
                        row["NOMBRE"].ToString(),
                        row["estado"].ToString()
                    };
                    orig.AddRange(extraColumns);
                    return(orig);
                }
                                                                    ).ToList();

                if (newset.Count() == 0)
                {
                    MessageBox.Show("No se encontró ningún rol. Intente cambiar el criterio de búsqueda.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }

                newset.ForEach(row =>
                               grid.Rows.Add(row.ToArray())
                               );
            }
            catch (Exception e)
            {
                this.DialogResult = System.Windows.Forms.DialogResult.Abort;
                MessageBox.Show("Error al buscar roles.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                this.Close();
            }
        }
Ejemplo n.º 16
0
        /// <summary>
        /// Update search Status
        /// </summary>
        /// <param name="searchresults"></param>
        public static int UpdateSearchStatus(int searchId, string strTerm, string strLocation, int searchStatus)
        {
            int       rowsAffected = -1;
            DBHandler dbHandler    = null;

            try
            {
                List <SqlParameter> dbParamCollection = new List <SqlParameter>();
                //searchId
                if (searchId > 0)
                {
                    SqlParameter dbparamSearchId = new SqlParameter("@SearchId", SqlDbType.Int);
                    dbparamSearchId.Value = searchId;
                    dbParamCollection.Add(dbparamSearchId);
                }

                //Term
                SqlParameter dbparamTerm = new SqlParameter("@Term", SqlDbType.VarChar, 50);
                dbparamTerm.Value = strTerm;
                dbParamCollection.Add(dbparamTerm);

                //Location
                SqlParameter dbparamLocation = new SqlParameter("@Location", SqlDbType.VarChar, 50);
                dbparamLocation.Value = strLocation;
                dbParamCollection.Add(dbparamLocation);

                //SearchFinished
                SqlParameter dbparamSearchFinished = new SqlParameter("@SearchFinished", SqlDbType.Int);
                dbparamSearchFinished.Value = searchStatus;
                dbParamCollection.Add(dbparamSearchFinished);

                dbHandler    = new DBHandler(1);
                rowsAffected = dbHandler.ExecuteNonQuery(Constants.SP_HouzzMAINSEARCH_SEARCHFINISHED_UPDATE, dbParamCollection);
                if (rowsAffected < 0)
                {
                    //errror in query execution
                }
            }
            catch (Exception ex)
            {
                YelpTrace.Write("UpdateSearchStatus" + ex);
            }
            return(rowsAffected);
        }
Ejemplo n.º 17
0
        public void SavePayers()
        {
            var toBeDeleted = new List <DataModel.Contact>();

            foreach (var payer in initialPayerList)
            {
                var match = PayerList.FirstOrDefault(p => p.Id == payer.Id);
                if (match == null)
                {
                    toBeDeleted.Add(payer);
                }
            }

            using (var conn = DBHandler.Connection())
            {
                conn.Open();
                using (var t = conn.BeginTransaction())
                {
                    toBeDeleted.ForEach(p => DataModel.Client.RemoveDefaultPayer(p.Id, conn, t));
                    toBeDeleted.ForEach(p => p.Delete(conn, t));
                    foreach (var payer in PayerList)
                    {
                        // Do not save empty names.
                        if (string.IsNullOrWhiteSpace(payer.Name))
                        {
                            if (payer.Id != null)
                            {
                                // Also remove those existing with empty names.
                                DataModel.Client.RemoveDefaultPayer(payer.Id, conn, t);
                                payer.Delete(conn, t);
                            }
                        }
                        else
                        {
                            payer.Payer = true;
                            payer.Save(conn, t);
                        }
                    }
                    t.Commit();
                }
            }

            Refresh();
        }
Ejemplo n.º 18
0
Archivo: App.xaml.cs Proyecto: bdr27/c-
        public App()
            : base ()
        {
            serverMiniCheckers = new MainWindow();
            requestResponseLog = new List<string>();
            dbHandler = new MOCKDBHandler();

            WireHandlers();
            LoadMOCK();
            CheckStartServer();
            GetNetworkInfo();          
            
            dbHandler.LoadHighScores();
            serverMiniCheckers.LoadLeaderboard(dbHandler.GetHighScores());
            serverMiniCheckers.Show();
            
            
            updateRequestResponse("System Startup Complete");
        }
Ejemplo n.º 19
0
        public List <UserInfo> GetCardtoEmpNo(string card_no)
        {
            string          query    = string.Format("SELECT emp_no,emp_nm,company_cd,department_cd,position_cd FROM vw_cards WHERE card_no='{0}'", card_no);
            DataTable       dt       = DBHandler.GetDataTable(query, connectionString);
            List <UserInfo> userInfo = new List <UserInfo>();

            foreach (DataRow row in dt.Rows)
            {
                userInfo.Add(new UserInfo
                {
                    emp_no  = row["emp_no"].ToString(),
                    emp_nm  = row["emp_nm"].ToString(),
                    comp_cd = row["company_cd"].ToString(),
                    dept_cd = row["department_cd"].ToString(),
                    posi_cd = row["position_cd"].ToString()
                });
            }
            return(userInfo);
        }
        public ActionResult ForgotPassword(string forgEmail)
        {
            DBHandler handle = new DBHandler();
            int       retVal = handle.verifyEmail(forgEmail);

            if (retVal > 0)
            {
                int         _min                = 1000;
                int         _max                = 9999;
                Random      _rdm                = new Random();
                int         code                = _rdm.Next(_min, _max);
                string      fromEmail           = "*****@*****.**";
                string      fromPass            = "******";
                string      fromName            = "Admin";
                MailAddress fromAddress         = new MailAddress(fromEmail, fromName);
                MailAddress toAddress           = new MailAddress(forgEmail);
                System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient
                {
                    Host                  = "smtp.gmail.com",
                    Port                  = 587,
                    EnableSsl             = true,
                    DeliveryMethod        = System.Net.Mail.SmtpDeliveryMethod.Network,
                    UseDefaultCredentials = false,
                    Credentials           = new NetworkCredential(fromAddress.Address, fromPass)
                };
                using (var message = new MailMessage(fromAddress, toAddress)
                {
                    Subject = "Reset Password",
                    Body = code.ToString(),
                })
                {
                    smtp.Send(message);
                }
                Session["code"]  = Convert.ToString(code);
                Session["email"] = forgEmail;
                return(View("CheckCode"));
            }
            else
            {
                ViewBag.Message = "Email doesn't exist";
                return(View("ExistingUser"));
            }
        }
Ejemplo n.º 21
0
        private void search_Click(object sender, EventArgs e)
        {
            DBHandler instance = DBHandler.getInstance();

            if (byName.Checked)
            {
                string[] list  = searchText.Text.Split('-');
                string   name  = list[0];
                string   phone = list[1];
                selectedClient = instance.getClient(name, phone);
            }
            else
            {
                selectedClient = instance.getClient(int.Parse(searchText.Text));
            }
            clientsSelectElements();
            clientToFields();
            //fieldsToClient();
        }
Ejemplo n.º 22
0
        protected void btnAdd_Click(object sender, EventArgs e)
        {
            Modules module = new Modules();

            module.moduleName        = txtModuleName.Text;
            module.moduleLevel       = ddLevel.SelectedValue.ToString();
            module.moduleDuration    = Convert.ToInt32(txtDura.Text);
            module.modulePrice       = Convert.ToDouble(txtPrice.Text);
            module.moduleDescription = txtDesc.Text;



            DBHandler handler = new DBHandler();

            if (handler.AddNewModule(module) == true)
            {
                Response.Redirect("ModulesList.aspx");
            }
        }
Ejemplo n.º 23
0
 public void Delete(IDbConnection conn = null, IDbTransaction t = null)
 {
     if (conn == null)
     {
         using (var c = DBHandler.Connection())
         {
             c.Open();
             using (var tr = c.BeginTransaction())
             {
                 DeleteUsing(c, tr);
                 tr.Commit();
             }
         }
     }
     else
     {
         DeleteUsing(conn, t);
     }
 }
        private void listarHabitacionesFactura_Load(object sender, EventArgs e)
        {
            if (Login.Login.LoggedUserSessionHotelID == -1)
            {
                var result = new AbmHotel.Listado().ShowDialog();
                if (result == System.Windows.Forms.DialogResult.Abort)
                {// FALLO LA OBTENCION!
                    MessageBox.Show("Fallo en la obtención de un Hotel", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    this.Close();
                }
                else if (result == System.Windows.Forms.DialogResult.Cancel) // USUARIO CERRO LA VENTANA!
                {
                    MessageBox.Show("Se ha cerrado la ventana sin seleccionar un Hotel", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    this.Close();
                }
            }

            try
            {
                var nombreHotel = new QueryBuilder(QueryBuilder.QueryBuilderType.SELECT).
                                  Fields("nombre").Table("MATOTA.Hotel").AddEquals("idHotel", Login.Login.LoggedUserSessionHotelID.ToString());
                textBoxNombreHotel.Text = DBHandler.Query(nombreHotel.Build()).First()["nombre"].ToString();
            }
            catch (Exception)
            {
                MessageBox.Show("Ocurrió un error al agregar el nombre del hotel.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }

            FormHandler.listarTipoUbicacion(comboBoxUbicacion);
            comboBoxUbicacion.SelectedIndex = -1;
            FormHandler.listarTipoHabitacion(comboBoxHabitacion);
            comboBoxHabitacion.SelectedIndex = -1;
            poblador = new pobladorHabitacionFactura(new List <TextBox>()
            {
                textBoxNroHabitacion, textBoxPiso
            },
                                                     new List <ComboBox>()
            {
                comboBoxUbicacion, comboBoxHabitacion
            }, dataGridView1, new List <string> {
                "Seleccionar"
            });
        }
Ejemplo n.º 25
0
        public bool EsAuditable(string AEspacio, string AEntidad)
        {
            if (_usarWS != 0)
            {
                return(_wsDB.EsAuditable(AEspacio, AEntidad));
            }
            DBHandler FConector = DBGlobal();

            FConector.Conectar("ORA_CONEAUIW");
            try
            {
                return(FConector.ConsultarSQL("SELECT COUNT(*) FROM DBA_TABLES WHERE OWNER = 'SIS_" + AEspacio +
                                              "' AND TABLE_NAME = 'AUD_" + AEntidad + "'").Tables[0].Rows[0].ItemArray[0].ToString() == "1");
            }
            finally
            {
                FConector.Desconectar();
            }
        }
Ejemplo n.º 26
0
        public void EscribirSQL(string ASQL)
        {
            if (_usarWS != 0)
            {
                _wsDB.EscribirSQL(ASQL);
                return;
            }
            DBHandler FConector = DBGlobal();

            FConector.Conectar("ORA_CONEAUIW");
            try
            {
                FConector.EjecutarSQL(ASQL);
            }
            finally
            {
                FConector.Desconectar();
            }
        }
Ejemplo n.º 27
0
 public void Save(bool noLinkUpdates, IDbConnection conn = null, IDbTransaction t = null)
 {
     if (conn == null)
     {
         using (var c = DBHandler.Connection())
         {
             c.Open();
             using (var tr = c.BeginTransaction())
             {
                 SaveUsing(c, tr, noLinkUpdates);
                 tr.Commit();
             }
         }
     }
     else
     {
         SaveUsing(conn, t, noLinkUpdates);
     }
 }
Ejemplo n.º 28
0
        public static string ActivateDeactivateUsers(string id)
        {
            DBHandler dbHandlerObj = new DBHandler();
            DataTable dt           = new DataTable();
            string    query        = "SELECT HasDisabled FROM [dbo].[AspNetUsers] where  id='" + id + "'";

            dt = dbHandlerObj.GetData(query);
            if (dt.Rows[0][0] != null && Convert.ToBoolean(dt.Rows[0][0]))
            {
                query = "update [dbo].[AspNetUsers] set HasDisabled=0 where id='" + id + "'";
                dbHandlerObj.TranscatData(query);
            }
            else
            {
                query = "update [dbo].[AspNetUsers] set HasDisabled=1 where id='" + id + "'";
                dbHandlerObj.TranscatData(query);
            }
            return("success");
        }
        public FoodPick(int nID, Service service)
        {
            InitializeComponent();

            this.service = service;
            narudzbaID   = nID;
            //inicijalizacija resursa
            jela      = new List <jelo>();
            db        = new FamiliaContextClass();
            dbHandler = new DBHandler();
            tr        = new TextRange(opisJela.Document.ContentStart, opisJela.Document.ContentEnd);
            //ucitavanje jela iz baze
            jela = dbHandler.loadJela();
            urls = dbHandler.loadJelaUrls();
            //scroll view jela
            createScroll();
            //scroll view kolicine jela
            createScrollForDishes();
        }
Ejemplo n.º 30
0
        public static int Insert(string connStr, string tableName, string[] fields, object[] values)
        {

            if (string.IsNullOrEmpty(connStr))
                connStr = GetConnectionStr();

            DBHandler db = DBHandlerFactory.GetHandler(connStr);

          
            string sql = "insert into " + tableName + " (";
 
            for (int i = 0; i < fields.Length; i++)
            {
                sql += fields[i];
                if (i != fields.Length - 1)
                    sql += ",";

                if (values[i] == null)
                    values[i] = "";

                db.AddParameter(fields[i], values[i]);
               
            }

            sql += ")values(";

            for (int i = 0; i < values.Length; i++)
            {
                sql += "@"+fields[i]+"";
                if (i != values.Length - 1)
                    sql += ",";
            }
            sql += ")";

            db.CommandText = sql;
            db.CommandType = CommandType.Text;


            int ret = db.ExecuteNonQuery();
            db.Close();

            return ret;
        }
Ejemplo n.º 31
0
        public static string GetValue(string connStr, string sql)
        {
            if (string.IsNullOrEmpty(connStr))
                connStr = GetConnectionStr();
 


            DBHandler db = DBHandlerFactory.GetHandler(connStr);
            db.CommandText = sql;
            db.CommandType = CommandType.Text;
            object str =  db.ExecuteScalar();
            db.Close();
            if (str == null)
                return null;
            else
               return  Convert.ToString(str);
 

        }
Ejemplo n.º 32
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            DBHandler dbHandler = (DBHandler)Application.Get("dbHandler");
            Debug.Assert(dbHandler != null);

            string memberId = Request.Cookies["memberId"].Value;
            memberId = Server.UrlDecode(memberId);

            GridView1.DataSource = dbHandler.inquiryBookCartItems(memberId);
            GridView1.DataBind();

            if (GridView1.Rows.Count == 0)
            {
                btn_order.Visible = false;
            }
        }
    }
Ejemplo n.º 33
0
        /*//
         *  // SUMMARY
         *  // Create the Click event behavior to all the buttons on the panel dynamically
         *  // Return click event on UI (Void type)
         */
        private void dynamicButton_Click(object sender, RoutedEventArgs e)
        {
            var element = (Button)sender;
            //MessageBox.Show(element.Uid);
            DBHandler handlers = new DBHandler();

            DatabaseModel DBInstance = new DatabaseModel();

            DBInstance = handlers.UpdateDBObject();

            if (!DBInstance.EditOn || DBInstance.TempPedido.id == DBInstance.LastPedidoID)
            {
                handlers.addItemtoPedido(Convert.ToInt32(element.Uid), this);
            }
            else
            {
                MessageBox.Show("Hay un pedido en edicion o creacion en este momento, se debe completar esa tarea primeramente para poder iniciar un pedido nuevo.");
            }
        }
Ejemplo n.º 34
0
Archivo: App.xaml.cs Proyecto: bdr27/c-
        public App()
            : base()
        {
            serverMiniCheckers = new MainWindow();
            dbHandler = new MOCKDBHandler();
            running = false;
            udpMessageHandler = new ServerUDPMessageHandler();
            multicastSender = new BroadcastSender();
            gameState = GameState.WAIT_FOR_GAME_START;

            SetupThreads();
            WireHandlers();
            LoadMOCK();
            CheckStartServer();
            GetNetworkInfo();

            dbHandler.LoadHighScores();
            serverMiniCheckers.LoadLeaderboard(dbHandler.GetHighScores());
            serverMiniCheckers.Show();

            updateRequestResponse("System Startup Complete");
        }
Ejemplo n.º 35
0
 public UserController()
 {
     db = new DBHandler();
     cm = new MySqlCommand();
 }
Ejemplo n.º 36
0
 public BackEnd()
 {
     db = new DBHandler();
     raasparql = new RAASPARQLHandler();
     librisSparql = new LibrisSPARQLHandler();
 }
 public ProgrammeController()
 {
     db = new DBHandler();
     cm = new MySqlCommand();
 }
Ejemplo n.º 38
0
 public void SetupListener(int port)
 {
     database = new MOCKDBHandler();
     udpServer = new UdpClient(50000);
     endPoint = new IPEndPoint(IPAddress.Any, port);
 }
Ejemplo n.º 39
0
 public LoginController()
 {
     db = new DBHandler();
     cm = new MySqlCommand();
 }
        public string GeneratorCode()
        {
            DBHandler _db = new DBHandler();

            IEnumerable<Country> countryList = _db.GetCountryList();
            IEnumerable<State> stateList = _db.GetStateList();
            IEnumerable<City> cityList = _db.GetCityList();

            StringBuilder sb = new StringBuilder();



            sb.Append("\nusing System;");
            sb.Append("\nusing System.Collections.Generic;");

            sb.Append("\n\n namespace MU.Location" );
            sb.Append("\n {");
            sb.Append("\n\tpublic partial class LocationHandler");
            sb.Append("\n\t{");
            sb.Append("\n\t\tDictionary<int, Country> _countries;");
            sb.Append("\n\t\tDictionary<int, State> _states;");
            sb.Append("\n\t\tDictionary<int, City> _cities;");


            #region Country Region

            sb.Append("\n\n\t\t#region Country Region");

            sb.Append("\n\n\t\t public List<Country> GetCountryList(){");
            sb.Append("\n\t\t\tList<Country> list = new List<Country>();");
            sb.Append("\n\t\t\tforeach (var item in CountryList){");
            sb.Append("\n\t\t\t\tlist.Add(item.Value);");
            sb.Append("\n\t\t\t}");
            sb.Append("\n\t\t\treturn list;");
            sb.Append("\n\t\t}");


            sb.Append("\n\n\t\tpublic Country GetCountryByID(int id){");
            sb.Append("\n\t\t\tforeach (var item in CountryList){");
            sb.Append("\n\t\t\t\tif (item.Value != null && item.Value.Id == id){");
            sb.Append("\n\t\t\t\t\treturn item.Value;");
            sb.Append("\n\t\t\t\t}");
            sb.Append("\n\t\t\t}");
            sb.Append("\n\t\t\treturn null;");
            sb.Append("\n\t\t}");


            sb.Append("\n\n\t\tpublic Country GetCountryByName(string name){");
            sb.Append("\n\t\t\tforeach (var item in CountryList){");
            sb.Append("\n\t\t\t\tif (item.Value != null && item.Value.Name == name){");
            sb.Append("\n\t\t\t\t\treturn item.Value;");
            sb.Append("\n\t\t\t\t}");
            sb.Append("\n\t\t\t}");
            sb.Append("\n\t\t\treturn null;");
            sb.Append("\n\t\t}");

            sb.Append("\n\n\t\tpublic List<Country> GetCountryByNameMatch(string name){");
            sb.Append("\n\t\t\tList<Country> SelectedValue = new List<Country>();");
            sb.Append("\n\t\t\tforeach (var item in CountryList){");
            sb.Append("\n\t\t\t\tif (item.Value != null && item.Value.Name.Contains(name)){");
            sb.Append("\n\t\t\t\t\t SelectedValue.Add(item.Value);");
            sb.Append("\n\t\t\t\t}");
            sb.Append("\n\t\t\t}");
            sb.Append("\n\t\t\treturn SelectedValue.Count > 0 ? SelectedValue : null;");
            sb.Append("\n\t\t}");

            sb.Append("\n\n\t\tpublic Country GetCountryBySortName(string code){");
            sb.Append("\n\t\t\tforeach (var item in CountryList){");
            sb.Append("\n\t\t\t\tif (item.Value != null && item.Value.SortName == code){");
            sb.Append("\n\t\t\t\t\treturn item.Value;");
            sb.Append("\n\t\t\t\t}");
            sb.Append("\n\t\t\t}");
            sb.Append("\n\t\t\treturn null;");
            sb.Append("\n\t\t}");

            sb.Append("\n\t\t#endregion");

            #endregion

            #region State Region

            sb.Append("\n\n\t\t#region State Region");

            sb.Append("\n\n\t\tpublic State GetStateByID(int id){");
            sb.Append("\n\t\t\tforeach (var item in StateList){");
            sb.Append("\n\t\t\t\tif (item.Value != null && item.Value.Id == id){");
            sb.Append("\n\t\t\t\t\treturn item.Value;");
            sb.Append("\n\t\t\t\t}");
            sb.Append("\n\t\t\t}");
            sb.Append("\n\t\t\treturn null;");
            sb.Append("\n\t\t}");



            sb.Append("\n\n\t\tpublic State GetStateByName(string name){");
            sb.Append("\n\t\t\tforeach (var item in StateList){");
            sb.Append("\n\t\t\t\tif (item.Value != null && item.Value.Name == name){");
            sb.Append("\n\t\t\t\t\treturn item.Value;");
            sb.Append("\n\t\t\t\t}");
            sb.Append("\n\t\t\t}");
            sb.Append("\n\t\t\treturn null;");
            sb.Append("\n\t\t}");

            sb.Append("\n\n\t\tpublic List<State> GetStateByNameMatch(string name){");
            sb.Append("\n\t\t\tList<State> SelectedValue = new List<State>();");
            sb.Append("\n\t\t\tforeach (var item in StateList){");
            sb.Append("\n\t\t\t\tif (item.Value != null && item.Value.Name.Contains(name)){");
            sb.Append("\n\t\t\t\t\t SelectedValue.Add(item.Value);");
            sb.Append("\n\t\t\t\t}");
            sb.Append("\n\t\t\t}");
            sb.Append("\n\t\t\treturn SelectedValue.Count > 0 ? SelectedValue : null;");
            sb.Append("\n\t\t}");


            sb.Append("\n\n\t\tpublic List<State> GetStateListByCountryID(int id){");
            sb.Append("\n\t\t\tList<State> SelectedValue = new List<State>();");
            sb.Append("\n\t\t\tforeach (var item in StateList){");
            sb.Append("\n\t\t\t\tif (item.Value != null && item.Value.CountryID == id){");
            sb.Append("\n\t\t\t\t\t SelectedValue.Add(item.Value);");
            sb.Append("\n\t\t\t\t}");
            sb.Append("\n\t\t\t}");
            sb.Append("\n\t\t\treturn SelectedValue.Count > 0 ? SelectedValue : null;");
            sb.Append("\n\t\t}");

            sb.Append("\n\t\t#endregion");

            #endregion

            #region City Region

            sb.Append("\n\n\t\t#region City Region");

            sb.Append("\n\n\t\tpublic City GetCityByID(int id){");
            sb.Append("\n\t\t\tforeach (var item in CityList){");
            sb.Append("\n\t\t\t\tif (item.Value != null && item.Value.Id == id){");
            sb.Append("\n\t\t\t\t\treturn item.Value;");
            sb.Append("\n\t\t\t\t}");
            sb.Append("\n\t\t\t}");
            sb.Append("\n\t\t\treturn null;");
            sb.Append("\n\t\t}");



            sb.Append("\n\n\t\tpublic City GetCityByName(string name){");
            sb.Append("\n\t\t\tforeach (var item in CityList){");
            sb.Append("\n\t\t\t\tif (item.Value != null && item.Value.Name == name){");
            sb.Append("\n\t\t\t\t\treturn item.Value;");
            sb.Append("\n\t\t\t\t}");
            sb.Append("\n\t\t\t}");
            sb.Append("\n\t\t\treturn null;");
            sb.Append("\n\t\t}");

            sb.Append("\n\n\t\tpublic List<City> GetCityByNameMatch(string name){");
            sb.Append("\n\t\t\tList<City> SelectedValue = new List<City>();");
            sb.Append("\n\t\t\tforeach (var item in CityList){");
            sb.Append("\n\t\t\t\tif (item.Value != null && item.Value.Name.Contains(name)){");
            sb.Append("\n\t\t\t\t\t SelectedValue.Add(item.Value);");
            sb.Append("\n\t\t\t\t}");
            sb.Append("\n\t\t\t}");
            sb.Append("\n\t\t\treturn SelectedValue.Count > 0 ? SelectedValue : null;");
            sb.Append("\n\t\t}");

            sb.Append("\n\n\t\tpublic List<City> GetCityListByStateID(int id){");
            sb.Append("\n\t\t\tList<City> SelectedValue = new List<City>();");
            sb.Append("\n\t\t\tforeach (var item in CityList){");
            sb.Append("\n\t\t\t\tif (item.Value != null && item.Value.StateID == id){");
            sb.Append("\n\t\t\t\t\t SelectedValue.Add(item.Value);");
            sb.Append("\n\t\t\t\t}");
            sb.Append("\n\t\t\t}");
            sb.Append("\n\t\t\treturn SelectedValue.Count > 0 ? SelectedValue : null;");
            sb.Append("\n\t\t}");

            sb.Append("\n\n\t\tpublic List<City> GetCityListByCountryID(int id){");
            sb.Append("\n\t\t\tList<City> SelectedValue = new List<City>();");
            sb.Append("\n\t\t\tforeach (var item in CityList){");
            sb.Append("\n\t\t\t\tif (item.Value != null && item.Value.CountryID == id){");
            sb.Append("\n\t\t\t\t\t SelectedValue.Add(item.Value);");
            sb.Append("\n\t\t\t\t}");
            sb.Append("\n\t\t\t}");
            sb.Append("\n\t\t\treturn SelectedValue.Count > 0 ? SelectedValue : null;");
            sb.Append("\n\t\t}");

            sb.Append("\n\t\t#endregion");

            #endregion

            #region Country List Generator

            sb.Append("\n\n\t\t#region Country List Generator");

            sb.Append("\n\t\tpublic Dictionary<int, Country> CountryList{");
            sb.Append("\n\t\t\tget{");
            sb.Append("\n\t\t\tif (_countries == null){");
            sb.Append("\n\t\t\t\t_countries = new Dictionary<int, Country>();");

            foreach (var country in countryList)
            {
                sb.Append("\n\t\t\t\t_countries.Add(" + country.Id + ", new Country { Id = " + country.Id + ", Name = \"" + country.Name + "\" , SortName = \"" + country.SortName + "\"});");
            }
            
            sb.Append("\n\t\t\t}");
            sb.Append("\n\t\t\treturn _countries;");
            sb.Append("\n\t\t}");
            sb.Append("\n\t}");

            sb.Append("\n\t#endregion");

            #endregion

            #region State List Generator
            sb.Append("\n\n\t\t#region State List Generator");

            sb.Append("\n\n\t\tpublic Dictionary<int, State> StateList{");
            sb.Append("\n\t\t\tget{");
            sb.Append("\n\t\t\tif (_states == null){");
            sb.Append("\n\t\t\t\t_states = new Dictionary<int, State>();");
            
            foreach (var state in stateList)
            {
                sb.Append("\n\t\t\t\t_states.Add(" + state.Id + ", new State { Id = " + state.Id + ", Name = \"" + state.Name + "\", CountryID = " + state.CountryID + " });");
            }
            
            
            sb.Append("\n\t\t\t}");
            sb.Append("\n\t\t\treturn _states;");
            sb.Append("\n\t\t}");
            sb.Append("\n\t}");

            sb.Append("\n\t\t#endregion");
            #endregion

            #region City List Generator
            sb.Append("\n\n\t\t#region City List Generator");

            sb.Append("\n\n\t\tpublic Dictionary<int, City> CityList{");
            sb.Append("\n\t\t\tget{");
            sb.Append("\n\t\t\tif (_cities == null){");
            sb.Append("\n\t\t\t_cities = new Dictionary<int, City>();");

            foreach (var city in cityList)
            {
                sb.Append("\n\t\t\t_cities.Add(" + city.Id + ", new City { Id = " + city.Id + ", Name = \"" + city.Name + "\", CountryID = " + city.CountryID + ", StateID = " + city.StateID + " });");
            }


            sb.Append("\n\t\t\t}");
            sb.Append("\n\t\t\treturn _cities;");
            sb.Append("\n\t\t}");
            sb.Append("\n\t}");

            sb.Append("\n\t\t#endregion");
            #endregion
            

            
            sb.Append("\n\t}");
            sb.Append("\n }");

            return sb.ToString();
        }