GetDecimal() public method

public GetDecimal ( int i ) : Decimal
i int
return Decimal
Beispiel #1
0
        public static PyObject DBColumnToPyObject(int index, ref MySqlDataReader reader)
        {
            Type type = reader.GetFieldType(index);

            switch (type.Name)
            {
                case "String":
                    return new PyString(reader.GetString(index));
                case "UInt32":
                case "Int32":
                case "UInt16":
                case "Int16":
                case "SByte":
                case "Byte":
                    return new PyInt(reader.GetInt32(index));
                case "UInt64":
                case "Int64":
                    return new PyLongLong(reader.GetInt64(index));
                case "Byte[]":
                    return new PyBuffer((byte[])reader.GetValue(index));
                case "Double":
                    return new PyFloat(reader.GetDouble(index));
                case "Decimal":
                    return new PyFloat((double)reader.GetDecimal(index));
                case "Boolean":
                    return new PyBool(reader.GetBoolean(index));
                default:
                    Log.Error("Database", "Unhandled MySQL type " + type.Name);
                    break;
            }

            return null;
        }
Beispiel #2
0
 public static Albaran GetAlbaran(MySqlDataReader rdr)
 {
     if (rdr.IsDBNull(rdr.GetOrdinal("NUMALBAR")))
         return null;
     Albaran a = new Albaran();
     a.CodTipom = rdr.GetString("CODTIPOM");
     a.NumAlbar = rdr.GetInt32("NUMALBAR");
     a.FechaAlb = rdr.GetDateTime("FECHAALB");
     a.TotalAlb = rdr.GetDecimal("TOTALALB");
     return a;
 }
 private void AddDataIntoSalesList(SQLiteDataReader sqLiteDataReader, MySqlDataReader mySqlDataReader, List<SaleForExcelReport> sales)
 {
     var productTax = Convert.ToDecimal(sqLiteDataReader["Tax"].ToString());
     var income = mySqlDataReader.GetDecimal(2);
     var taxPercentage = productTax / 100;
     var currentTax = income * taxPercentage;
     var sale = new SaleForExcelReport(mySqlDataReader.GetString(0),
         income,
         mySqlDataReader.GetDecimal(3),
         currentTax);
     sales.Add(sale);
 }
 private static ProjectMember FillProjectMember(MySqlDataReader dr)
 {
     ProjectMember p = new ProjectMember();
     p = new ProjectMember();
     p.EmpProj = dr.GetInt32("EmpProj");
     p.ProjID = dr.GetInt32("ProjID");
     p.EmpID = dr.GetInt32("EmpID");
     p.Role = dr.GetString("Role");
     p.TotalHours = dr.GetDecimal("TotalHours");
     p.StartDate = dr.GetDateTime("StartDate");
     p.EndDate = dr["EndDate"] as DateTime?;
     return p;
 }
Beispiel #5
0
        public SMSModel(MySqlDataReader dataReader)
        {
            id = dataReader.GetInt32("id");

            if (!string.IsNullOrEmpty(dataReader["msg_id"].ToString()))
                msg_id = dataReader.GetString("msg_id");

            if (!string.IsNullOrEmpty(dataReader["number"].ToString()))
                number = dataReader.GetString("number");
            if (!string.IsNullOrEmpty(dataReader["message"].ToString()))
                message = dataReader.GetString("message");

            if (!string.IsNullOrEmpty(dataReader["sign"].ToString()))
                sign = dataReader.GetString("sign");

            if (!string.IsNullOrEmpty(dataReader["cost"].ToString()))
                cost = dataReader.GetDecimal("cost");

            if (!string.IsNullOrEmpty(dataReader["balance"].ToString()))
                balance = dataReader.GetDecimal("balance");

            if (!string.IsNullOrEmpty(dataReader["added"].ToString()))
                added = dataReader.GetString("added");

            if (!string.IsNullOrEmpty(dataReader["sended"].ToString()))
                sended = dataReader.GetString("sended");

            if (!string.IsNullOrEmpty(dataReader["received"].ToString()))
                received = dataReader.GetString("received");

            if (!string.IsNullOrEmpty(dataReader["error_code"].ToString()))
                error_code = dataReader.GetString("error_code");

            if (!string.IsNullOrEmpty(dataReader["status"].ToString()))
                status = dataReader.GetString("status");
        }
Beispiel #6
0
        public Session createSessionFromDataReader(MySqlDataReader dr)
        {
            Session session;
            String userLogin;
            int code = 0;
            DateTime date;
            String dateString;
            Video video;
            String mode;
            String comment;

            float evaluetion;

            if (dr.Equals(DBNull.Value)) return null;

            if (!dr["comment"].Equals(DBNull.Value))
                comment = dr.GetString("comment");
            else
                comment = "";

            if (dr["code"].Equals(DBNull.Value)) return null;
            code = dr.GetInt32("code");

            if (dr["userLogin"].Equals(DBNull.Value)) return null;
            userLogin = dr.GetString("userLogin");

            if (!dr["evaluetion"].Equals(DBNull.Value))
                evaluetion = (float)Convert.ToDouble(dr.GetDecimal("evaluetion"));
            else
                evaluetion = 0;

            DaoVideo daoVideo = new DaoVideo();
            daoVideo.openConnection();

            video = daoVideo.getVideoByCode(dr.GetInt32("videoCode"));

            date = dr.GetDateTime("date");
            dateString = date.Day + "/" + date.Month + "/" + date.Year;

            if (!dr["modeCode"].Equals(DBNull.Value))
                mode = getModeByCode(dr.GetInt32("modeCode"));
            else
                mode = "";

            session = new Session(userLogin, video, dateString, evaluetion, mode, comment);
            session.setCode(code);
            return session;
        }
        private ShoppingCart BuildObject(MySqlDataReader reader)
        {
            if (!reader.Read()) return null;
            var cart = new ShoppingCart();
            do {
                cart.Items.Add(new ShoppingCart.ShoppingCartItem {
                    Product = new Product {
                        Id = reader.GetInt64("ProductId"),
                        Name = reader.GetString("Name"),
                        Price = reader.GetDecimal("Price"),
                        Description = reader.GetString("Description"),
                    },
                    Quantity = reader.GetInt32("Quantity"),
                });
            } while (reader.Read());

            return cart;
        }
Beispiel #8
0
 public static LinFactura GetLinFactura(MySqlDataReader rdr)
 {
     if (rdr.IsDBNull(rdr.GetOrdinal("NUMLINEA")))
         return null;
     LinFactura lf = new LinFactura();
     lf.CodTipoa = rdr.GetString("CODTIPOA");
     lf.NumAlbar = rdr.GetInt32("NUMALBAR");
     lf.NumLinea = rdr.GetInt32("NUMLINEA");
     lf.CodArtic = rdr.GetString("CODARTIC");
     lf.NomArtic = rdr.GetString("NOMARTIC");
     lf.PrecioAr = rdr.GetDecimal("PRECIOAR");
     lf.Cantidad = rdr.GetDecimal("CANTIDAD");
     lf.DtoLine1 = rdr.GetDecimal("DTOLINE1");
     lf.DtoLine2 = rdr.GetDecimal("DTOLINE2");
     lf.Importel = rdr.GetDecimal("IMPORTEL");
     return lf;
 }
