Exemplo n.º 1
0
 public Form_StockItem_Edit(CodeTables.DBTableControl xdbTables, SQLTable xtbl,string where_condition, string ColumnToOrderBy,TangentaDB.Item_Data x_Item_Data, NavigationButtons.Navigation xnav)
 {
     InitializeComponent();
     nav = xnav;
     m_Item_Data = x_Item_Data;
     lngRPM.s_lbl_Item_Stock.Text(lbl_Item_Stock);
     this.lbl_Item.Text = m_Item_Data.Item_UniqueName.v;
     dbTables = xdbTables;
     tbl = xtbl;
     this.Text = lngRPM.s_Stock.s;
     string selection = @"Stock_$_ppi_$_i_$$UniqueName,Stock_$$dQuantity,Stock_$$ExpiryDate, Stock_$_ppi_$_pp_$$PurchasePricePerUnit,Stock_$$ImportTime,Stock_$_ppi_$_i_$$Description,Stock_$_ppi_$_st_$_sup_$_c_$_orgd_$_org_$$Name,Stock_$_ppi_$_i_$$Code,Stock_$_ppi_$_i_$_u_$$Name,Stock_$_ppi_$_i_$_u_$$Symbol,Stock_$_ppi_$_i_$_u_$$DecimalPlaces,Stock_$_ppi_$_i_$_u_$$StorageOption,Stock_$_ppi_$_i_$_exp_$$ExpectedShelfLifeInDays,Stock_$_ppi_$_i_$_exp_$$SaleBeforeExpiryDateInDays,Stock_$_ppi_$_i_$_exp_$$DiscardBeforeExpiryDateInDays,Stock_$_ppi_$_i_$_wrty_$$WarrantyDuration, Stock_$_ppi_$_i_$_wrty_$$WarrantyDurationType,Stock_$_ppi_$_i_$_wrty_$$WarrantyConditions,Stock_$_ppi_$_i_$_iimg_$$Image_Data,ID";
     if (m_usrc_EditTable.Init(dbTables, tbl, selection,ColumnToOrderBy,false,where_condition,null,false,nav))
     {
         if (m_usrc_EditTable.RowsCount==0)
         {
             if (f_PurchasePrice_Item.GetOneFrom_Item_ID(m_Item_Data.Item_ID.v, ref PurchasePrice_Item_ID))
             {
                 m_usrc_EditTable.FillInitialData();
             }
             else
             {
                 bclose = true;
                 return;
             }
         }
         m_usrc_EditTable.CallBackSetInputControlProperties(m_Item_Data.Unit_DecimalPlaces.v);
     }
     else
     {
         bclose = true;
     }
 }
Exemplo n.º 2
0
 public Form_ShopC_Item_Edit(CodeTables.DBTableControl xdbTables, SQLTable xtbl, string xColumnOrderBy, long ID, Control xParentControl)
 {
     InitializeComponent();
     dbTables = xdbTables;
     tbl = xtbl;
     ColumnOrderBy = xColumnOrderBy;
     ID_v = new long_v();
     ID_v.v = ID;
     ParentControl = xParentControl;
     if (ParentControl != null)
     {
         if (ParentControl is usrc_StockEditForSelectedStockTake)
         {
             m_usrc_StockEditForSelectedStockTake = (usrc_StockEditForSelectedStockTake)ParentControl;
         }
     }
     this.Text = lngRPM.s_Items.s;
     rdb_OnlyInOffer.Checked = true;
     lngRPM.s_OnlyInOffer.Text(this.rdb_OnlyInOffer);
     lngRPM.s_AllItems.Text(this.rdb_All);
     lngRPM.s_OnlyNotInOffer.Text(this.rdb_OnlyNotInOffer);
     if (nav==null)
     {
         nav = new NavigationButtons.Navigation();
         nav.m_eButtons = NavigationButtons.Navigation.eButtons.OkCancel;
         nav.eExitResult = NavigationButtons.Navigation.eEvent.NOTHING;
         usrc_NavigationButtons1.Init(nav);
     }
 }
Exemplo n.º 3
0
 public EditTable_Form(DBTableControl dbTables, SQLTable tbl, TableDockingForm dtF,Globals.delegate_SetControls xSetControls, bool bReadOnly,NavigationButtons.Navigation xnav)
 {
     m_TableDockingForm = dtF;
     this.Icon = Properties.Resources.SmallEditIcon;
     InitializeComponent();
     this.Text = lngRPM.s_EditTable.s + tbl.lngTableName.s + " (" + tbl.TableName + ")";
     usrc_EditRow.Init(dbTables, tbl, xSetControls, bReadOnly,xnav);
 }
Exemplo n.º 4
0
 public Form_StockTake_Edit(Navigation xnav, CodeTables.DBTableControl xdbTables)
 {
     InitializeComponent();
     this.nav = xnav;
     dbTables = xdbTables;
     this.Text = lngRPM.s_EditStockTakeItems.s;
     usrc_EditTable1.Text(lngRPM.s_EditStockTake);
 }
 public Form_OrganisationAccount_Edit(CodeTables.DBTableControl xdbTables, SQLTable xtbl,string xColumnOrderBy, NavigationButtons.Navigation xnav)
 {
     InitializeComponent();
     nav = xnav;
     dbTables = xdbTables;
     tbl = xtbl;
     ColumnOrderBy = xColumnOrderBy;
     this.Text = lngRPM.s_OrganisationAccount.s;
 }
