Exemplo n.º 1
0
Arquivo: Sql.cs Projeto: jcoeiii/RMT
        static public void DeletePO(FormMain.dbType type, string PO)
        {
            SQLiteConnection con = GetConnection();
            {
                using (System.Data.SQLite.SQLiteCommand com = new System.Data.SQLite.SQLiteCommand("SET ARITHABORT ON", con))
                {
                    try
                    {
                        if (type == FormMain.dbType.Order)
                        {
                            com.CommandText = Order.DeletePOCommandText(PO);
                        }
                        else
                        {
                            com.CommandText = Quote.DeletePOCommandText(PO);
                        }
                        com.ExecuteNonQuery();

                        //if (type == FormMain.dbType.Order)
                        //    Sql._OrderTotal--;
                    }
                    catch (SqlException ex)
                    {
                        MessageBox.Show("Database error: " + ex.Message);
                    }
                }
            }
        }
Exemplo n.º 2
0
Arquivo: Sql.cs Projeto: jcoeiii/RMT
        //static private int _OrderTotal = 0;

        static public int GetRowCounts(FormMain.dbType type)
        {
            int?count            = 0;
            SQLiteConnection con = GetConnection();

            {
                using (System.Data.SQLite.SQLiteCommand com = new System.Data.SQLite.SQLiteCommand("SET ARITHABORT ON", con))
                {
                    try
                    {
                        if (type == FormMain.dbType.Order)
                        {
                            com.CommandText = Order.GetRowCountCommandText;
                        }
                        else
                        {
                            com.CommandText = Quote.GetRowCountCommandText;
                        }
                        object o = com.ExecuteScalar();
                        count = Convert.ToInt32(o);
                    }
                    catch// (Exception ex)
                    {
                    }
                }
            }

            //if (type == FormMain.dbType.Order && count.HasValue)
            //{
            //    _OrderTotal = count.Value;
            //}
            return((count == null) ? 0 : count.Value);
        }
Exemplo n.º 3
0
Arquivo: Sql.cs Projeto: jcoeiii/RMT
 static public int InsertRow(FormMain.dbType type, List <string> guis)
 {
     Killconnection();
     SQLiteConnection con = GetConnection();
     {
         using (System.Data.SQLite.SQLiteCommand com = new System.Data.SQLite.SQLiteCommand(con))
         {
             if (type == FormMain.dbType.Order)
             {
                 com.CommandText = Order.InsertRowCommandText;
                 for (int i = 0; i < Order.NameCount; i++)
                 {
                     com.Parameters.AddWithValue("@" + Order.GetTableName(i), guis[i]);
                 }
             }
             else
             {
                 com.CommandText = Quote.InsertRowCommandText;
                 for (int i = 0; i < Quote.NameCount; i++)
                 {
                     com.Parameters.AddWithValue("@" + Quote.GetTableName(i), guis[i]);
                 }
             }
             try
             {
                 int cnt = com.ExecuteNonQuery();      // Execute the query
                 //if (type == FormMain.dbType.Order)
                 //    Sql._OrderTotal++;
                 return(cnt);
             }
             catch (SqlException ex)
             {
                 MessageBox.Show("Database error: " + ex.Message);
                 return(0);
             }
         }
     }
 }
Exemplo n.º 4
0
Arquivo: Sql.cs Projeto: jcoeiii/RMT
        static public List <string> ReadRow(FormMain.dbType type, string PO, int rowCount, out List <string> guis)
        {
            guis = new List <string>();

            SQLiteConnection con = GetConnection();

            {
                using (System.Data.SQLite.SQLiteCommand com = new System.Data.SQLite.SQLiteCommand("SET ARITHABORT ON", con))
                {
                    if (type == FormMain.dbType.Order)
                    {
                        com.CommandText = Order.ReadRowCommandText(PO);
                    }
                    else
                    {
                        com.CommandText = Quote.ReadRowCommandText(PO);
                    }
                    try
                    {
                        using (SQLiteDataAdapter DB = new SQLiteDataAdapter(com))
                        {
                            DataSet DS = new DataSet();

                            if (type == FormMain.dbType.Order)
                            {
                                DB.Fill(DS, "OrderTable");

                                if (DS.Tables["OrderTable"].Rows.Count != 0)
                                {
                                    DataRow rrr = DS.Tables["OrderTable"].Rows[rowCount];

                                    for (int i = 0; i < Order.NameCount; i++)
                                    {
                                        guis.Add(rrr[Order.GetTableName(i)] as string);
                                    }
                                    return(guis);
                                }
                            }
                            else
                            {
                                DB.Fill(DS, "QuoteTable");

                                if (DS.Tables["QuoteTable"].Rows.Count != 0)
                                {
                                    DataRow rrr = DS.Tables["QuoteTable"].Rows[rowCount == 0 ? 0 : rowCount - 1];

                                    for (int i = 0; i < Quote.NameCount; i++)
                                    {
                                        guis.Add(rrr[Quote.GetTableName(i)] as string);
                                    }
                                    return(guis);
                                }
                            }
                        }
                    }
                    catch (SqlException ex)
                    {
                        MessageBox.Show("Database error: " + ex.Message);
                    }
                }
            }
            return(Order.Defaults);
        }
Exemplo n.º 5
0
Arquivo: Sql.cs Projeto: jcoeiii/RMT
        static public List <string> GetPOs(FormMain.dbType type)
        {
            List <string>    POs = new List <string>();
            SQLiteConnection con = GetConnection();
            {
                using (System.Data.SQLite.SQLiteCommand com = new System.Data.SQLite.SQLiteCommand("SET ARITHABORT ON", con))
                {
                    try
                    {
                        if (type == FormMain.dbType.Order)
                        {
                            com.CommandText = Order.GetPOsCommandText;
                        }
                        else
                        {
                            com.CommandText = Quote.GetPOsCommandText;
                        }

                        using (SQLiteDataAdapter DB = new SQLiteDataAdapter(com))
                        {
                            DataSet DS = new DataSet();
                            if (type == FormMain.dbType.Order)
                            {
                                DB.Fill(DS, "OrderTable");

                                if (DS.Tables["OrderTable"].Rows.Count != 0)
                                {
                                    DataRow rrr;
                                    int     max = GetRowCounts(type);
                                    for (int i = 0; i < max; i++)
                                    {
                                        #region reads as strings
                                        rrr = DS.Tables["OrderTable"].Rows[i];
                                        POs.Add(rrr["PO"] as string);
                                        #endregion
                                    }
                                }
                            }
                            else
                            {
                                DB.Fill(DS, "QuoteTable");

                                if (DS.Tables["QuoteTable"].Rows.Count != 0)
                                {
                                    DataRow rrr;
                                    int     max = GetRowCounts(type);
                                    for (int i = 0; i < max; i++)
                                    {
                                        #region reads as strings
                                        rrr = DS.Tables["QuoteTable"].Rows[i];
                                        POs.Add(rrr["PO"] as string);
                                        #endregion
                                    }
                                }
                            }
                        }
                    }
                    catch (SqlException ex)
                    {
                        MessageBox.Show("Database error: " + ex.Message);
                    }
                }
            }
            return(POs);
        }