Beispiel #9
0
        private List<User> readToUser(MySqlDataReader _reader)
        {
            List<User> users = new List<User>();
            string usersQuery = String.Format("SELECT user_type, {0}.users.id, Username, name, dateOfBirth, surname, gender, password, length, weight FROM {0}.users LEFT JOIN {0}.client_bmi_info on {0}.users.id = {0}.client_bmi_info.users_id  ", _database);
            OpenConnection();
            _selectCommand = new MySqlCommand(usersQuery, Connection);


            while (_reader.Read())
            {
                User u;
                int type = _reader.GetInt32(0);
                if (type == 2)
                {
                    u = new Administrator()
                    {
                        Username = _reader.IsDBNull(2) ? null : _reader.GetString(2),
                        Surname = _reader.IsDBNull(5) ? null : _reader.GetString(5),
                        Name = _reader.IsDBNull(3) ? null : _reader.GetString(3),
                        DateOfBirth = _reader.IsDBNull(4) ? DateTime.MinValue : (DateTime)_reader.GetMySqlDateTime(4),
                        Id = _reader.IsDBNull(1) ? 0 : _reader.GetInt32(1),
                        Gender = _reader.IsDBNull(6) ? null : _reader.GetString(6)
                    };
                }
                else if (type == 1)
                {
                    u = new Specialist
                    {
                        Username = _reader.IsDBNull(2) ? null : _reader.GetString(2),
                        Surname = _reader.IsDBNull(5) ? null : _reader.GetString(5),
                        Name = _reader.IsDBNull(3) ? null : _reader.GetString(3),
                        DateOfBirth = _reader.IsDBNull(4) ? DateTime.MinValue : (DateTime)_reader.GetMySqlDateTime(4),
                        Id = _reader.IsDBNull(1) ? 0 : _reader.GetInt32(1),
                        Gender = _reader.IsDBNull(6) ? null : _reader.GetString(6)
                    };
                }
                else if (_reader.GetInt32(0) == 0)
                {
                    u = new Client
                    {
                        Username = _reader.IsDBNull(2) ? null : _reader.GetString(2),
                        Surname = _reader.IsDBNull(5) ? null : _reader.GetString(5),
                        Name = _reader.IsDBNull(3) ? null : _reader.GetString(3),
                        DateOfBirth = _reader.IsDBNull(4) ? DateTime.MinValue : (DateTime)_reader.GetMySqlDateTime(4),
                        Id = _reader.IsDBNull(1) ? 0 : _reader.GetInt32(1),
                        Gender = _reader.IsDBNull(6) ? null : _reader.GetString(6),
                        Lenght = _reader.IsDBNull(8) ? -1 : _reader.GetDecimal(8),
                        Weight = _reader.IsDBNull(9) ? -1 : _reader.GetDecimal(9)
                    };
                }
                else
                    continue;
                users.Add(u);
            }
            _reader.Close();
            return users;
        }
        private void rNextButton_Click(object sender, EventArgs e)
        {
            float np, m, o, nd, h, t, s, lwt, pax;
            System.Text.StringBuilder cmgmt = new StringBuilder();
            System.Text.StringBuilder hv = new StringBuilder();

            fsheet.registerClient(client.getID());
            fsheet.registerPatient(patient.getID());
            fsheet.setAmbWellness(ambCB.Checked);
            fsheet.setCareTraining(ctCB.Checked);
            fsheet.setSeniorResidential(senresCB.Checked);
            fsheet.ReqDetails = detIn.Text;

            if (caseMgmtCB.Checked)
            {
                int cnt = caseMgmtBox.CheckedItems.Count;

                for (int i = 0; i < cnt; i++)
                {
                    cmgmt.Append("'" + caseMgmtBox.CheckedItems[i].ToString() + "'");
                    if (i < cnt - 1)
                        cmgmt.Append(",");
                }

                Console.WriteLine(cmgmt);
            }
            if (hvacCB.Checked)
            {
                int num = hvacCoB.CheckedItems.Count;
                Console.WriteLine("Number of items checked for HVAC: {0}",num);

                for (int i = 0; i < num; i++)
                {
                    hv.Append("'"+hvacCoB.CheckedItems[i].ToString()+"'");
                    if (i < num - 1)
                        hv.Append(",");

                }
                Console.WriteLine(hv);
            }

            //initialize cost table parameters
            try
            {  //get MD Parameters first
                np = float.Parse(mdNPIn.Text);
                m = float.Parse(mdmealsIn.Text);
                o = float.Parse(mdoverIn.Text);
                nd = float.Parse(mdndIn.Text);
                h = float.Parse(mdhpIn.Text);
                t = float.Parse(mdTranspoIn.Text);
                s = float.Parse(mdSomethingIn.Text);
                lwt = float.Parse(mdLWTIn.Text);
                pax = float.Parse(mdNoPaxIn.Text);
                cost.setMDParams(np, m, o, nd, h, t, s, lwt, pax);
            }
            catch (Exception err)
            {
                Console.WriteLine("Cost Table Field Error(MD): " + err.Message);
            }

            try
            { //get MD Parameters first
                np = float.Parse(hcNPIn.Text);
                m = float.Parse(hcmealsIn.Text);
                o = float.Parse(hcoverIn.Text);
                nd = float.Parse(hcndIn.Text);
                h = float.Parse(hchpIn.Text);
                t = float.Parse(hcTranspoIn.Text);
                s = float.Parse(hcSomethingIn.Text);
                lwt = float.Parse(hcLWTIn.Text);
                pax = float.Parse(hcNoPaxIn.Text);

                cost.setHCParams(np, m, o, nd, h, t, s, lwt, pax);
            }
            catch (Exception err)
            {
                Console.WriteLine("Cost Table Field Error(HCP): " + err.Message);
            }

            if (true)
            {
                if (OpenConnection())
                {
                    string query = "INSERT INTO FACESHEET(PATID,CLIENTID,CTRAINING,AMBWELLNESS,SENIORRES,REQDETAILS) " +
                    "VALUES (@ptid,@ctid,@cty,@amb,@sen,@rqdet)";
                    cmd = new MySqlCommand(query, conn);
                    cmd.Prepare();
                    cmd.Parameters.AddWithValue("@ptid", fsheet.PatientID);
                    cmd.Parameters.AddWithValue("@ctid", fsheet.ClientID);
                    cmd.Parameters.AddWithValue("@cty", fsheet.CarTra);
                    cmd.Parameters.AddWithValue("@amb", fsheet.AmbWel);
                    cmd.Parameters.AddWithValue("@sen", fsheet.SenRes);
                    cmd.Parameters.AddWithValue("@rqdet", fsheet.ReqDetails);

                    cmd.ExecuteNonQuery();

                    query = "SELECT LAST_INSERT_ID() FROM FACESHEET;";
                    cmd.CommandText = query;
                    read = cmd.ExecuteReader();
                    read.Read();
                    fsheet.FID = UInt16.Parse(read.GetDecimal(0).ToString());

                    read.Close();

                    //insert values to case mgmt map

                    if (caseMgmtBox.CheckedItems.Count > 0)
                    {

                        string caseQuery = "SELECT CASEID FROM CASE_MGMT_REF WHERE DESCRIPTION IN (" + cmgmt + ");";
                        cmd = new MySqlCommand(caseQuery, conn);
                        UInt16[] ctmp = new UInt16[caseMgmtBox.CheckedItems.Count];

                        read = cmd.ExecuteReader();
                        int x = 0;
                        while (read.Read())
                        {

                            Console.WriteLine(read.GetDecimal(0).ToString());
                            ctmp[x] = UInt16.Parse(read.GetDecimal(0).ToString());
                            x++;
                        }
                        fsheet.addCaseMgmtIndex(ctmp);
                        read.Close();

                        query = "INSERT INTO CASE_MGMT_MAP VALUES (@fcID,@cmgmtID);";
                        cmd.CommandText = query;

                        for (int ccnt = 0; ccnt < ctmp.Length; ccnt++)
                        {
                            cmd.Parameters.Clear();
                            cmd.Parameters.AddWithValue("@fcID", fsheet.FID);
                            cmd.Parameters.AddWithValue("@cmgmtID", ctmp[ccnt]);
                            cmd.Prepare();
                            cmd.ExecuteNonQuery();
                        }
                    }

                    if (hvacCoB.CheckedItems.Count > 0)
                    {
                        string HVacquery = "SELECT HVACID FROM HVAC_REF WHERE DESCRIPTION IN (" + hv + ");";
                        cmd = new MySqlCommand(HVacquery,conn);
                        UInt16[] htmp = new UInt16[hvacCoB.CheckedItems.Count];

                        read = cmd.ExecuteReader();
                        int x = 0;
                        while (read.Read())
                        {

                            Console.WriteLine(read.GetDecimal(0).ToString());
                            htmp[x] = UInt16.Parse(read.GetDecimal(0).ToString());
                            x++;
                        }
                        fsheet.addHomeVacIndex(htmp);
                        read.Close();

                        query = "INSERT INTO HVAC_MAP VALUES (@fcID,@hvacID);";
                        cmd.CommandText = query;

                        for (int hcnt = 0; hcnt < htmp.Length; hcnt++)
                        {
                            cmd.Parameters.Clear();
                            cmd.Parameters.AddWithValue("@fcID", fsheet.FID);
                            cmd.Parameters.AddWithValue("@hvacID",htmp[hcnt]);
                            cmd.Prepare();
                            cmd.ExecuteNonQuery();

                        }

                    }

                    CloseConnection();
                    tabControl1.SelectedIndex++;
                }
            }
        }