Exemplo n.º 6
0
 public Form_PersonData_Edit(CodeTables.DBTableControl xdbTables, SQLTable xtbl,string xColumnOrderBy,NavigationButtons.Navigation xnav)
 {
     InitializeComponent();
     nav = xnav;
     dbTables = xdbTables;
     tbl = xtbl;
     ColumnOrderBy = xColumnOrderBy;
     this.Text = lngRPM.s_Customers_Person.s;
 }
Exemplo n.º 7
0
 public Form_DBSettings_Edit(CodeTables.DBTableControl xdbTables, SQLTable xtbl, string xColumnOrderBy, NavigationButtons.Navigation xnav)
 {
     InitializeComponent();
     nav = xnav;
     dbTables = xdbTables;
     tbl = xtbl;
     ColumnOrderBy = xColumnOrderBy;
     lngRPM.s_DBSettings.Text(this);
 }
 public PersonAccount_EditForm(CodeTables.DBTableControl xdbTables, SQLTable xtbl, string xColumnOrderBy, long ID)
 {
     InitializeComponent();
     dbTables = xdbTables;
     tbl = xtbl;
     ColumnOrderBy = xColumnOrderBy;
     ID_v = new long_v();
     ID_v.v = ID;
     this.Text = lngRPM.s_Items.s;
 }
Exemplo n.º 9
0
 public Form_myOrg_Edit(CodeTables.DBTableControl xdbTables,SQLTable xtbl,bool bAllowNew, NavigationButtons.Navigation xnav)
 {
     InitializeComponent();
     nav = xnav;
     this.usrc_NavigationButtons1.Init(nav);
     dbTables = xdbTables;
     tbl = xtbl;
     usrc_EditRow.AllowUserToAddNew = bAllowNew;
     lngRPM.s_Edit_Offices.Text(btn_Office);
 }
Exemplo n.º 10
0
 public Form_ShopAItem_Edit(CodeTables.DBTableControl xdbTables, SQLTable xtbl, string ColumnToOrderBy)
 {
     InitializeComponent();
     dbTables = xdbTables;
     tbl = xtbl;
     this.Text = lngRPM.s_ShopB_Items.s;
     if (!usrc_EditTable.Init(dbTables, tbl,null,ColumnToOrderBy,false,null,null,false,null))
     {
         bclose = true;
     }
 }
Exemplo n.º 11
0
 public Form_Customer_Person_Edit(CodeTables.DBTableControl xdbTables, SQLTable xtbl, string xColumnOrderBy, long ID)
 {
     InitializeComponent();
     dbTables = xdbTables;
     tbl = xtbl;
     ColumnOrderBy = xColumnOrderBy;
     ID_v = new long_v();
     ID_v.v = ID;
     this.Text = lngRPM.s_Items.s;
     this.usrc_EditTable.Title = xtbl.lngTableName.s;
 }
Exemplo n.º 12
0
 public Form_PersonData_Edit(CodeTables.DBTableControl xdbTables, SQLTable xtbl, string xColumnOrderBy, long ID, NavigationButtons.Navigation xnav)
 {
     InitializeComponent();
     nav = xnav;
     dbTables = xdbTables;
     tbl = xtbl;
     ColumnOrderBy = xColumnOrderBy;
     ID_v = new long_v();
     ID_v.v = ID;
     this.Text = lngRPM.s_Items.s;
 }
 public SelectID_Table_Assistant_Form(string sql, SQLTable tbl, DBTableControl xDBTables, string[] xsCoumnsToView)
 {
     InitializeComponent();
     m_sql = sql;
     m_DBTables = xDBTables;
     m_tbl = tbl;
     this.Text = tbl.lngTableName.s + " (" + tbl.TableName + ")";
     string csError = "";
     ColumnToView = xsCoumnsToView;
     FillDataTable(ref csError);
     this.btn_Cancel.Text = lngRPM.s_Cancel.s;
 }
Exemplo n.º 14
0
        public DataTable_Form(DBTableControl dbTables, SQLTable tbl, DataTable_Form_ENUM eMode, TableDockingForm pForm)
        {
            //m_DB = pDB;
            m_DBTables = dbTables;
            m_Mode = eMode;
            m_tbl = tbl;

            m_TableDockingForm = pForm;

            this.Icon = Properties.Resources.table;
            InitializeComponent();
            SetControls(m_tbl);
        }
Exemplo n.º 15
0
        public MyDataBase_Tangenta(Form pForm, string XmlRootName, string xmlIniFileFolder)
        {
            // TODO: Complete member initialization
            mt = new TangentaTableClass.SQL_Database_Tables_Definition();

            m_DBTables = new DBTableControl(pForm, XmlRootName, xmlIniFileFolder);

            //            Define_Image_SQL_Database_Tables();

            //            Define_Document_SQL_Database_Tables();

            Define_SQL_Database_Tables();
        }
Exemplo n.º 16
0
 public bool Insert(ref long ID, DBTableControl dbTables)
 {
     switch (dbTables.m_con.DBType)
     {
         case DBConnectionControl40.DBConnection.eDBType.SQLITE:
             return Insert_SQL(ref ID, dbTables,-1);
         case DBConnectionControl40.DBConnection.eDBType.MSSQL:
             return Insert_SQL(ref ID, dbTables,-1);
         case DBConnectionControl40.DBConnection.eDBType.MYSQL:
             return Insert_SQL(ref ID, dbTables,-1);
     }
     return false;
 }
Exemplo n.º 17
0
 public Form_Templates(CodeTables.DBTableControl xdbTables, SQLTable xtbl,string xColumnOrderBy, NavigationButtons.Navigation xnav)
 {
     InitializeComponent();
     nav = xnav;
     dbTables = xdbTables;
     tbl = xtbl;
     ColumnOrderBy = xColumnOrderBy;
     this.Text = lngRPM.s_Items.s;
     rdb_OnlyInOffer.Checked = true;
     this.rdb_OnlyInOffer.Text = lngRPM.s_OnlyInOffer.s;
     this.rdb_All.Text = lngRPM.s_AllItems.s;
     this.rdb_OnlyNotInOffer.Text = lngRPM.s_OnlyNotInOffer.s;
 }
Exemplo n.º 18
0
 public Form_ShopC_Item_Edit(CodeTables.DBTableControl xdbTables, SQLTable xtbl,string xColumnOrderBy, NavigationButtons.Navigation xnav)
 {
     InitializeComponent();
     nav = xnav;
     dbTables = xdbTables;
     tbl = xtbl;
     usrc_NavigationButtons1.Init(nav);
     ColumnOrderBy = xColumnOrderBy;
     lngRPM.s_Items.Text(this, " "+lngRPM.s_Shop_C.s);
     rdb_OnlyInOffer.Checked = true;
     lngRPM.s_OnlyInOffer.Text(this.rdb_OnlyInOffer);
     lngRPM.s_AllItems.Text(this.rdb_All);
     lngRPM.s_OnlyNotInOffer.Text(this.rdb_OnlyNotInOffer);
 }
Exemplo n.º 19
0
 public Price_Undefined_Window(string sTitle,DataTable xdt_price_Item_view,CodeTables.DBTableControl xdbTables)
 {
     InitializeComponent();
     this.Title = sTitle;
     this.btn_Edit.Content = lngRPM.s_EditPriceList.s;
     this.btn_Cancel.Content = lngRPM.s_Cancel.s;
     dt_price_Item_view = xdt_price_Item_view;
     dbTables = xdbTables;
     this.dgvx_PriceUndefinedItem.ItemsSource = dt_price_Item_view.AsDataView();
     tbl = new SQLTable(dbTables.GetTable(typeof(Atom_cAddress_Org)));
     tbl.CreateTableTree(dbTables.items);
     this.dgvx_PriceUndefinedItem.AutoGeneratedColumns +=dgvx_PriceUndefinedItem_AutoGeneratedColumns;
     //this.dgvx_PriceUndefinedItem.Columns[0].Header =
 }
Exemplo n.º 20
0
 public EditTable_Assistant_Form(usrc_myGroupBox mygrpbox, SQLTable tbl,ID_v id_v, DBTableControl xDBTables,int xpos, int ypos)
 {
     my_start_up_id_v = id_v;
     m_xpos = xpos;
     m_ypos = ypos;
     m_DBTables = xDBTables;
     m_MyGroupBox = mygrpbox;
     m_tbl = tbl;
     InitializeComponent();
     btn_Cancel.Text = lngRPM.s_Cancel.s;
     this.Text = tbl.lngTableName.s + " (" + tbl.TableName + ")";
     string csError="";
     FillDataTable(ref csError);
 }
Exemplo n.º 21
0
        public TableDockingForm(Form pParentForm, DBTableControl dbTables, SQLTable tbl,NavigationButtons.Navigation xnav)
        {
            nav = xnav;
            m_pParentForm = pParentForm;
            InitializeComponent();
            m_DBTables = dbTables;
            m_tbl = tbl;
            m_pTableDockingFormXml = m_DBTables.m_xml.GetTableDockingFormXml(m_tbl.TableName);
            if (m_pTableDockingFormXml == null)
            {
                m_pTableDockingFormXml = new TableDockingFormXml(m_tbl.TableName);
                m_DBTables.m_xml.m_xmldata.Add(m_pTableDockingFormXml);
            }

            m_pTableDockingFormXml.wrect.SetFormPlacement(this);

            this.Icon = Properties.Resources.TableDockingForm_icon;
            this.Text = m_tbl.lngTableName.s;
            SetViews();
        }