Beispiel #11
0
 public static LineaStock GetLineaStock(MySqlDataReader rdr)
 {
     LineaStock ls = new LineaStock();
     ls.NumLinea = rdr.GetInt32("CODALMAC");
     ls.Almacen = rdr.GetString("NOMALMAC");
     ls.Stock = rdr.GetDecimal("CANSTOCK");
     return ls;
 }
Beispiel #12
0
 public static Articulo GetArticulo(MySqlDataReader rdr)
 {
     if (rdr.IsDBNull(rdr.GetOrdinal("CODARTIC")))
         return null;
     Articulo a = new Articulo();
     a.CodArtic = rdr.GetString("CODARTIC");
     a.NomArtic = rdr.GetString("NOMARTIC");
     a.Preciove = rdr.GetDecimal("PRECIOVE");
     a.CodFamia = rdr.GetInt32("CODFAMIA");
     a.CodMarca = rdr.GetInt32("CODMARCA");
     return a;
 }
        private static Option<Team> MapOption(MySqlDataReader dr)
        {
            var option = new Option<Team>
                {
                    CutOff = dr.GetDateTime("cutOffTime"),
                    GameId = dr.GetInt64("gameId"),
                    GroupId = dr.GetInt64("groupId"),
                    Id = dr.GetInt64("id"),
                    Team = new Team
                        {
                            Id = dr.GetInt32("teamId")
                        },
                    Type = (GameOptionType) dr.GetInt32("type")
                };

            if (dr["value"] != DBNull.Value)
            {
                option.Value = dr.GetDecimal("value");
            }

            if (dr["outcome"] != DBNull.Value)
            {
                option.Outcome = (OptionOutcome) dr.GetInt32("outcome");
                option.IsWinner = option.Outcome.Value == OptionOutcome.Won;
            }

            option.CutOff = option.CutOff.AddDays(ConfigSettings.GameTimeOffSetInDays);
            option.IsPastCutOff = DateTime.UtcNow >= option.CutOff;

            return option;
        }