Exemplo n.º 22
0
 public Form_ShopB_Item_Edit(CodeTables.DBTableControl xdbTables, SQLTable xtbl, string ColumnToOrderBy, NavigationButtons.Navigation xnav)
 {
     InitializeComponent();
     m_bChanged = false;
     dbTables = xdbTables;
     nav = xnav;
     tbl = xtbl;
     lngRPM.s_Items.Text(this, " "+lngRPM.s_Shop_B.s);
     List_of_Inserted_Items_ID = new List<long>();
     rdb_OnlyInOffer.Checked = true;
     lngRPM.s_OnlyInOffer.Text(this.rdb_OnlyInOffer);
     lngRPM.s_AllItems.Text(this.rdb_All);
     lngRPM.s_OnlyNotInOffer.Text(this.rdb_OnlyNotInOffer);
     usrc_NavigationButtons1.Init(xnav);
     string selection = " SimpleItem_$$Name,SimpleItem_$$Abbreviation,SimpleItem_$_siimg_$$Image_Data,SimpleItem_$_sipg1_$$Name,SimpleItem_$_sipg1_$_sipg2_$$Name,SimpleItem_$_sipg1_$_sipg2_$_sipg3_$$Name,SimpleItem_$$ToOffer,ID ";
     if (!usrc_EditTable.Init(dbTables, tbl, selection, ColumnToOrderBy,false,null,null,false,nav))
     {
         bclose = true;
     }
 }
        public void CreateInputControls(SQLTable pPrevTable,
                                        Column fcol, 
                                        string sParentKeys, 
                                        ref List<usrc_InputControl> 
                                        inpCtrlList, 
                                        Object pParentWindow, 
                                        Control pControl,
                                        DBTableControl xDBTables,
                                        bool bReadOnly,
                                        NavigationButtons.Navigation xnav)
        {
            int iCol = 0;
            int iCount = Column.Count();
            this.pParentTable = pPrevTable;
            this.myGroupBox = new usrc_myGroupBox();
            this.myGroupBox.SelectionButtonVisible = m_SelectionButtonVisible;
            this.myGroupBox.Init(this, fcol, sParentKeys, pParentWindow, pControl, xDBTables, bReadOnly,xnav);

            if (pParentWindow.GetType() == typeof(myPanel))
            {
                this.myGroupBox.Left = 5;
                this.myGroupBox.Top = 5;
                Panel pnl = (Panel)pParentWindow;
                pnl.Controls.Add(myGroupBox);
            }
            else if (pParentWindow.GetType() == typeof(usrc_myGroupBox))
            {
                usrc_myGroupBox pParentMyGroupBox = (usrc_myGroupBox)pParentWindow;
                MyControl mctrl = new MyControl(this.myGroupBox);
                pParentMyGroupBox.controls.Add(mctrl);
            }

            for (iCol = 0; iCol < iCount; iCol++)
            {
                Column col = Column[iCol];
                if (!col.IsIdentity)
                {
                    if (col.fKey != null)
                    {
                        string sKey;
                        bool xbReadOnly = bReadOnly;

                        if (col.Style == CodeTables.Column.eStyle.ReadOnlyTable)
                        {
                            xbReadOnly = true;
                        }

                        sKey = sParentKeys + "*" + col.fKey.refInListOfTables.TableName + ">";
                        col.fKey.fTable.CreateInputControls(this, col, sKey, ref inpCtrlList, this.myGroupBox, pControl, xDBTables, xbReadOnly,xnav);
                    }
                    else
                    {
                        string sImportExportLine;
                        usrc_InputControl inpCtrl;
                        if (col.IsNumber())
                        {
                            sImportExportLine = sParentKeys + col.Name + ",";
                            inpCtrl = new usrc_InputControl();
                            inpCtrl.Init(this, col, inpCtrlList, sImportExportLine, true,bReadOnly);
                            if (!bReadOnly)
                            {
                                inpCtrl.ObjectChanged += new usrc_InputControl.delegate_ObjectChanged(inpCtrl_ObjectChanged);
                            }
                            col.InputControl = inpCtrl;
                        }
                        else
                        {
                            sImportExportLine = sParentKeys + col.Name + ",";
                            inpCtrl = new usrc_InputControl();
                            inpCtrl.Init(this, col, inpCtrlList, sImportExportLine, false,bReadOnly);
                            if (!bReadOnly)
                            {
                                inpCtrl.ObjectChanged += new usrc_InputControl.delegate_ObjectChanged(inpCtrl_ObjectChanged);
                            }
                            col.InputControl = inpCtrl;
                        }
                        MyControl mctrl = new MyControl(inpCtrl);
                        this.myGroupBox.controls.Add(mctrl);
                    }
                }
            }

            if (pPrevTable!=null)
            {
                if (pParentWindow is usrc_myGroupBox)
                {
                    if (!bReadOnly)
                    {
                        this.myGroupBox.Unique_parameter_exist += myGroupBox_Unique_parameter_exist;
                        this.myGroupBox.bUnique_parameter_exist = true;
                        this.myGroupBox.RowReferenceFromTable_Check_NoChangeToOther += myGroupBox_RowReferenceFromTable_Check_NoChangeToOther;
                        this.myGroupBox.usrc_myGroupBox_IndexChanged += new usrc_myGroupBox.delegate_IndexChanged(myGroupBox_usrc_myGroupBox_IndexChanged);
                        this.myGroupBox.usrc_InputControl_ObjectChanged += new usrc_myGroupBox.delegate_ObjectChanged(myGroupBox_usrc_InputControl_ObjectChanged);
                    }
                }
                //if (pParentWindow is Panel)
                //{
                //    if (!bReadOnly)
                //    {
                //        this.myGroupBox.Unique_parameter_exist += myGroupBox_Unique_parameter_exist;
                //        this.myGroupBox.bUnique_parameter_exist = true;
                //        this.myGroupBox.RowReferenceFromTable_Check_NoChangeToOther += myGroupBox_RowReferenceFromTable_Check_NoChangeToOther;
                //        //this.myGroupBox.usrc_myGroupBox_IndexChanged += new usrc_myGroupBox.delegate_IndexChanged(myGroupBox_usrc_myGroupBox_IndexChanged);
                //        //this.myGroupBox.usrc_InputControl_ObjectChanged += new usrc_myGroupBox.delegate_ObjectChanged(myGroupBox_usrc_InputControl_ObjectChanged);
                //    }
                //}
            }
        }
Exemplo n.º 24
0
        private bool Insert_MSSQL(ref long ID, DBTableControl dbTables, int iSQLFormatedTabsWithLineBreaks)
        {
            List<SQL_Parameter> lpar = new List<SQL_Parameter>();
            string sql_insert = " insert into " + this.TableName;

            string sql_insert_columns = "";
            string sql_insert_values = "";
            string crlf = "\r\n";

            if (iSQLFormatedTabsWithLineBreaks >= 0)
            {
                sql_insert += crlf + "(" + crlf;
            }
            else
            {
                sql_insert += "(";
            }

            int i = 0;
            foreach (Column col in Column)
            {
                if (!col.IsIdentity)
                {
                    SQL_Parameter par = null;
                    string Insert_into_value_parameter = null;
                    if (col.get_SQL_Parameter(ref par, ref Insert_into_value_parameter, dbTables, iSQLFormatedTabsWithLineBreaks))
                    {
                        if (par != null)
                        {
                            if (i == 0)
                            {
                                sql_insert_columns += col.Name;
                                sql_insert_values += Insert_into_value_parameter;
                                i = 1;
                            }
                            else
                            {
                                if (iSQLFormatedTabsWithLineBreaks >= 0)
                                {
                                    sql_insert_columns += "," + crlf + col.Name;
                                    sql_insert_values += "," + crlf + Insert_into_value_parameter;
                                }
                                else
                                {
                                    sql_insert_columns += "," + col.Name;
                                    sql_insert_values += "," + Insert_into_value_parameter;
                                }
                            }
                            lpar.Add(par);
                        }
                    }
                    else
                    {
                        return false;
                    }
                }
            }
            if (iSQLFormatedTabsWithLineBreaks >= 0)
            {
                sql_insert += sql_insert_columns + crlf + ")" + crlf + "values" + crlf + "(" + crlf + sql_insert_values + crlf + ")";
            }
            else
            {
                sql_insert += sql_insert_columns + ")values(" + sql_insert_values + ")";
            }
            object objret = null;
            string Err = null;
            if (dbTables.m_con.ExecuteNonQuerySQLReturnID(sql_insert, lpar, ref ID, ref objret, ref Err, this.TableName))
            {
                return true;
            }
            else
            {
                LogFile.Error.Show("Error:SQLTable:Insert_SQLite:Err=" + Err);
                return false;
            }
        }
Exemplo n.º 25
0
        internal bool Insert_SQL_Get_Select_ID(ref long_v id_v, DBTableControl dbTables, int iSQLFormatedTabsWithLineBreaks)
        {
            if (Insert_SQLite_Get_Select_Unique_ID(ref id_v, dbTables, iSQLFormatedTabsWithLineBreaks))
            {
                if (id_v != null)
                {
                    return true;
                }
                else
                {
                    List<SQL_Parameter> lpar = new List<SQL_Parameter>();
                    string sql_select = " select id from " + this.TableName + " where ";
                    string sql_compare_values = "";
                    string sql_InsertColumns = "";
                    string sql_InsertValues = "";
                    int i = 0;
                    foreach (Column col in Column)
                    {
                        if (!col.IsIdentity)
                        {
                            string compare_value_parameter = null;
                            SQL_Parameter par = null;
                            if (col.get_SQL_Parameter(ref par, ref compare_value_parameter, dbTables, iSQLFormatedTabsWithLineBreaks))
                            {
                                if (i == 0)
                                {
                                    if (iSQLFormatedTabsWithLineBreaks < 0)
                                    {
                                        if (compare_value_parameter.Equals("null"))
                                        {
                                            sql_compare_values += col.Name + " is null ";
                                            sql_InsertValues += "null";
                                        }
                                        else
                                        {
                                            sql_compare_values += col.Name + " = " + compare_value_parameter;
                                            sql_InsertValues += compare_value_parameter;
                                            lpar.Add(par);
                                        }

                                    }
                                    else
                                    {
                                        if (compare_value_parameter.Equals("null"))
                                        {
                                            sql_compare_values += "\r\n" + col.Name + " is null ";
                                            sql_InsertValues += "\r\nnull";
                                        }
                                        else
                                        {
                                            sql_compare_values += "\r\n" + col.Name + " = " + compare_value_parameter;
                                            sql_InsertValues += "\r\n" + compare_value_parameter;
                                            lpar.Add(par);

                                        }
                                    }
                                    sql_InsertColumns += col.Name;
                                    i = 1;
                                }
                                else
                                {
                                    if (iSQLFormatedTabsWithLineBreaks < 0)
                                    {
                                        if (compare_value_parameter.Equals("null"))
                                        {
                                            sql_compare_values += " and " + col.Name + " is null ";
                                            sql_InsertValues += ",null";
                                        }
                                        else
                                        {
                                            sql_compare_values += " and " + col.Name + " = " + compare_value_parameter;
                                            sql_InsertValues += "," + compare_value_parameter;
                                            lpar.Add(par);
                                        }
                                    }
                                    else
                                    {
                                        if (compare_value_parameter.Equals("null"))
                                        {
                                            sql_compare_values += "\r\n and " + col.Name + " is null ";
                                            sql_InsertValues += "\r\n,null";
                                        }
                                        else
                                        {
                                            sql_compare_values += "\r\n and " + col.Name + " = " + compare_value_parameter;
                                            sql_InsertValues += "\r\n," + compare_value_parameter;
                                            lpar.Add(par);
                                        }
                                    }
                                    sql_InsertColumns += ","+col.Name;
                                }
                            }
                            else
                            {
                                return false;
                            }
                        }
                    }
                    if (sql_compare_values.Length > 0)
                    {
                        sql_select += sql_compare_values;
                        DataTable dt = new DataTable();
                        string Err = null;
                        if (dbTables.m_con.ReadDataTable(ref dt, sql_select, lpar, ref Err))
                        {
                            if (dt.Rows.Count > 0)
                            {
                                if (id_v == null)
                                {
                                    id_v = new long_v();
                                }
                                id_v.v = (long)dt.Rows[0]["id"];
                                return true;
                            }
                            else
                            {
                                string sql_insert = "insert into " + this.TableName + "(" + sql_InsertColumns+")Values("+sql_InsertValues+")";            // row not found
                                long id = -1;
                                object oret = null;
                                if (dbTables.m_con.ExecuteNonQuerySQLReturnID(sql_insert, lpar, ref id, ref oret, ref Err, this.TableName))
                                {
                                    if (id_v == null)
                                    {
                                        id_v = new long_v();
                                    }
                                    id_v.v = id;
                                    return true;
                                }
                                else
                                {
                                    LogFile.Error.Show("ERROR:Insert_SQLite_Get_Select_ID:sql=" + sql_select + "\r\nErr=" + Err);
                                    return false;
                                }
                            }
                        }
                        else
                        {
                            LogFile.Error.Show("ERROR:Insert_SQLite_Get_Select_ID:sql=" + sql_select + "\r\nErr=" + Err);
                            return false;
                        }
                    }
                    return true;
                }
            }
            else
            {
                return false;
            }
        }