Beispiel #14
0
        //
        //-------------------------------------------------------------------------------------------------
        //
        public bool ds2purchase(int cart_items, int[] prod_id_in, int[] qty_in, int customerid_out,
      ref int neworderid_out, ref bool IsRollback, ref double rt)
        {
            int i, j;
              bool success = false;
            #if (USE_WIN32_TIMER)
              long ctr0 = 0, ctr = 0, freq = 0;
            #else
              TimeSpan TS = new TimeSpan();
              DateTime DT0;
            #endif

              // Find total cost of purchase
              Decimal netamount_in = 0;
              string db_query = "select PROD_ID, PRICE from PRODUCTS where PROD_ID in (" + prod_id_in[0];
              for (i=1; i<cart_items; i++) db_query = db_query + "," + prod_id_in[i];
              db_query = db_query + ")";
              //Console.WriteLine(db_query);
              Purchase = new MySqlCommand(db_query, objConn);
              Rdr = Purchase.ExecuteReader();
              while (Rdr.Read())
            {
            j = 0;
            int prod_id = Rdr.GetInt32(0);
            while (prod_id_in[j] != prod_id) ++j; // Find which product was returned
            netamount_in = netamount_in + qty_in[j] * Rdr.GetDecimal(1);
            //Console.WriteLine(j + " " + prod_id + " " + Rdr.GetDecimal(1));
            }
              Rdr.Close();
              Decimal taxamount_in =  (Decimal) 0.0825 * netamount_in;
              Decimal totalamount_in = netamount_in + taxamount_in;

              // Insert new order into ORDERS table
              string currentdate = DateTime.Today.ToString("yyyy'-'MM'-'dd");
              MySqlTransaction trans = objConn.BeginTransaction(IsolationLevel.RepeatableRead);
              db_query = String.Format("INSERT into DS2.ORDERS (ORDERDATE, CUSTOMERID, NETAMOUNT, TAX, TOTALAMOUNT) VALUES" +
            "('{0}', {1}, {2:F2}, {3:F2}, {4:F2})", currentdate, customerid_out, netamount_in, taxamount_in, totalamount_in);

              Purchase = new MySqlCommand(db_query, objConn, trans);

            //    Console.WriteLine("Thread {0}: Calling Purchase w/ customerid = {1}  number_items= {2}",
            //      Thread.CurrentThread.Name, customerid_out, cart_items);

            #if (USE_WIN32_TIMER)
              QueryPerformanceFrequency(ref freq); // obtain system freq (ticks/sec)
              QueryPerformanceCounter(ref ctr0); // Start response time clock
            #else
              DT0 = DateTime.Now;
            #endif

              bool deadlocked = false;
              do
            {
            try
              {
              deadlocked = false;
              Purchase.ExecuteNonQuery();
              db_query = "select LAST_INSERT_ID();";
              Purchase = new MySqlCommand(db_query, objConn);
              neworderid_out = Convert.ToInt32(Purchase.ExecuteScalar().ToString());
            //        Console.WriteLine("Thread {0}: Purchase: neworderid_out= {1}", Thread.CurrentThread.Name, neworderid_out);
              if (neworderid_out > 0) success = true;

              // loop through purchased items and make inserts into orderdetails table
              // (o_insert_query) and cust_hist table (ch_insert_query)

              string o_insert_query = "INSERT into DS2.ORDERLINES (ORDERLINEID, ORDERID, PROD_ID, QUANTITY, ORDERDATE)" +
            " VALUES ";
              string c_insert_query = "INSERT into DS2.CUST_HIST (CUSTOMERID, ORDERID, PROD_ID) VALUES ";

              for (i=0; i<cart_items; i++)
            {
            j = i+1;
            db_query = "SELECT QUAN_IN_STOCK, SALES FROM DS2.INVENTORY WHERE PROD_ID=" + prod_id_in[i] + ";";
            Purchase = new MySqlCommand(db_query, objConn);
            Rdr = Purchase.ExecuteReader();
            Rdr.Read();
            int curr_quan = Rdr.GetInt32(0);
            int curr_sales = Rdr.GetInt32(1);
            Rdr.Close();
            int new_quan = curr_quan - qty_in[i];
            int new_sales = curr_sales + qty_in [i];
            if (new_quan < 0)
              {
              //Console.WriteLine("Insufficient quantity for product " + prod_id_in[i]);
              success = false;
              }
            else
              {
              db_query = "UPDATE DS2.INVENTORY SET QUAN_IN_STOCK=" + new_quan + ", SALES=" +
                new_sales + " WHERE PROD_ID=" + prod_id_in[i] + ";";
              Purchase = new MySqlCommand(db_query, objConn, trans);
              Purchase.ExecuteNonQuery();
              }

            o_insert_query = o_insert_query +
              "(" + j + "," +  neworderid_out + "," + prod_id_in[i] + "," + qty_in[i] + ",'" + currentdate + "'),";
            c_insert_query = c_insert_query +
              "(" + customerid_out + "," +  neworderid_out + "," + prod_id_in[i] + "),";
            } // End of for (i=0; i<cart_items; i++)

              o_insert_query = o_insert_query.Remove(o_insert_query.Length-1,1) + ";";
            //        Console.WriteLine(o_insert_query);

              c_insert_query = c_insert_query.Remove(c_insert_query.Length-1,1) + ";";
            //        Console.WriteLine(c_insert_query);

              Purchase = new MySqlCommand(o_insert_query, objConn, trans);
              if (Purchase.ExecuteNonQuery()<0)
            {
            Console.WriteLine("Thread {0}: Insert into ORDERLINES table failed; query= {1}",
              Thread.CurrentThread.Name, o_insert_query);
            success = false;
            }

              Purchase = new MySqlCommand(c_insert_query, objConn, trans);
              if (Purchase.ExecuteNonQuery()<0)
            {
            Console.WriteLine("Thread {0}: Insert into CUST_HIST table failed; query= {1}",
              Thread.CurrentThread.Name, c_insert_query);
            success = false;
            }

              if (success)trans.Commit();
              else trans.Rollback();
              }  // End Try

            catch (MySqlException e)
              {
              if ((e.Number == 1205) || (e.Number == 1213))
            {
            deadlocked = true;
            Random r = new Random(DateTime.Now.Millisecond);
            int wait = r.Next(1000);
            Console.WriteLine("Thread {0}: Purchase deadlocked (error {1}: {2})...waiting {3} msec, then will retry",
              Thread.CurrentThread.Name, e.Number, e.Message, wait);
            Thread.Sleep(wait); // Wait up to 1 sec, then try again
            }
              else if (e.Number == 1062)
            {
            deadlocked = true; // Not really but it will cause a retry
            Console.WriteLine("Thread {0}: Duplicate entry found in Purchase (error {1}: {2})... will retry",
              Thread.CurrentThread.Name, e.Number, e.Message);
            }
              else
            {
            Console.WriteLine("Thread {0}: MySql Error {1} in Purchase: {2}",
              Thread.CurrentThread.Name, e.Number, e.Message);
            return(false);
            }
              } // End Catch
            } while (deadlocked);

            #if (USE_WIN32_TIMER)
              QueryPerformanceCounter(ref ctr); // Stop response time clock
              rt = (ctr - ctr0)/(double) freq; // Calculate response time
            #else
              TS = DateTime.Now - DT0;
              rt = TS.TotalSeconds; // Calculate response time
            #endif

              if (!success)
            {
            IsRollback = true;
            //      Console.WriteLine("Thread {0}: Purchase: Insufficient stock for order {1} - order not processed",
            //        Thread.CurrentThread.Name, neworderid_out);
            neworderid_out = 0;
            }

              return(true);
        }
Beispiel #15
0
 public static Cobro GetCobro(MySqlDataReader rdr)
 {
     Cobro c = new Cobro();
     c.FechaVenci = rdr.GetDateTime("FECHAVENCI");
     c.FechaFact = rdr.GetDateTime("FECHAFACT");
     c.NumFact = rdr.GetString("NUMFACT");
     c.NomForpa = rdr.GetString("NOMFORPA");
     c.Total = rdr.GetDecimal("TOTAL");
     return c;
 }
Beispiel #16
0
 public static LinPedido GetLinPedido(MySqlDataReader rdr)
 {
     if (rdr.IsDBNull(rdr.GetOrdinal("NUMLINEA")))
         return null;
     LinPedido lp = new LinPedido();
     lp.NumLinea = rdr.GetInt32("NUMLINEA");
     lp.CodArtic = rdr.GetString("CODARTIC");
     lp.NomArtic = rdr.GetString("NOMARTIC");
     lp.PrecioAr = rdr.GetDecimal("PRECIOAR");
     lp.Cantidad = rdr.GetDecimal("CANTIDAD");
     lp.DtoLine1 = rdr.GetDecimal("DTOLINE1");
     lp.DtoLine2 = rdr.GetDecimal("DTOLINE2");
     lp.Importel = rdr.GetDecimal("IMPORTEL");
     return lp;
 }