Exemplo n.º 26
0
 private bool Insert_MYSQL(ref long ID, DBTableControl dbTables)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 27
0
 public static bool InsertInDataBase_WithImportText(Globals.delegate_SetControls SetControls, SQLTable m_tbl,DBTableControl dbTables, StringBuilder sDataBaseUsed, bool bRefresh_m_DataTable_Form)
 {
     bool bRet = false;
     List<string> Lines = m_tbl.GetInputControlsData();
     if (Lines != null)
     {
         if (Lines.Count > 0)
         {
             string ErrorMsg = "";
             if (SQLcmd_InsertLines(Lines, dbTables, sDataBaseUsed, ref ErrorMsg))
             {
                 bRet = true;
                 //System.Data.OleDb.OleDbDataAdapter adp=new System.Data.OleDb.OleDbDataAdapter();
                 if (bRefresh_m_DataTable_Form)
                 {
                     if (SetControls != null)
                     {
                         SetControls(m_tbl);
                     }
                 }
             }
             else
             {
                 if (!DBConnectionControl40.DynSettings.bPreviewSQLBeforeExecution)
                 {
                     MessageBox.Show(ErrorMsg);
                 }
             }
         }
     }
     return bRet;
 }
Exemplo n.º 28
0
        public static bool SQLcmd_InsertLines(List<string> Line, DBTableControl dbTables, StringBuilder m_strSQLUseDatabase, ref string ErrorMsg)
        {
            List<SQL_Parameter> lsqlPar = new List<SQL_Parameter>();

            SQLTable sqlTbl = null;
            SQLTable refsqlTbl = null;
            int iTableNameStart;
            int iTableNameEnd;
            StringBuilder sbSQLInsert = new StringBuilder(m_strSQLUseDatabase.ToString());
            string sPrevVar = "";

            char[] trimChars = new char[] { ' ', '\t' };

            int index;
            int iCount = Line.Count();
            index = 0;
            while (index < iCount)
            {
                string sLine = Line[index];
                if (sqlTbl != null)
                {
                    iTableNameStart = sLine.IndexOf('<');
                    if (iTableNameStart != -1)
                    {
                        iTableNameStart++;
                        if (sLine[iTableNameStart].Equals('/'))
                        {
                            iTableNameStart++;
                            iTableNameEnd = sLine.IndexOf('>');
                            string sTblName = sLine.Substring(iTableNameStart, iTableNameEnd - iTableNameStart);
                            if (sqlTbl.TableName.Equals(sTblName))
                            {
                                string sVarID = Globals.sVar + "_" + sqlTbl.TableName;
                                sPrevVar = Globals.sVar;
                                if (dbTables.m_con.DBType == DBConnection.eDBType.SQLITE)
                                {
                                    string PrevVar = sqlTbl.TableName;
                                    sVarID = "";
                                    Int64 ID = -1;
                                    string csError = null;
                                    bool bSomethingDefined = false;
                                    if (sqlTbl.SQLcmd_InsertInto_SQLITE(dbTables.m_con, PrevVar, ref sVarID, /*ref  lsqlPar,*/ dbTables.items,ref bSomethingDefined, ref ID, ref csError))
                                    {
                                        if (ID != -1)
                                        {
                                            return true;
                                        }
                                        else
                                        {
                                            return false;
                                        }
                                    }
                                    else
                                    {
                                        LogFile.Error.Show("Error:" + csError);
                                    }
                                }
                                else
                                {
                                    sqlTbl.SQLcmd_Insert_MSSQL(ref sbSQLInsert, sPrevVar, ref sVarID, ref lsqlPar, dbTables.items,0);
                                    object oResult = null;
                                    if (dbTables.m_con.ExecuteNonQuerySQL(sbSQLInsert.ToString(), lsqlPar,ref oResult, ref ErrorMsg))
                                    {
                                        lsqlPar.Clear();
                                        sbSQLInsert.Remove(0, sbSQLInsert.Length);
                                        sbSQLInsert.Append(m_strSQLUseDatabase.ToString());
                                        sqlTbl = null;
                                    }
                                    else
                                    {
                                        return false;
                                    }
                                }
                            }
                            else
                            {
                                MessageBox.Show(lngRPM.s_Illegal_end_table_XML_command_expected.s + ": </" + sqlTbl.TableName + ">\n", lngRPM.s_Error.s, MessageBoxButtons.OK, MessageBoxIcon.Error);
                                //Source_Txt.CloseText();
                            }
                        }
                        else
                        {
                            MessageBox.Show(lngRPM.s_Illegal_end_table_XML_command_expected.s + ": </" + sqlTbl.TableName + ">\n", lngRPM.s_Error.s, MessageBoxButtons.OK, MessageBoxIcon.Error);
                            //                                Source_Txt.CloseText();
                        }
                    }
                    else
                    {
                        string[] column = sLine.Split(',');
                        int iTokenCount = column.Count();
                        string s1;
                        string s2 = "";
                        if (iTokenCount >= 2)
                        {
                            s1 = column[0];
                            int i;
                            for (i = 1; i < iTokenCount; i++)
                            {
                                s2 += column[i];
                            }
                            string Value = "";
                            index = GetValue(index, Line, s2, ref Value);
                            if (sqlTbl.SetColumnValue(s1, Value))
                            {
                                index++;
                                continue;
                            }
                            else
                            {
                                //Source_Txt.CloseText();
                                return false;
                            }
                        }
                        else
                        {
                            //Source_Txt.ShowParseError(lngRPM.s_File.s + ":" + FileName + "\n" + lngRPM.s_Comma_is_missing_to_separate_cells_column_name_from_cell_value_in_line.s + ":" + Source_Txt.iLine.ToString(), lngRPM.s_Error.s, MessageBoxButtons.OK, MessageBoxIcon.Error);
                            MessageBox.Show(lngRPM.s_File.s + lngRPM.s_Comma_is_missing_to_separate_cells_column_name_from_cell_value_in_line.s, lngRPM.s_Error.s, MessageBoxButtons.OK, MessageBoxIcon.Error);
                            //Source_Txt.CloseText();
                            return false;
                        }
                    }
                }
                else
                {
                    iTableNameStart = sLine.IndexOf('<');
                    iTableNameEnd = sLine.IndexOf('>');
                    if ((iTableNameStart != -1) && (iTableNameEnd != -1) && (iTableNameEnd > iTableNameStart))
                    {
                        string sTableName = sLine.Substring(iTableNameStart + 1, iTableNameEnd - iTableNameStart - 1);
                        sTableName = sTableName.TrimStart(trimChars);
                        sTableName = sTableName.TrimEnd(trimChars);
                        if (Globals.FindTable(out refsqlTbl, sTableName, dbTables.items))
                        {
                            sqlTbl = new SQLTable(refsqlTbl);
                            sqlTbl.CreateTableTree(dbTables.items);
                            index++;
                            continue;
                        }
                        else
                        {
                            //Source_Txt.ShowParseError(lngRPM.s_TableNameIsExpectedToBeBeforeDataLines.s, lngRPM.s_Error.s, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                            MessageBox.Show(lngRPM.s_TableNameIsExpectedToBeBeforeDataLines.s, lngRPM.s_Error.s, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                            return false;
                        }

                    }
                    else
                    {
                        //Source_Txt.ShowParseError(lngRPM.s_TableNameIsExpectedToBeBeforeDataLines.s, lngRPM.s_Error.s, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        MessageBox.Show(lngRPM.s_TableNameIsExpectedToBeBeforeDataLines.s, lngRPM.s_Error.s, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        return false;
                    }
                }

                index++;
            }
            //Source_Txt.CloseText();
            //  Structures are filled now create SQL statements
            return true;
        }
Exemplo n.º 29
0
        public CreateView_Form(DBTableControl dbTables, SQLTable tbl, TableDockingForm dtF, NavigationButtons.Navigation xnav)
        {
            nav = xnav;
            this.Visible = false;
            bFormCreated = false;
            m_TableDockingForm = dtF;
            m_DBTables = dbTables;
            m_tbl = tbl;
            this.Icon=Properties.Resources.DataView_FormIcon;
            InitializeComponent();
            nmUpDn_Limit.Minimum = 0;
            nmUpDn_Limit.Maximum = 1000000000;
            chk_Limit.Checked = Properties.Settings.Default.bLimit;
            nmUpDn_Limit.Value = Convert.ToDecimal(Properties.Settings.Default.iLimitNumber);
            chk_Descending.Checked = Properties.Settings.Default.b_order_by_ID_desc;

            this.flowLayoutPanel1.Tag = 1;
            this.flowLayoutPanel1.FlowDirection = FlowDirection.LeftToRight;
            this.flowLayoutPanel2.Tag = 2;
            this.flowLayoutPanel2.FlowDirection = FlowDirection.TopDown;

            PictureBox pictureBox_MoveRight = new PictureBox();
            pictureBox_MoveRight.Image = Properties.Resources.MoveRightIcon.ToBitmap();
            pictureBox_MoveRight.Parent = this;
            pictureBox_MoveRight.Left = flowLayoutPanel2.Left + flowLayoutPanel2.Width + 3;
            pictureBox_MoveRight.Top = flowLayoutPanel2.Top + flowLayoutPanel2.Height / 4;
            pictureBox_MoveRight.Width = pictureBox_MoveRight.Image.Size.Width + 6;
            pictureBox_MoveRight.Height = pictureBox_MoveRight.Image.Size.Height + 6;
            pictureBox_MoveRight.Visible = true;
            //pictureBox_MoveRight.Anchor = AnchorStyles.Top | AnchorStyles.Bottom;

            PictureBox pictureBox_MoveLeft = new PictureBox();
            pictureBox_MoveLeft.Image = Properties.Resources.MoveLeftIcon.ToBitmap();
            pictureBox_MoveLeft.Parent = this;
            pictureBox_MoveLeft.Left = flowLayoutPanel2.Left + flowLayoutPanel2.Width + 3;
            pictureBox_MoveLeft.Top = flowLayoutPanel2.Top + flowLayoutPanel2.Height/4 + 30;
            pictureBox_MoveLeft.Width = pictureBox_MoveLeft.Image.Size.Width + 6;
            pictureBox_MoveLeft.Height = pictureBox_MoveLeft.Image.Size.Height + 6;
            pictureBox_MoveLeft.Visible = true;
            //pictureBox_MoveLeft.Anchor = AnchorStyles.Top | AnchorStyles.Bottom;
            //this.pictureBox2.Image = Properties.Resources.MoveLeftIcon.ToBitmap();

            this.flowLayoutPanel1.DragEnter += new DragEventHandler(flowLayoutPanel1_DragEnter);
            this.flowLayoutPanel1.DragDrop += new DragEventHandler(flowLayoutPanel1_DragDrop);
            this.flowLayoutPanel2.DragEnter += new DragEventHandler(flowLayoutPanel1_DragEnter);
            this.flowLayoutPanel2.DragDrop += new DragEventHandler(flowLayoutPanel1_DragDrop);

            if (!bFormCreated)
            {

                int iCtrl = 1;
                m_pTableDockingFormXml = m_DBTables.m_xml.GetTableDockingFormXml(m_tbl.TableName);
                if (m_pTableDockingFormXml == null)
                {
                    m_pTableDockingFormXml = m_DBTables.m_xml.Create_pTableDockingFormXml(m_tbl.TableName);
                    m_DBTables.m_xml.m_xmldata.Add(m_pTableDockingFormXml);
                }
                if (m_pTableDockingFormXml.m_CreateViewFormXml == null)
                {
                    m_pTableDockingFormXml.Create_pCreateViewFormXml();
                }

                m_pTableDockingFormXml.m_CreateViewFormXml.wrect.SetFormPlacement(this);

                // Create DefineView_InputControls with no binding to xml data !
                m_tbl.Create_DefineView_InputControls(null, "", ref m_tbl.DefineView_inpCtrlList, this, this, ref iCtrl);

                //this.DynamicCreateControls(m_DBTables.m_xml.GetCreateViewFormDefaultView(m_tbl.TableName));

                this.DynamicCreateControls(m_pTableDockingFormXml.m_CreateViewFormXml.m_DefaultViewXml);

                bFormCreated = true;
            }
            this.Text = lngRPM.s_DataView_Form.s + m_tbl.lngTableName.s + " (" + m_tbl.TableName + ")";
            tsmi_CreateNew.Text = lngRPM.s_CreateNewView.s;
            tsmi_Select_View.Text = lngRPM.s_SelectView.s;
            tsmi_DeleteView.Text = lngRPM.s_DeleteView.s;
            tsmi_Save.Text =  lngRPM.s_Save.s;
            tsmi_Show.Text = lngRPM.s_Show.s;
            label_PrimaryView.Text = lngRPM.s_PrimaryView.s;
            chk_Limit.Text = lngRPM.s_Limit.s;
            chk_Descending.Text = lngRPM.s_Descending.s;
            grb_ShowLimits.Text = lngRPM.s_View.s;
        }