Beispiel #17
0
 public static Cliente GetCliente(MySqlDataReader rdr)
 {
     if (rdr.IsDBNull(rdr.GetOrdinal("CODCLIEN")))
         return null;
     Cliente c = new Cliente();
     c.CodClien = rdr.GetInt32("CODCLIEN");
     c.NomClien = rdr.GetString("NOMCLIEN");
     c.NomComer = rdr.GetString("NOMCOMER");
     c.DomClien = rdr.GetString("DOMCLIEN");
     c.CodPobla = rdr.GetString("CODPOBLA");
     c.PobClien = rdr.GetString("POBCLIEN");
     c.ProClien = rdr.GetString("PROCLIEN");
     c.NifClien = rdr.GetString("NIFCLIEN");
     if (!rdr.IsDBNull(rdr.GetOrdinal("PERCLIE1")))
         c.PerClie1 = rdr.GetString("PERCLIE1");
     if (!rdr.IsDBNull(rdr.GetOrdinal("TELCLIE1")))
         c.TelClie1 = rdr.GetString("TELCLIE1");
     if (!rdr.IsDBNull(rdr.GetOrdinal("FAXCLIE1")))
         c.FaxClie1 = rdr.GetString("FAXCLIE1");
     if (!rdr.IsDBNull(rdr.GetOrdinal("PERCLIE2")))
         c.PerClie2 = rdr.GetString("PERCLIE2");
     if (!rdr.IsDBNull(rdr.GetOrdinal("TELCLIE2")))
         c.TelClie2 = rdr.GetString("TELCLIE2");
     if (!rdr.IsDBNull(rdr.GetOrdinal("FAXCLIE2")))
         c.FaxClie2 = rdr.GetString("FAXCLIE2");
     if (!rdr.IsDBNull(rdr.GetOrdinal("MAICLIE1")))
         c.Maiclie1 = rdr.GetString("MAICLIE1");
     if (!rdr.IsDBNull(rdr.GetOrdinal("MAICLIE2")))
         c.Maiclie2 = rdr.GetString("MAICLIE2");
     if (!rdr.IsDBNull(rdr.GetOrdinal("CODMACTA")))
         c.Codmacta = rdr.GetString("CODMACTA");
     c.CodActiv = rdr.GetInt32("CODACTIV");
     c.CodTarif = rdr.GetInt32("CODTARIF");
     c.Promocio = rdr.GetInt32("PROMOCIO");
     if (!rdr.IsDBNull(rdr.GetOrdinal("SITUACION")))
         c.Situacion = rdr.GetString("SITUACION");
     if (!rdr.IsDBNull(rdr.GetOrdinal("LIMITE_CREDITO")))
         c.LimiteCredito = rdr.GetDecimal("LIMITE_CREDITO");
     int tcred = rdr.GetInt32("CREDITO_PRIVADO");
     if (tcred == 1)
         c.TipoCredito = "PRIVADO";
     return c;
 }
Beispiel #18
0
 public static Articulo GetArticuloExt(MySqlDataReader rdr)
 {
     if (rdr.IsDBNull(rdr.GetOrdinal("CODARTIC")))
         return null;
     Articulo a = new Articulo();
     a.CodArtic = rdr.GetString("CODARTIC");
     a.NomArtic = rdr.GetString("NOMARTIC");
     a.Preciove = rdr.GetDecimal("PRECIOVE");
     a.Familia = GetFamilia(rdr);
     a.Proveedor = GetProveedor(rdr);
     a.Stock = rdr.GetDecimal("STOCK");
     if (rdr.GetInt32("ROTACION") == 1)
         a.Rotacion = true;
     a.Reservas = rdr.GetDecimal("RESERVAS");
     a.Referprov = rdr.GetString("REFERPROV");
     a.Pedido = rdr.GetDecimal("PEDIDO");
     return a;
 }
Beispiel #19
0
 public static PrecioEspecial GetPrecioEspecial(MySqlDataReader rdr)
 {
     if (rdr.IsDBNull(rdr.GetOrdinal("CODARTIC")))
         return null;
     PrecioEspecial pe = new PrecioEspecial();
     pe.Codartic = rdr.GetInt32("CODARTIC");
     pe.Nomartic = rdr.GetString("NOMARTIC");
     pe.Precioac = rdr.GetDecimal("PRECIOAC");
     pe.Dtoespe = rdr.GetDecimal("DTOESPE");
     return pe;
 }
Beispiel #20
0
 public static Pedido GetPedidoAgente(MySqlDataReader rdr)
 {
     if (rdr.IsDBNull(rdr.GetOrdinal("NUMPEDCL")))
         return null;
     Pedido p = new Pedido();
     p.NumPedcl = rdr.GetInt32("NUMPEDCL");
     p.FecPedcl = rdr.GetDateTime("FECPEDCL");
     p.FecEntre = rdr.GetDateTime("FECENTRE");
     p.TotalPed = rdr.GetDecimal("TOTALPED");
     if (!rdr.IsDBNull(rdr.GetOrdinal("CLIENTE")))
         p.Cliente = rdr.GetString("CLIENTE");
     if (!rdr.IsDBNull(rdr.GetOrdinal("AGENTE")))
         p.Agente = rdr.GetString("AGENTE");
     return p;
 }
Beispiel #21
0
 private Employee constructEmployee(MySqlDataReader staffReader)
 {
     Employee newEmployee = new Employee();
     newEmployee.NINo = staffReader.GetString("National_Insurance_Number");
     newEmployee.FirstName = staffReader.GetString("First_Name");
     newEmployee.LastName = staffReader.GetString("Last_Name");
     newEmployee.Position = staffReader.GetString("Position");
     newEmployee.Gender = staffReader.GetChar("Gender");
     newEmployee.DateStarted = staffReader.GetDateTime("Date_Started");
     newEmployee.DateFinished = SafeGetDateTime(staffReader, "Date_Finished");
     newEmployee.PVGDate = staffReader.GetDateTime("PVG_Date");
     newEmployee.HolidaysEntitled = staffReader.GetInt16("Holidays_Entitled");
     newEmployee.HolidaysTaken = staffReader.GetInt16("Holidays_Taken");
     newEmployee.WeeksHours = staffReader.GetInt16("Hours");
     newEmployee.Address = constructAddress(staffReader);
     newEmployee.DOB = staffReader.GetDateTime("DOB");
     newEmployee.Salary = staffReader.GetDecimal("Salary");
     newEmployee.HomePhone = staffReader.GetString("Home_Phone");
     newEmployee.MobilePhone = staffReader.GetString("Mobile_Phone");
     newEmployee.Email = staffReader.GetString("Email");
     newEmployee.Training = SafeGetString(staffReader, "Training");
     newEmployee.Medical = constructMedical(staffReader);
     //EC...
     return newEmployee;
 }
 private static Event _EventRead(Engine engine, MySqlDataReader dataReader)
 {
     Event aEvent = new Event(engine);
     uint flags = dataReader.IsDBNull(dataReader.GetOrdinal("flagsEvent")) ? 0 : dataReader.GetUInt32("flagsEvent");
     aEvent._idRundownEvent = dataReader.GetUInt64("idRundownEvent");
     aEvent._layer = (VideoLayer)dataReader.GetSByte("Layer");
     aEvent._eventType = (TEventType)dataReader.GetByte("typEvent");
     aEvent._startType = (TStartType)dataReader.GetByte("typStart");
     aEvent._scheduledTime = _readDateTimeField(dataReader, "ScheduledTime");
     aEvent._duration = dataReader.IsDBNull(dataReader.GetOrdinal("Duration")) ? default(TimeSpan) : aEvent.Engine.AlignTimeSpan(dataReader.GetTimeSpan("Duration"));
     aEvent._scheduledDelay = dataReader.IsDBNull(dataReader.GetOrdinal("ScheduledDelay")) ? default(TimeSpan) : aEvent.Engine.AlignTimeSpan(dataReader.GetTimeSpan("ScheduledDelay"));
     aEvent._scheduledTC = dataReader.IsDBNull(dataReader.GetOrdinal("ScheduledTC")) ? TimeSpan.Zero : dataReader.GetTimeSpan("ScheduledTC");
     aEvent._mediaGuid = (dataReader.IsDBNull(dataReader.GetOrdinal("MediaGuid"))) ? Guid.Empty : dataReader.GetGuid("MediaGuid");
     aEvent._eventName = dataReader.IsDBNull(dataReader.GetOrdinal("EventName")) ? default(string) : dataReader.GetString("EventName");
     var psb = dataReader.GetByte("PlayState");
     aEvent._playState = (TPlayState)psb;
     if (aEvent._playState == TPlayState.Playing || aEvent._playState == TPlayState.Paused)
         aEvent._playState = TPlayState.Aborted;
     if (aEvent._playState == TPlayState.Fading)
         aEvent._playState = TPlayState.Played;
     aEvent._startTime = _readDateTimeField(dataReader, "StartTime");
     aEvent._startTC = dataReader.IsDBNull(dataReader.GetOrdinal("StartTC")) ? TimeSpan.Zero : dataReader.GetTimeSpan("StartTC");
     aEvent._requestedStartTime = dataReader.IsDBNull(dataReader.GetOrdinal("RequestedStartTime")) ? null : (TimeSpan?)dataReader.GetTimeSpan("RequestedStartTime");
     aEvent._transitionTime = dataReader.IsDBNull(dataReader.GetOrdinal("TransitionTime")) ? default(TimeSpan) : dataReader.GetTimeSpan("TransitionTime");
     aEvent._transitionType = (TTransitionType)dataReader.GetByte("typTransition");
     aEvent._audioVolume = dataReader.IsDBNull(dataReader.GetOrdinal("AudioVolume")) ? 0 : dataReader.GetDecimal("AudioVolume");
     aEvent._idProgramme = dataReader.IsDBNull(dataReader.GetOrdinal("idProgramme")) ? 0 : dataReader.GetUInt64("idProgramme");
     aEvent._idAux = dataReader.IsDBNull(dataReader.GetOrdinal("IdAux")) ? default(string) : dataReader.GetString("IdAux");
     aEvent._enabled = (flags & (1 << 0)) != 0;
     aEvent._hold = (flags & (1 << 1)) != 0;
     EventGPI.FromUInt64(ref aEvent._gPI, (flags >> 4) & EventGPI.Mask);
     aEvent._nextLoaded = false;
     return aEvent;
 }