Exemplo n.º 30
0
        /// <summary>
        /// Create test form
        /// </summary>
        /// <param name="identifier">form identifier</param>
        /// <returns>test form</returns>
        /// 
        private static Form CreateDockForm(Guid identifier, DBTableControl dbTables, SQLTable x_tbl, TableDockingForm pParentForm, wRect wrect, ViewXml xViewXml,NavigationButtons.Navigation xnav)
        {
            if (identifier == new Guid(guid.gDocking_TableGrid_Form.ToByteArray()))
            {
                DataTable_Form result = new DataTable_Form(dbTables, x_tbl, DataTable_Form.DataTable_Form_ENUM.EDIT_OR_DELETE, pParentForm);
                result.Bounds = new Rectangle(wrect.Left, wrect.Top, wrect.Width, wrect.Height);
                return result;
            }
            else if (identifier == new Guid(guid.gDocking_EditTable_Form.ToByteArray()))
            {
                EditTable_Form result = new EditTable_Form(dbTables, x_tbl, pParentForm,SetControls,false,xnav);
                result.Bounds = new Rectangle(wrect.Left, wrect.Top, wrect.Width, wrect.Height);
                return result;
            }
            else if (identifier == new Guid(guid.gDocking_CreateView_Form.ToByteArray()))
            {
                CreateView_Form result = new CreateView_Form(dbTables, x_tbl, pParentForm, xnav);
                result.Bounds = new Rectangle(wrect.Left, wrect.Top, wrect.Width, wrect.Height);
                return result;
            }
            else
            {
                for (int i = 0; i < guid.MaxTableViews; i++)
                {
                    if (identifier == new Guid(guid.gDocking_TableView_Form[i].ToByteArray()))
                    {
                        TableView_Form result = new TableView_Form(i, dbTables, x_tbl, pParentForm, xViewXml);
                        result.Bounds = new Rectangle(wrect.Left, wrect.Top, wrect.Width, wrect.Height);
                        return result;
                    }
                }
            }

            throw new InvalidOperationException();
        }