Beispiel #23
0
 public List<DataRow> GetObjectByIDs(List<decimal> rowIDs)
 {
     dr.Close();
     List<DataRow> wantedRoews = new List<DataRow>();
     foreach(int ID in rowIDs)
     {
         string SqlCommand = string.Empty;
         SqlCommand = "SELECT * FROM `HEAD` WHERE `ID` = " + ID + " ";
         MySqlCommand MySqlTriggerCommand = new MySqlCommand(SqlCommand, mySqlConnection);
         dr = MySqlTriggerCommand.ExecuteReader();
         if (dr.HasRows)
         {
             while (dr.Read())
             {
                 DataRow drr = Table.NewRow();
                 for (int i = 0; i < 5; i++)
                 {
                     if (!dr.IsDBNull(i))
                     {
                         if (Table.Columns[i].DataType == typeof(string))
                         {
                             drr[i] = dr.GetString(i);
                         }
                         if (Table.Columns[i].DataType == typeof(decimal))
                         {
                             drr[i] = dr.GetDecimal(i);
                         }
                     }
                 }
                 wantedRoews.Add(drr);
             }
         }
     }
     return wantedRoews;
 }
Beispiel #24
0
 public static Oferta GetOferta(MySqlDataReader rdr)
 {
     if (rdr.IsDBNull(rdr.GetOrdinal("NUMOFERT")))
         return null;
     Oferta o = new Oferta();
     o.NumOfert = rdr.GetInt32("NUMOFERT");
     o.FecOfert = rdr.GetDateTime("FECOFERT");
     o.FecEntre = rdr.GetDateTime("FECENTRE");
     o.TotalOfe = rdr.GetDecimal("TOTALOFE");
     o.Aceptado = rdr.GetBoolean("ACEPTADO");
     return o;
 }
Beispiel #25
0
        //
        //-------------------------------------------------------------------------------------------------
        //
        public bool ds2browse(string browse_type_in, string browse_category_in, string browse_actor_in,
      string browse_title_in, int batch_size_in, int customerid_out, ref int rows_returned, 
      ref int[] prod_id_out, ref string[] title_out, ref string[] actor_out, ref decimal[] price_out, 
      ref int[] special_out, ref int[] common_prod_id_out, ref double rt)
        {
            // Products table: PROD_ID INT, CATEGORY TINYINT, TITLE VARCHAR(50), ACTOR VARCHAR(50),
              //   PRICE DECIMAL(12,2), SPECIAL TINYINT, COMMON_PROD_ID INT
              int i_row;
              int[] category_out = new int[GlobalConstants.MAX_ROWS];

            #if (USE_WIN32_TIMER)
              long ctr0 = 0, ctr = 0, freq = 0;
            #else
              TimeSpan TS = new TimeSpan();
              DateTime DT0;
            #endif

              switch(browse_type_in)
            {
            case "title":
              db_query = "select * from PRODUCTS where MATCH (TITLE) AGAINST ('" + browse_title_in + "') LIMIT " +
            batch_size_in + ";";
              break;
            case "actor":
              db_query = "select * from PRODUCTS where MATCH (ACTOR) AGAINST ('" + browse_actor_in + "') LIMIT " +
            batch_size_in + ";";
              break;
            case "category":
              db_query="select * from PRODUCTS where CATEGORY = " + Convert.ToInt32(browse_category_in) +
            " and SPECIAL=1 LIMIT " + batch_size_in + ";";
              break;
            }

            Browse = new MySqlCommand(db_query, objConn);

            #if (USE_WIN32_TIMER)
              QueryPerformanceFrequency(ref freq); // obtain system freq (ticks/sec)
              QueryPerformanceCounter(ref ctr0); // Start response time clock
            #else
              DT0 = DateTime.Now;
            #endif

              try
            {
            Rdr = Browse.ExecuteReader();

            i_row = 0;
            if (!Rdr.HasRows) // No rows returned
              {
              //Console.WriteLine("No DVDs Found");
              }
            else  // Rows returned
              {
              while (Rdr.Read())
            {
            prod_id_out[i_row] = Rdr.GetInt32(0);
            category_out[i_row] = Rdr.GetByte(1);
            title_out[i_row] = Rdr.GetString(2);
            actor_out[i_row] = Rdr.GetString(3);
            price_out[i_row] = Rdr.GetDecimal(4);
            special_out[i_row] = Rdr.GetByte(5);
            common_prod_id_out[i_row] = Rdr.GetInt32(6);
            ++i_row;
            }
              }
            Rdr.Close();
            rows_returned = i_row;
            }
              catch (MySqlException e)
            {
            Console.WriteLine("Thread {0}: Error in Browse: {1}", Thread.CurrentThread.Name, e.Message);
            return(false);
            }

            //    Console.WriteLine("Thread {0}: Calling Browse w/ browse_type= {1} batch_size_in= {2}  category= {3}" +
            //      " title= {4}  actor= {5}", Thread.CurrentThread.Name, browse_type_in, batch_size_in, browse_category_in,
            //      browse_title_in, browse_actor_in);

            #if (USE_WIN32_TIMER)
              QueryPerformanceCounter(ref ctr); // Stop response time clock
              rt = (ctr - ctr0)/(double) freq; // Calculate response time
            #else
              TS = DateTime.Now - DT0;
              rt = TS.TotalSeconds; // Calculate response time
            #endif

              return(true);
        }
        private void doneButton_Click(object sender, EventArgs e)
        {
            desig = edesigCoB.Text;
            fname = efnameIn.Text;
            sname = esnameIn.Text;
            mname = emnameIn.Text;

            birthdate = ebdayPick.Value;

            try
            {
                gender      = egenCoB.Text;
                nationality = enatIn.Text;
                religion    = erelIn.Text;
                civstat = ecivstatCoB.SelectedItem.ToString();
                Console.WriteLine(civstat);
                educattain  = eedattCoB.Text;
            }
            catch (Exception err)
            {
                Console.WriteLine(err.Message);
            }
            addline = eaddIn.Text;
            city    = ecityIn.Text;
            region  = eregIn.Text;

            try
            {
                stnumber = UInt16.Parse(estnoIn.Text);
            }
            catch (FormatException err)
            {
                Console.WriteLine("Street #: " + err.Message);
            }
            catch (OverflowException of)
            {
                Console.WriteLine("Street #: " + of.Message);
            }

            try
            {
                workNum     = UInt16.Parse(eWorkIn.Text);
                homeNum     = UInt16.Parse(eHomeIn.Text);
                mobNum      = UInt16.Parse(eMobileIn.Text);
                otherNum    = UInt16.Parse(eOtherIn.Text);
            }
            catch (Exception err)
            {
            }

            //get email
            //needs regex based error checking
            email = eemailIn.Text;

            emp.setName(desig, fname, mname, sname);
            emp.setBday(birthdate);
            emp.setGender(gender);
            emp.setNationality(nationality);
            emp.setReligion(religion);
            emp.setCivilStatus(civstat);
            emp.setEducAttainment(educattain);
            emp.setEmail(email);
            emp.setAddress(stnumber, addline, city, region);
            emp.setNumbers(homeNum, workNum, mobNum, otherNum);

            if (true)
            {
                RegisterPerson(emp);

                OpenConnection();

                string query = "SELECT LAST_INSERT_ID() FROM PERSON;";
                cmd = new MySqlCommand(query, conn);

                read = cmd.ExecuteReader();

                read.Read();

                UInt16 lastID = UInt16.Parse(read.GetDecimal(0).ToString());

                emp.setID(lastID);

                read.Close();

                query = "INSERT INTO EMPLOYEE (EMPID) VALUES(@eid);";

                cmd.CommandText = query;

                cmd.Prepare();

                cmd.Parameters.AddWithValue("@eid", lastID);

                cmd.ExecuteNonQuery();

                CloseConnection();

            }
        }
 private static void _mediaReadFields(MySqlDataReader dataReader, PersistentMedia media)
 {
     uint flags = dataReader.IsDBNull(dataReader.GetOrdinal("flags")) ? (uint)0 : dataReader.GetUInt32("flags");
     byte typVideo = dataReader.IsDBNull(dataReader.GetOrdinal("typVideo")) ? (byte)0 : dataReader.GetByte("typVideo");
     media._mediaName = dataReader.IsDBNull(dataReader.GetOrdinal("MediaName")) ? string.Empty : dataReader.GetString("MediaName");
     media._duration = dataReader.IsDBNull(dataReader.GetOrdinal("Duration")) ? default(TimeSpan) : dataReader.GetTimeSpan("Duration");
     media._durationPlay = dataReader.IsDBNull(dataReader.GetOrdinal("DurationPlay")) ? default(TimeSpan) : dataReader.GetTimeSpan("DurationPlay");
     media._folder = dataReader.IsDBNull(dataReader.GetOrdinal("Folder")) ? string.Empty : dataReader.GetString("Folder");
     media._fileName = dataReader.IsDBNull(dataReader.GetOrdinal("FileName")) ? string.Empty : dataReader.GetString("FileName");
     media._fileSize = dataReader.IsDBNull(dataReader.GetOrdinal("FileSize")) ? 0 : dataReader.GetUInt64("FileSize");
     media.idFormat = dataReader.IsDBNull(dataReader.GetOrdinal("idFormat")) ? 0 : dataReader.GetUInt64("idFormat");
     media._lastUpdated = _readDateTimeField(dataReader, "LastUpdated");
     media._mediaStatus = (TMediaStatus)(dataReader.IsDBNull(dataReader.GetOrdinal("statusMedia")) ? 0 : dataReader.GetInt32("statusMedia"));
     media._mediaType = (TMediaType)(dataReader.IsDBNull(dataReader.GetOrdinal("typMedia")) ? 0 : dataReader.GetInt32("typMedia"));
     media._tCStart = dataReader.IsDBNull(dataReader.GetOrdinal("TCStart")) ? default(TimeSpan) : dataReader.GetTimeSpan("TCStart");
     media._tCPlay = dataReader.IsDBNull(dataReader.GetOrdinal("TCPlay")) ? default(TimeSpan) : dataReader.GetTimeSpan("TCPlay");
     media.idProgramme = dataReader.IsDBNull(dataReader.GetOrdinal("idProgramme")) ? 0 : dataReader.GetUInt64("idProgramme");
     media._audioVolume = dataReader.IsDBNull(dataReader.GetOrdinal("AudioVolume")) ? 0 : dataReader.GetDecimal("AudioVolume");
     media._audioLevelIntegrated = dataReader.IsDBNull(dataReader.GetOrdinal("AudioLevelIntegrated")) ? 0 : dataReader.GetDecimal("AudioLevelIntegrated");
     media._audioLevelPeak = dataReader.IsDBNull(dataReader.GetOrdinal("AudioLevelPeak")) ? 0 : dataReader.GetDecimal("AudioLevelPeak");
     media._audioChannelMapping = dataReader.IsDBNull(dataReader.GetOrdinal("typAudio")) ? TAudioChannelMapping.Stereo : (TAudioChannelMapping)dataReader.GetByte("typAudio");
     media.HasExtraLines = (typVideo & (byte)0x80) > 0;
     media._videoFormat = (TVideoFormat)(typVideo & 0x7F);
     media._idAux = dataReader.IsDBNull(dataReader.GetOrdinal("idAux")) ? string.Empty : dataReader.GetString("idAux");
     media._killDate = _readDateTimeField(dataReader, "KillDate");
     media._mediaGuid = dataReader.IsDBNull(dataReader.GetOrdinal("MediaGuid")) ? Guid.Empty : dataReader.GetGuid("MediaGuid");
     media._mediaEmphasis = (TMediaEmphasis)((flags >> 8) & 0xF);
     media._parental = (TParental)((flags >> 12) & 0xF);
     if (media is ServerMedia)
         ((ServerMedia)media)._doNotArchive = (flags & 0x1) != 0;
     media._mediaCategory = (TMediaCategory)((flags >> 4) & 0xF); // bits 4-7 of 1st byte
 }
        private void cNextButton_Click(object sender, EventArgs e)
        {
            desig = cdesigCoB.Text;
            fname = cfnameIn.Text;
            sname = csnameIn.Text;
            mname = cmnameIn.Text;

            birthdate = cbdayPick.Value;

            try
            {
                gender = cgenCoB.Text;
                nationality = cnatIn.Text;
                religion = crelIn.Text;
                civstat = ccivstatCoB.Text;
                educattain = cedattCoB.Text;
            }
            catch (Exception err)
            {
                Console.WriteLine(err.Message);
            }
            addline = caddIn.Text;
            city = ccityIn.Text;
            region = cregIn.Text;

            try
            {
                stnumber = UInt16.Parse(pstnoIn.Text);
            }
            catch (FormatException err)
            {
                Console.WriteLine("Street #: " + err.Message);
            }
            catch (OverflowException of)
            {
                Console.WriteLine("Street #: " + of.Message);
            }

            try
            {
                workNum = UInt16.Parse(cWorkIn.Text);
                homeNum = UInt16.Parse(cHomeIn.Text);
                mobNum = UInt16.Parse(cMobileIn.Text);
                otherNum = UInt16.Parse(cOtherIn.Text);
            }
            catch (Exception err)
            {
            }

            //get email
            //needs regex based error checking
            email = cemailIn.Text;
            //get position/relationship of client to patient
            posrel = posIn.Text;
            isPrimary = primaryCB.Checked;

            client.setName(desig, fname, mname, sname);
            client.setBday(birthdate);
            client.setGender(gender);
            client.setNationality(nationality);
            client.setReligion(religion);
            client.setCivilStatus(civstat);
            client.setEducAttainment(educattain);
            client.setEmail(email);
            client.setAddress(stnumber, addline, city, region);
            client.setNumbers(homeNum, workNum, mobNum, otherNum);

            if (true)//implement error checking flags here
            {   string query;
                UInt16 lastID;

                if(selID == 0)
                 RegisterPerson(client);

                OpenConnection();

                if (selID == 0)
                {
                    query = "SELECT LAST_INSERT_ID() FROM PERSON;";
                    cmd = new MySqlCommand(query, conn);
                    read = cmd.ExecuteReader();
                    read.Read();
                    Console.WriteLine(read.GetDecimal(0).ToString());
                   lastID = UInt16.Parse(read.GetDecimal(0).ToString());
                    client.setID(lastID);
                    read.Close();

                    query = "INSERT INTO CLIENT (ClientID) VALUES(@cid);";
                    cmd.CommandText = query;
                    cmd.Prepare();
                    cmd.Parameters.AddWithValue("@cid", lastID);
                    cmd.ExecuteNonQuery();
                }
                else
                {
                    client.setID(selID);
                }

                query = "INSERT INTO RELATIONSHIP VALUES (@pd,@cd,@ip,@rel);";
                cmd.CommandText = query;
                cmd.Prepare();
                cmd.Parameters.AddWithValue("@pd", patient.getID());
                cmd.Parameters.AddWithValue("@cd", client.getID());
                cmd.Parameters.AddWithValue("@ip", isPrimary);
                cmd.Parameters.AddWithValue("@rel", posrel);
                cmd.ExecuteNonQuery();

                CloseConnection();
                tabControl1.SelectedIndex++;
            }
            else
            {
            }
        }
        private void pNextButton_Click(object sender, EventArgs e)
        {
            //Patient Tab
            //get all the values in the fields & perform error checking
            //currently, clicking this button will register the Patient details into
            //the database. Will change this in the future so that if the user cancels the
            //registration, all table entries related to the cancelled registration
            //will be removed from the database.

            desig = pdesigCoB.Text;

            fname = pfnameIn.Text;
            sname = psnameIn.Text;
            mname = pmnameIn.Text;

            birthdate = pbdayPick.Value;             //Get data from DateTime Picker

            if (Checker.check(fname))
                Console.WriteLine("FNAME IS GOOD");
            else
                Console.WriteLine("FNAME IS SHIT");

            if (Checker.check(sname))
                Console.WriteLine("SNAME IS GOOD");
            else
                Console.WriteLine("SNAME IS SHIT");

            if (Checker.check(mname))
                Console.WriteLine("MNAME IS GOOD");
            else
                Console.WriteLine("MNAME IS SHIT");

            //following fields must not be blank

                gender = pgenCoB.Text;
                nationality = pnatIn.Text;
                religion = prelIn.Text;
                civstat = pcivStatCoB.Text;
                educattain = pedattCoB.Text;

            //fields for address. must not be blank!
            addline = paddlineIn.Text;
            city = pcityIn.Text;
            region = pregIn.Text;

            try
            {
                stnumber = UInt16.Parse(pstnoIn.Text);
            }
            catch (FormatException err)
            {
                Console.WriteLine("Street #: " + err.Message);
            }
            catch (OverflowException of)
            {
                Console.WriteLine("Street #: " + of.Message);
            }

            try
            {
                workNum = UInt16.Parse(pWorkIn.Text);
                homeNum = UInt16.Parse(pHomeIn.Text);
                mobNum = UInt16.Parse(pMobileIn.Text);
                otherNum = UInt16.Parse(pOtherIn.Text);
            }
            catch (Exception err)
            {
            }

            //get email
            //needs regex based error checking
            email = pemailIn.Text;

            //add fields to Patient Object
            patient.setName(desig, fname, mname, sname);
            patient.setBday(birthdate);
            patient.setGender(gender);
            patient.setNationality(nationality);
            patient.setReligion(religion);
            patient.setCivilStatus(civstat);
            patient.setEducAttainment(educattain);
            patient.setEmail(email);
            patient.setAddress(stnumber, addline, city, region);
            patient.setNumbers(homeNum, workNum, mobNum, otherNum);

            //displayStuff(patient);

            //open connection to database
            if (true)
            {
                RegisterPerson(patient);

                //insert into patient table

                OpenConnection();

                string query = "SELECT LAST_INSERT_ID() FROM PERSON;";
                cmd.CommandText = query;

                read = cmd.ExecuteReader();

                read.Read();

                Console.WriteLine(read.GetDecimal(0).ToString());

                UInt16 lastID = UInt16.Parse(read.GetDecimal(0).ToString());

                patient.setID(lastID);

                read.Close();

                query = "INSERT INTO PATIENT(PatID) VALUES(@pid);";

                cmd.CommandText = query;

                cmd.Prepare();

                cmd.Parameters.AddWithValue("@pid", lastID);

                cmd.ExecuteNonQuery();

                CloseConnection();

                tabControl1.SelectedIndex++;

            }
            else
            {

            }

            //move to next tab
        }
Beispiel #30
0
 public static LineaComponente GetLineaComponente(MySqlDataReader rdr)
 {
     LineaComponente lc = new LineaComponente();
     lc.NumLinea = rdr.GetInt32("NUMLINEA");
     lc.Articulo = rdr.GetString("NOMARTIC");
     lc.Cantidad = rdr.GetDecimal("CANTIDAD");
     return lc;
 }