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);
 }
 bool myGroupBox_RowReferenceFromTable_Check_NoChangeToOther(SQLTable pSQL_Table, List<usrc_RowReferencedFromTable> usrc_RowReferencedFromTable_List, ID_v id_v, ref bool bCancelDialog, ref ltext Instruction)
 {
     if (pParentTable != null)
     {
         return pParentTable.myGroupBox.SetEvent_RowReferenceFromTable_Check_NoChangeToOther(pSQL_Table, usrc_RowReferencedFromTable_List, id_v, ref bCancelDialog, ref Instruction);
     }
     else
     {
         bCancelDialog = false;
         return false;
     }
 }
예제 #3
0
        internal static bool Get(PostAddress_v address_v, ref ID_v cAdressOrg_iD_v)
        {
            string Err = null;
            long_v cStreetName_Person_ID_v = null;
            long_v cHouseNumber_Person_ID_v = null;
            long_v cCity_Person_ID_v = null;
            long_v cZIP_Person_ID_v = null;
            long_v cCountry_Person_ID_v = null;
            long_v cState_Person_ID_v = null;

            if (f_cStreetName_Person.Get(address_v.StreetName_v, ref cStreetName_Person_ID_v))
            {
                if (f_cHouseNumber_Person.Get(address_v.HouseNumber_v, ref cHouseNumber_Person_ID_v))
                {
                    if (f_cCity_Person.Get(address_v.City_v, ref cCity_Person_ID_v))
                    {
                        if (f_cZIP_Person.Get(address_v.ZIP_v, ref cZIP_Person_ID_v))
                        {
                            if (f_cCountry_Person.Get(address_v.Country_v,
                                                      address_v.Country_ISO_3166_a2_v,
                                                      address_v.Country_ISO_3166_a3_v,
                                                      address_v.Country_ISO_3166_num_v,
                                                      ref cCountry_Person_ID_v))
                            {
                                List<SQL_Parameter> lpar = new List<SQL_Parameter>();

                                string scond_cStreetName_Person_ID_v = " cStreetName_Person_ID is null ";
                                string sval_cStreetName_Person_ID_v = "null";

                                if (cStreetName_Person_ID_v != null)
                                {
                                    string spar_cStreetName_Person_ID_v = "@par_cStreetName_Person_ID_v";
                                    SQL_Parameter par_cStreetName_Person_ID_v = new SQL_Parameter(spar_cStreetName_Person_ID_v, SQL_Parameter.eSQL_Parameter.Bigint, false, cStreetName_Person_ID_v.v);
                                    lpar.Add(par_cStreetName_Person_ID_v);
                                    scond_cStreetName_Person_ID_v = " cStreetName_Person_ID = " + spar_cStreetName_Person_ID_v;
                                    sval_cStreetName_Person_ID_v = spar_cStreetName_Person_ID_v;
                                }

                                string scond_cHouseNumber_Person_ID_v = " cHouseNumber_Person_ID is null ";
                                string sval_cHouseNumber_Person_ID_v = "null";
                                if (cHouseNumber_Person_ID_v != null)
                                {
                                    string spar_cHouseNumber_Person_ID_v = "@par_cHouseNumber_Person_ID_v";
                                    SQL_Parameter par_cHouseNumber_Person_ID_v = new SQL_Parameter(spar_cHouseNumber_Person_ID_v, SQL_Parameter.eSQL_Parameter.Bigint, false, cHouseNumber_Person_ID_v.v);
                                    lpar.Add(par_cHouseNumber_Person_ID_v);
                                    scond_cHouseNumber_Person_ID_v = " cHouseNumber_Person_ID = " + spar_cHouseNumber_Person_ID_v;
                                    sval_cHouseNumber_Person_ID_v = spar_cHouseNumber_Person_ID_v;
                                }

                                string scond_cCity_Person_ID_v = " cCity_Person_ID is null ";
                                string sval_cCity_Person_ID_v = "null";
                                if (cCity_Person_ID_v != null)
                                {
                                    string spar_cCity_Person_ID_v = "@par_cCity_Person_ID_v";
                                    SQL_Parameter par_cCity_Person_ID_v = new SQL_Parameter(spar_cCity_Person_ID_v, SQL_Parameter.eSQL_Parameter.Bigint, false, cCity_Person_ID_v.v);
                                    lpar.Add(par_cCity_Person_ID_v);
                                    scond_cCity_Person_ID_v = " cCity_Person_ID = " + spar_cCity_Person_ID_v;
                                    sval_cCity_Person_ID_v = spar_cCity_Person_ID_v;
                                }

                                string scond_cZIP_Person_ID_v = " cZIP_Person_ID is null ";
                                string sval_cZIP_Person_ID_v = "null";
                                if (cZIP_Person_ID_v != null)
                                {
                                    string spar_cZIP_Person_ID_v = "@par_cZIP_Person_ID_v";
                                    SQL_Parameter par_cZIP_Person_ID_v = new SQL_Parameter(spar_cZIP_Person_ID_v, SQL_Parameter.eSQL_Parameter.Bigint, false, cZIP_Person_ID_v.v);
                                    lpar.Add(par_cZIP_Person_ID_v);
                                    scond_cZIP_Person_ID_v = " cZIP_Person_ID = " + spar_cZIP_Person_ID_v;
                                    sval_cZIP_Person_ID_v = spar_cZIP_Person_ID_v;
                                }

                                string scond_cCountry_Person_ID_v = " cCountry_Person_ID is null ";
                                string sval_cCountry_Person_ID_v = "null";
                                if (cCountry_Person_ID_v != null)
                                {
                                    string spar_cCountry_Person_ID_v = "@par_cCountry_Person_ID_v";
                                    SQL_Parameter par_cCountry_Person_ID_v = new SQL_Parameter(spar_cCountry_Person_ID_v, SQL_Parameter.eSQL_Parameter.Bigint, false, cCountry_Person_ID_v.v);
                                    lpar.Add(par_cCountry_Person_ID_v);
                                    scond_cCountry_Person_ID_v = " cCountry_Person_ID = " + spar_cCountry_Person_ID_v;
                                    sval_cCountry_Person_ID_v = spar_cCountry_Person_ID_v;
                                }

                                string scond_cState_Person_ID_v = " cState_Person_ID is null ";
                                string sval_cState_Person_ID_v = "null";
                                if (cState_Person_ID_v != null)
                                {
                                    string spar_cState_Person_ID_v = "@par_cState_Person_ID_v";
                                    SQL_Parameter par_cState_Person_ID_v = new SQL_Parameter(spar_cState_Person_ID_v, SQL_Parameter.eSQL_Parameter.Bigint, false, cState_Person_ID_v.v);
                                    lpar.Add(par_cState_Person_ID_v);
                                    scond_cState_Person_ID_v = " cState_Person_ID = " + spar_cState_Person_ID_v;
                                    sval_cState_Person_ID_v = spar_cState_Person_ID_v;
                                }
                                string sql = "select ID from cAddress_Person where " + scond_cStreetName_Person_ID_v + " and "
                                                                                       + scond_cHouseNumber_Person_ID_v + " and "
                                                                                       + scond_cCity_Person_ID_v + " and "
                                                                                       + scond_cZIP_Person_ID_v + " and "
                                                                                       + scond_cCountry_Person_ID_v + " and "
                                                                                       + scond_cState_Person_ID_v;

                                DataTable dt = new DataTable();
                                if (DBSync.DBSync.ReadDataTable(ref dt, sql, lpar, ref Err))
                                {
                                    if (dt.Rows.Count > 0)
                                    {
                                        if (cAdressOrg_iD_v == null)
                                        {
                                            cAdressOrg_iD_v = new ID_v();
                                        }
                                        cAdressOrg_iD_v.v = (long)dt.Rows[0]["ID"];
                                        return true;
                                    }
                                    else
                                    {
                                        sql = "insert into cAddress_Person (cStreetName_Person_ID,cHouseNumber_Person_ID,cCity_Person_ID,cZIP_Person_ID,cCountry_Person_ID,cState_Person_ID) values ("
                                                + sval_cStreetName_Person_ID_v + ","
                                                + sval_cHouseNumber_Person_ID_v + ","
                                                + sval_cCity_Person_ID_v + ","
                                                + sval_cZIP_Person_ID_v + ","
                                                + sval_cCountry_Person_ID_v + ","
                                                + sval_cState_Person_ID_v + ")";
                                        long cAddress_Person_ID = -1;
                                        object oret = null;
                                        if (DBSync.DBSync.ExecuteNonQuerySQLReturnID(sql, lpar, ref cAddress_Person_ID, ref oret, ref Err, "cAddress_Person"))
                                        {
                                            if (cAdressOrg_iD_v == null)
                                            {
                                                cAdressOrg_iD_v = new ID_v();
                                            }
                                            cAdressOrg_iD_v.v = cAddress_Person_ID;
                                            return true;
                                        }
                                        else
                                        {
                                            LogFile.Error.Show("ERROR:ShopA_dbfunc:dbfunc:get(ItemShopA m_ItemShopA, ref long atom_ItemShopA_ID) sql=" + sql + "\r\nErr=" + Err);
                                            return false;
                                        }
                                    }
                                }
                                else
                                {
                                    LogFile.Error.Show("ERROR:ShopA_dbfunc:dbfunc:get(ItemShopA m_ItemShopA, ref long atom_ItemShopA_ID) sql=" + sql + "\r\nErr=" + Err);
                                    return false;
                                }
                            }
                        }
                    }
                }
            }
            return false;
        }
예제 #4
0
        //string_v StreetName_v = tf.set_string(Address.StreetName);
        //string_v HouseNumber_v = tf.set_string(Address.HouseNumber);
        //string_v ZIP_v = tf.set_string(Address.ZIP);
        //string_v City_v = tf.set_string(Address.City);
        //string_v Country_v = tf.set_string(Address.Country);
        //string_v State_v = tf.set_string(Address.State);
        //string_v PhoneNumber_v = tf.set_string(PhoneNumber);
        //string_v FaxNumber_v = tf.set_string(FaxNumber);
        //string_v Email_v = tf.set_string(Email);
        //string_v HomePage_v = tf.set_string(HomePage);
        //string_v Logo_Hash_v = tf.set_string(Logo_Hash);
        //byte_array_v Logo_Image_Data_v = tf.set_byte_array(Logo);
        //string_v Logo_Description_v = tf.set_string(Logo_Description);
        public static bool Get( string_v Organisation_Name_v,
                                string_v Tax_ID_v,
                                string_v Registration_ID_v,
                                string_v OrganisationTYPE_v,
                                PostAddress_v Address_v,
                                string_v PhoneNumber_v,
                                string_v FaxNumber_v,
                                string_v Email_v,
                                string_v HomePage_v,
                                string_v BankName_v,
                                string_v TRR_v,
                                string_v Logo_Hash_v,
                                byte_array_v Logo_Image_Data_v,
                                string_v Logo_Description_v,
                                ref ID_v iD_v)
        {
            string Err = null;
            long_v Atom_Organisation_ID_v = null;
            long_v Atom_OrganisationData_ID_v = null;

            if (f_Atom_Organisation.Get( Organisation_Name_v,
                                Tax_ID_v,
                                Registration_ID_v,
                                OrganisationTYPE_v,
                                Address_v,
                                PhoneNumber_v,
                                FaxNumber_v,
                                Email_v,
                                HomePage_v,
                                BankName_v,
                                TRR_v,
                                Logo_Hash_v,
                                Logo_Image_Data_v,
                                Logo_Description_v,
                                ref Atom_Organisation_ID_v,
                                ref Atom_OrganisationData_ID_v
                                ))
            {
                DataTable dt = new DataTable();
                string sql_select = "select ID from Atom_myOrganisation where Atom_OrganisationData_ID = " + Atom_OrganisationData_ID_v.v.ToString();
                if (DBSync.DBSync.ReadDataTable(ref dt, sql_select, null, ref Err))
                {
                    if (dt.Rows.Count > 0)
                    {
                        if (iD_v == null)
                        {
                            iD_v = new ID_v();
                        }
                        iD_v.v = (long)dt.Rows[0]["ID"];
                        return true;
                    }
                    else
                    {
                        long Atom_myOrganisation_id = -1;
                        string sql_insert = " insert into Atom_myOrganisation  (Atom_OrganisationData_ID) values (" + Atom_OrganisationData_ID_v.v.ToString() + ")";
                        object oret = null;
                        if (DBSync.DBSync.ExecuteNonQuerySQLReturnID(sql_insert, null, ref Atom_myOrganisation_id, ref oret, ref Err, "Atom_myOrganisation"))
                        {
                            if (iD_v == null)
                            {
                                iD_v = new ID_v();
                            }
                            iD_v.v = Atom_myOrganisation_id;
                            return true;
                        }
                        else
                        {
                            LogFile.Error.Show("ERROR:Insert_Atom_myOrganisation:sql_insert:Err=" + Err);
                            return false;
                        }
                    }
                }
                else
                {
                    LogFile.Error.Show("ERROR:myOrg:Insert_Atom_myOrganisation:sql_select=" + sql_select + "\r\nErr=" + Err);
                    return false;
                }
            }
            else
            {
                return false;
            }
        }
예제 #5
0
        public static bool Get(long Organisation_ID,
                                string_v OrganisationTYPE_v,
                                PostAddress_v Address_v,
                                string_v PhoneNumber_v,
                                string_v FaxNumber_v,
                                string_v Email_v,
                                string_v HomePage_v,
                                string_v Logo_Hash_v,
                                byte_array_v Image_Data_v,
                                string_v Logo_Description_v,
                                ref ID_v cAdressAtom_Org_iD_v,
                                ref long_v OrganisationData_ID_v)
        {
            string Err = null;

            //  long_v Atom_Organisation_ID_v = null;
            long_v OrganisationTYPE_ID_v = null;
            if (f_cOrgTYPE.Get(OrganisationTYPE_v, ref OrganisationTYPE_ID_v))
            {
                if (f_cAddress_Org.Get(Address_v, ref cAdressAtom_Org_iD_v))
                {
                    ID_v cHomePage_Org_ID_v = null;
                    string cHomePage_Org_ID_v_cond = "cHomePage_Org_ID is null";
                    string cHomePage_Org_ID_v_Value = "null";

                    if (fs.Get_ID("cHomePage_Org", "HomePage", HomePage_v, ref cHomePage_Org_ID_v, ref Err))
                    {
                        if (cHomePage_Org_ID_v != null)
                        {
                            cHomePage_Org_ID_v_Value = cHomePage_Org_ID_v.v.ToString();
                            cHomePage_Org_ID_v_cond = "cHomePage_Org_ID = " + cHomePage_Org_ID_v_Value;
                        }
                    }

                    ID_v cEmail_Org_ID_v = null;
                    string cEmail_Org_ID_v_cond = "cEmail_Org_ID is null";
                    string cEmail_Org_ID_v_Value = "null";

                    if (fs.Get_ID("cEmail_Org", "Email", Email_v, ref cEmail_Org_ID_v, ref Err))
                    {
                        if (cEmail_Org_ID_v != null)
                        {
                            cEmail_Org_ID_v_Value = cEmail_Org_ID_v.v.ToString();
                            cEmail_Org_ID_v_cond = "cEmail_Org_ID = " + cEmail_Org_ID_v_Value;
                        }
                    }

                    ID_v cPhoneNumber_Org_ID_v = null;
                    string cPhoneNumber_Org_ID_v_cond = "cPhoneNumber_Org_ID is null";
                    string cPhoneNumber_Org_ID_v_Value = "null";

                    if (fs.Get_ID("cPhoneNumber_Org", "PhoneNumber", PhoneNumber_v, ref cPhoneNumber_Org_ID_v, ref Err))
                    {
                        if (cPhoneNumber_Org_ID_v != null)
                        {
                            cPhoneNumber_Org_ID_v_Value = cPhoneNumber_Org_ID_v.v.ToString();
                            cPhoneNumber_Org_ID_v_cond = "cPhoneNumber_Org_ID = " + cPhoneNumber_Org_ID_v_Value;
                        }
                    }

                    ID_v cFaxNumber_Org_ID_v = null;
                    string cFaxNumber_Org_ID_v_cond = "cFaxNumber_Org_ID is null";
                    string cFaxNumber_Org_ID_v_Value = "null";

                    if (fs.Get_ID("cFaxNumber_Org", "FaxNumber", FaxNumber_v, ref cFaxNumber_Org_ID_v, ref Err))
                    {
                        if (cFaxNumber_Org_ID_v != null)
                        {
                            cFaxNumber_Org_ID_v_Value = cFaxNumber_Org_ID_v.v.ToString();
                            cFaxNumber_Org_ID_v_cond = "cFaxNumber_Org_ID = " + cFaxNumber_Org_ID_v_Value;
                        }
                    }

                    long_v Logo_ID_v = null;
                    string Logo_ID_cond = "Logo_ID is null";
                    string Logo_ID_Value = "null";
                    // = null;
                    //if (Logo != null)
                    //{
                    //    Image_Data_v = new byte_array_v();
                    //    Image_Data_v.v = DBtypesFunc.imageToByteArray(Logo, Logo.RawFormat);
                    //}
                    if (f_Logo.Get(Logo_Hash_v, Image_Data_v, Logo_Description_v, ref Logo_ID_v))
                    {
                        if (Logo_ID_v != null)
                        {
                            Logo_ID_Value = Logo_ID_v.v.ToString();
                            Logo_ID_cond = "Logo_ID = " + Logo_ID_Value;
                        }
                    }

                    List<SQL_Parameter> lpar = new List<SQL_Parameter>();
                    //if (BankName_v != null)
                    //{
                    //    BankName_Value = "@par_BankName";
                    //    SQL_Parameter par_BankName = new SQL_Parameter(BankName_Value, SQL_Parameter.eSQL_Parameter.Nvarchar, false, BankName_v.v);
                    //    lpar.Add(par_BankName);
                    //    BankName_condition = " BankName = " + par_BankName.Name + " ";
                    //}
                    //else
                    //{
                    //    BankName_condition = " BankName is null ";
                    //    BankName_Value = "null";
                    //}

                    //if (TRR_v != null)
                    //{
                    //    TRR_Value = "@par_TRR";
                    //    SQL_Parameter par_TRR = new SQL_Parameter(TRR_Value, SQL_Parameter.eSQL_Parameter.Nvarchar, false, TRR_v.v);
                    //    lpar.Add(par_TRR);
                    //    TRR_condition = " TRR = " + par_TRR.Name + " ";
                    //}
                    //else
                    //{
                    //    TRR_condition = " TRR is null ";
                    //    TRR_Value = "null";
                    //}

                    string cOrgTYPE_ID_condition = null;
                    string cOrgTYPE_ID_value = null;
                    if (OrganisationTYPE_ID_v != null)
                    {
                        cOrgTYPE_ID_condition = " cOrgTYPE_ID = " + cAdressAtom_Org_iD_v.v.ToString();
                        cOrgTYPE_ID_value = cAdressAtom_Org_iD_v.v.ToString();
                    }
                    else
                    {
                        cOrgTYPE_ID_condition = " cOrgTYPE_ID is null ";
                        cOrgTYPE_ID_value = "null";
                    }
                    string cAddress_Org_ID_condition = null;
                    if (cAdressAtom_Org_iD_v != null)
                    {
                        cAddress_Org_ID_condition = " cAddress_Org_ID = " + cAdressAtom_Org_iD_v.v.ToString();
                    }
                    else
                    {
                        cAddress_Org_ID_condition = " cAddress_Org_ID is null ";
                    }

                    string sql_select = "select ID from OrganisationData where Organisation_ID =" + Organisation_ID.ToString() + @" and
                                                                                    " + cOrgTYPE_ID_condition + @" and
                                                                                    " + cAddress_Org_ID_condition + @" and
                                                                                    " + cHomePage_Org_ID_v_cond + @" and
                                                                                    " + cEmail_Org_ID_v_cond + @" and
                                                                                    " + cPhoneNumber_Org_ID_v_cond + @" and
                                                                                    " + cFaxNumber_Org_ID_v_cond + @" and
                                                                                    " + Logo_ID_cond;
                    DataTable dt = new DataTable();
                    if (DBSync.DBSync.ReadDataTable(ref dt, sql_select, lpar, ref Err))
                    {
                        if (dt.Rows.Count > 0)
                        {
                            if (OrganisationData_ID_v == null)
                            {
                                OrganisationData_ID_v = new long_v();
                            }
                            OrganisationData_ID_v.v = (long)dt.Rows[0]["ID"];
                            return true;
                        }
                        else
                        {
                            string sql_insert = @"insert into OrganisationData (Organisation_ID,cOrgTYPE_ID,cAddress_Org_ID,cHomePage_Org_ID,cEmail_Org_ID,cPhoneNumber_Org_ID,cFaxNumber_Org_ID,Logo_ID) values (
                                                                                    " + Organisation_ID.ToString() + @",
                                                                                    " + cOrgTYPE_ID_value + @",
                                                                                    " + cAdressAtom_Org_iD_v.v.ToString() + @",
                                                                                    " + cHomePage_Org_ID_v_Value + @",
                                                                                    " + cEmail_Org_ID_v_Value + @",
                                                                                    " + cPhoneNumber_Org_ID_v_Value + @",
                                                                                    " + cFaxNumber_Org_ID_v_Value + @",
                                                                                    " + Logo_ID_Value + ")";
                            object oret = null;
                            long OrganisationData_ID = -1;
                            if (DBSync.DBSync.ExecuteNonQuerySQLReturnID(sql_insert, lpar, ref OrganisationData_ID, ref oret, ref Err, "OrganisationData"))
                            {
                                if (OrganisationData_ID_v == null)
                                {
                                    OrganisationData_ID_v = new long_v();
                                }
                                OrganisationData_ID_v.v = OrganisationData_ID;
                                return true;
                            }
                            else
                            {
                                LogFile.Error.Show("ERROR:f_OrganisationData:Get:sql=" + sql_insert + "\r\nErr=" + Err);
                            }
                        }
                    }
                    else
                    {
                        LogFile.Error.Show("ERROR:f_OrganisationData:Get:sql=" + sql_select + "\r\nErr=" + Err);
                    }
                }
            }
            return false;
        }
예제 #6
0
        private bool GetAddressElementID(string AddressElement_TableName, string AddressElement_ColumnName, object oValue, ref ID_v iD_v)
        {
            string Err = null;
            DataTable dt = new DataTable();
            List<SQL_Parameter> lpar = new List<SQL_Parameter>();
            string sql = null;
            string sparname = "@par_" + AddressElement_TableName + "_" + AddressElement_ColumnName;
            if (oValue != null)
            {
                SQL_Parameter par = null;
                if (oValue is string)
                {
                    par = new SQL_Parameter(sparname, SQL_Parameter.eSQL_Parameter.Nvarchar, false, ((string)oValue));
                }
                else if (oValue is short)
                {
                    par = new SQL_Parameter(sparname, SQL_Parameter.eSQL_Parameter.Smallint, false, ((short)oValue));
                }
                else
                {
                    LogFile.Error.Show("ERROR:Address:GetAddressElementID:Err=type=" + oValue.GetType().ToString() + " not implemented!");
                }

                lpar.Add(par);
                sql = "select ID from " + AddressElement_TableName + " where " + AddressElement_ColumnName + " = " + sparname;
            }
            else
            {
                iD_v = null;
                return true;
            }

            if (DBSync.DBSync.ReadDataTable(ref dt, sql, lpar, ref Err))
            {
                if (dt.Rows.Count > 0)
                {
                    if (iD_v == null)
                    {
                        iD_v = new ID_v();
                    }
                    iD_v.v = (long)dt.Rows[0]["ID"];
                    return true;
                }
                else
                {
                    // insert
                    sql = "insert into " + AddressElement_TableName + "(" + AddressElement_ColumnName + ") values (" + sparname + ")";
                    long id = -1;
                    object oret = new object();
                    if (DBSync.DBSync.ExecuteNonQuerySQLReturnID(sql, lpar, ref id, ref oret, ref Err, AddressElement_TableName))
                    {
                        if (iD_v == null)
                        {
                            iD_v = new ID_v();
                        }
                        iD_v.v = id;
                        return true;
                    }
                    else
                    {
                        LogFile.Error.Show("ERROR:PostAddress:GetAddressElementID:sql=" + sql + "\r\n" + Err);
                        return false;
                    }
                }
            }
            else
            {
                LogFile.Error.Show("ERROR:PostAddress:GetAddressElementID:" + sql + "\r\n" + Err);
                return false;
            }
        }
예제 #7
0
        private bool GetAddressElementID(string AddressElement_TableName, string[] AddressElement_ColumnNames, object[] oValues, ref ID_v iD_v)
        {
            string Err = null;
            DataTable dt = new DataTable();
            List<SQL_Parameter> lpar = new List<SQL_Parameter>();
            string sql = null;
            string sql_Condtition = null;
            string sql_insert_Columns = null;
            string sql_insert_Values = null;

            if (AddressElement_ColumnNames.Length != oValues.Length)
            {
            LogFile.Error.Show("ERROR:Adress:GetAddressElementID:(AddressElement_ColumnNames.Length != oValues.Length)!");
            return false;
            }
            int i;
            string sql_pref = "select ID from " + AddressElement_TableName + " where ";
            for (i = 0; i < AddressElement_ColumnNames.Length; i++)
            {
            string sparname = "@par_" + AddressElement_TableName + "_" + AddressElement_ColumnNames[i];
            object oValue = oValues[i];
            if (oValue != null)
            {
                SQL_Parameter par = null;
                if (oValue is string)
                {
                    par = new SQL_Parameter(sparname, SQL_Parameter.eSQL_Parameter.Nvarchar, false, ((string)oValue));
                    lpar.Add(par);
                }
                else if (oValue is short)
                {
                    par = new SQL_Parameter(sparname, SQL_Parameter.eSQL_Parameter.Smallint, false, ((short)oValue));
                    lpar.Add(par);

                }
                else
                {
                    LogFile.Error.Show("ERROR:Address:GetAddressElementID:Err=type=" + oValue.GetType().ToString() + " not implemented!");
                    return false;
                }

                if (sql_Condtition == null)
                {
                    sql_Condtition = " (" + AddressElement_ColumnNames[i] + " = " + sparname + ") ";
                }
                else
                {
                    sql_Condtition += " and (" + AddressElement_ColumnNames[i] + " = " + sparname + ")";
                }

                if (sql_insert_Columns == null)
                {
                    sql_insert_Columns = AddressElement_ColumnNames[i];
                    sql_insert_Values = sparname;
                }
                else
                {
                    sql_insert_Columns += "," + AddressElement_ColumnNames[i];
                    sql_insert_Values += "," + sparname;
                }
            }
            else
            {
                iD_v = null;
                return true;
            }
            }

            if (sql_Condtition != null)
            {
            if (sql_Condtition.Length >0)
            {
                sql = sql_pref + sql_Condtition;
                if (DBSync.DBSync.ReadDataTable(ref dt, sql, lpar, ref Err))
                {
                    if (dt.Rows.Count > 0)
                    {
                        if (iD_v == null)
                        {
                            iD_v = new ID_v();
                        }
                        iD_v.v = (long)dt.Rows[0]["ID"];
                        return true;
                    }
                    else
                    {
                        // insert
                        sql = "insert into " + AddressElement_TableName + "(" + sql_insert_Columns + ") values (" + sql_insert_Values + ")";
                        long id = -1;
                        object oret = new object();
                        if (DBSync.DBSync.ExecuteNonQuerySQLReturnID(sql, lpar, ref id, ref oret, ref Err, AddressElement_TableName))
                        {
                            if (iD_v == null)
                            {
                                iD_v = new ID_v();
                            }
                            iD_v.v = id;
                            return true;
                        }
                        else
                        {
                            LogFile.Error.Show("ERROR:PostAddress:GetAddressElementID:sql=" + sql + "\r\n" + Err);
                            return false;
                        }
                    }
                }
                else
                {
                    LogFile.Error.Show("ERROR:PostAddress:GetAddressElementID:" + sql + "\r\n" + Err);
                    return false;
                }
            }
            }
            LogFile.Error.Show("ERROR:PostAddress:GetAddressElementID:sql_Condtition not defined!");
            return false;
        }
예제 #8
0
        internal bool Get_Address_Tabel_ID(SQLTable Address_Tabel, ref ID_v iD_v)
        {
            string Err = null;
            string sql_select = "select ID from " + Address_Tabel.TableName + " where ";
            string sql_conditions = null;
            string sql_insert = "insert into " + Address_Tabel.TableName + "(";
            string sql_insert_columns = null;
            string sql_values = null;
            foreach (Column col in Address_Tabel.Column)
            {
                if (!col.IsIdentity)
                {
                    if (col.fKey != null)
                    {
                        if (col.fKey.fTable != null)
                        {
                            foreach (Column c in col.fKey.fTable.Column)
                            {
                                if (!c.IsIdentity)
                                {
                                    if (c.fKey == null)
                                    {
                                        if (c.Name.Equals("StreetName"))
                                        {
                                            if (!GetAddressElementID(col.fKey.fTable.TableName, c.Name, StreetName, ref col.fKey.reference_ID))
                                            {
                                                return false;
                                            }
                                        }
                                        else if (c.Name.Equals("HouseNumber"))
                                        {
                                            if (!GetAddressElementID(col.fKey.fTable.TableName, c.Name, HouseNumber, ref col.fKey.reference_ID))
                                            {
                                                return false;
                                            }
                                        }
                                        else if (c.Name.Equals("ZIP"))
                                        {
                                            if (!GetAddressElementID(col.fKey.fTable.TableName, c.Name, ZIP, ref col.fKey.reference_ID))
                                            {
                                                return false;
                                            }
                                        }
                                        else if (c.Name.Equals("City"))
                                        {
                                            if (!GetAddressElementID(col.fKey.fTable.TableName, c.Name, City, ref col.fKey.reference_ID))
                                            {
                                                return false;
                                            }
                                        }
                                        else if (c.Name.Equals("Country"))
                                        {
                                            string tbl_name = col.fKey.fTable.TableName;
                                            if (!GetAddressElementID(tbl_name, new string[] { "Country", "Country_ISO_3166_a2", "Country_ISO_3166_a3", "Country_ISO_3166_num" },
                                                                                                new object[] { Country, Country_ISO_3166_a2 , Country_ISO_3166_a3, Country_ISO_3166_num },
                                                                                                ref col.fKey.reference_ID))
                                            {
                                                return false;
                                            }
                                        }
                                        else if (c.Name.Equals("State"))
                                        {
                                            if (State_v != null)
                                            {
                                                if (!GetAddressElementID(col.fKey.fTable.TableName, c.Name, State, ref col.fKey.reference_ID))
                                                {
                                                    return false;
                                                }
                                            }
                                            else
                                            {
                                                col.fKey.reference_ID = null;
                                            }
                                        }
                                    }
                                }
                            }
                            string sql_condition = null;
                            if (col.fKey.reference_ID != null)
                            {
                                sql_condition = col.Name + " = " + col.fKey.reference_ID.v.ToString();
                            }
                            else
                            {
                                sql_condition = col.Name + " is null ";
                            }

                            if (sql_conditions == null)
                            {
                                sql_conditions = sql_condition;
                            }
                            else
                            {
                                sql_conditions += " and " + sql_condition;
                            }

                            if (sql_insert_columns == null)
                            {
                                sql_insert_columns = col.Name;
                            }
                            else
                            {
                                sql_insert_columns += "," + col.Name;
                            }

                            if (col.fKey.reference_ID != null)
                            {
                                if (sql_values == null)
                                {
                                    sql_values = col.fKey.reference_ID.v.ToString();
                                }
                                else
                                {
                                    sql_values += "," + col.fKey.reference_ID.v.ToString();
                                }
                            }
                            else
                            {
                                if (sql_values == null)
                                {
                                    sql_values = "null";
                                }
                                else
                                {
                                    sql_values += ",null";
                                }
                            }
                        }
                    }
                }
            }
            sql_select += sql_conditions;
            DataTable dt = new DataTable();
            if (DBSync.DBSync.ReadDataTable(ref dt, sql_select, null, ref Err))
            {
                if (dt.Rows.Count > 0)
                {
                    if (iD_v == null)
                    {
                        iD_v = new ID_v();
                    }
                    iD_v.v = (long)dt.Rows[0]["ID"];
                    return true;
                }
                else
                {
                    // insert
                    sql_insert += sql_insert_columns + ") Values (" + sql_values + ")";
                    long id = -1;
                    object oret = new object();
                    if (DBSync.DBSync.ExecuteNonQuerySQLReturnID(sql_insert, null, ref id, ref oret, ref Err, Address_Tabel.TableName))
                    {
                        if (iD_v == null)
                        {
                            iD_v = new ID_v();
                        }
                        iD_v.v = id;
                        return true;
                    }
                    else
                    {
                        LogFile.Error.Show("ERROR:PostAddress:Get_Address_Tabel_ID:" + sql_insert + "\r\n" + Err);
                        return false;
                    }
                }
            }
            else
            {
                LogFile.Error.Show("ERROR:PostAddress:Get_Address_Tabel_ID:" + sql_select + "\r\n" + Err);
                return false;
            }
        }
예제 #9
0
        public static bool Get(string_v Organisation_Name_v,
                                 string_v Tax_ID_v,
                                 string_v Registration_ID_v,
                                 string_v OrganisationTYPE_v,
                                 PostAddress_v Address_v,
                                 string_v PhoneNumber_v,
                                 string_v FaxNumber_v,
                                 string_v Email_v,
                                 string_v HomePage_v,
                                 long_v BankAccount_ID_v,
                                 string_v Organisation_BankAccount_Description_v,
                                 string_v Image_Hash_v,
                                 byte_array_v Image_Data_v,
                                 string_v Image_Description_v,
                                 ref ID_v cAdressAtom_Org_iD_v,
                                 ref long_v Organisation_ID_v,
                                 ref long_v OrganisationData_ID_v)
        {
            string Err = null;
            string Name_condition = null;
            string Tax_ID_condition = null;
            string Registration_ID_condition = null;

            string sName_value = null;
            string sTaxID_value = null;
            string sRegistration_ID_value = null;

            List<SQL_Parameter> lpar = new List<SQL_Parameter>();
            if (Organisation_Name_v != null)
            {
                SQL_Parameter par_Name = new SQL_Parameter("@par_Name", SQL_Parameter.eSQL_Parameter.Nvarchar, false, Organisation_Name_v.v);
                lpar.Add(par_Name);
                Name_condition = " Name = " + par_Name.Name + " ";
                sName_value = "@par_Name";
            }
            else
            {
                Name_condition = " Name is null ";
                sName_value = "null";
            }

            if (Tax_ID_v != null)
            {
                SQL_Parameter par_Tax_ID = new SQL_Parameter("@par_Tax_ID", SQL_Parameter.eSQL_Parameter.Nvarchar, false, Tax_ID_v.v);
                lpar.Add(par_Tax_ID);
                Tax_ID_condition = " Tax_ID = " + par_Tax_ID.Name + " ";
                sTaxID_value = "@par_Tax_ID";
            }
            else
            {
                Tax_ID_condition = " Tax_ID  is null ";
                sTaxID_value = "null";
            }
            if (Registration_ID_v != null)
            {
                SQL_Parameter par_Registration_ID = new SQL_Parameter("@par_Registration_ID", SQL_Parameter.eSQL_Parameter.Nvarchar, false, Registration_ID_v.v);
                lpar.Add(par_Registration_ID);
                Registration_ID_condition = " Registration_id = " + par_Registration_ID.Name + " ";
                sRegistration_ID_value = "@par_Registration_ID";
            }
            else
            {
                Registration_ID_condition = " Registration_ID is null ";
                sRegistration_ID_value = "null";
            }

            string sql_select = "select ID from Organisation where " + Name_condition + @" and
                                                                        " + Tax_ID_condition + @" and
                                                                        " + Registration_ID_condition;
            DataTable dt = new DataTable();
            if (DBSync.DBSync.ReadDataTable(ref dt, sql_select, lpar, ref Err))
            {
                if (dt.Rows.Count > 0)
                {
                    if (Organisation_ID_v == null)
                    {
                        Organisation_ID_v = new long_v();
                    }
                    Organisation_ID_v.v = (long)dt.Rows[0]["ID"];
                    return f_OrganisationData.Get(Organisation_ID_v.v,
                                                       OrganisationTYPE_v,
                                                       Address_v,
                                                       PhoneNumber_v,
                                                       FaxNumber_v,
                                                       Email_v,
                                                       HomePage_v,
                                                       Image_Hash_v,
                                                       Image_Data_v,
                                                       Image_Description_v,
                                                       ref cAdressAtom_Org_iD_v,
                                                       ref OrganisationData_ID_v);
                }
                else
                {
                    string sql_insert = " insert into Organisation  (Name,Tax_ID,Registration_ID) values (" + sName_value + "," + sTaxID_value + "," + sRegistration_ID_value + ")";
                    object oret = null;
                    long Organisation_ID = -1;
                    if (DBSync.DBSync.ExecuteNonQuerySQLReturnID(sql_insert, lpar, ref Organisation_ID, ref oret, ref Err, "Organisation"))
                    {
                        if (Organisation_ID_v == null)
                        {
                            Organisation_ID_v = new long_v();
                        }
                        Organisation_ID_v.v = Organisation_ID;
                        if (f_OrganisationData.Get(Organisation_ID_v.v,
                                                                               OrganisationTYPE_v,
                                                                               Address_v,
                                                                               PhoneNumber_v,
                                                                               FaxNumber_v,
                                                                               Email_v,
                                                                               HomePage_v,
                                                                               Image_Hash_v,
                                                                               Image_Data_v,
                                                                               Image_Description_v,
                                                                                ref cAdressAtom_Org_iD_v,
                                                                               ref OrganisationData_ID_v))
                        {

                            long_v OrganisationAccount_ID_v = null;
                            return f_OrganisationAccount.Get(BankAccount_ID_v,
                                                      Organisation_ID_v,
                                                      Organisation_BankAccount_Description_v,
                                                      ref OrganisationAccount_ID_v);
                        }
                        else
                        {
                            return false;
                        }
                    }
                    else
                    {
                        LogFile.Error.Show("ERROR:f_Organisation:Get:sql=" + sql_insert + "\r\nErr=" + Err);
                        return false;
                    }
                }
            }
            else
            {
                LogFile.Error.Show("ERROR:f_Organisation:Get:sql=" + sql_select + "\r\nErr=" + Err);
                return false;
            }
        }
예제 #10
0
 private bool RowReferenceFromTable_Check_NoChangeToOther_Ex(List<usrc_RowReferencedFromTable> usrc_RowReferencedFromTable_List, ID_v id_v)
 {
     ltext Instruction = null;
     if (this.myGroupBox!=null)
     {
         bool bCancelDialog = false;
         bool bRes = this.myGroupBox.SetEvent_RowReferenceFromTable_Check_NoChangeToOther(this, usrc_RowReferencedFromTable_List, id_v, ref bCancelDialog, ref Instruction);
         if (bCancelDialog)
         {
             return bRes;
         }
     }
     usrc_RowReferencedFromTable_List_Dialog RowReferencedFromTable_List_Dialog = new usrc_RowReferencedFromTable_List_Dialog(usrc_RowReferencedFromTable_List, this, id_v.v, Instruction);
     DialogResult dlgRes = RowReferencedFromTable_List_Dialog.ShowDialog();
     if (dlgRes == DialogResult.No)
     {
         return true;
     }
     return false;
 }
예제 #11
0
파일: fs.cs 프로젝트: dstrucl/Tangenta40
        public static bool Get_ID(string TableName, string col_name, string_v svalue, ref ID_v iD_v, ref string Err)
        {
            DataTable dt = new DataTable();
            string spar = "@par_svalue";
            string scond = col_name + " is null";
            string sval = "null";
            List<SQL_Parameter> lpar = new List<SQL_Parameter>();
            if (svalue != null)
            {
                SQL_Parameter par_svalue = new SQL_Parameter(spar, SQL_Parameter.eSQL_Parameter.Nvarchar, false, svalue.v);
                lpar.Add(par_svalue);
                scond = " " + col_name + " = " + spar + " ";
                sval = spar;
            }

            string sql_select = "select ID from " + TableName + " where " + scond;
            if (DBSync.DBSync.ReadDataTable(ref dt, sql_select, lpar, ref Err))
            {
                if (dt.Rows.Count > 0)
                {
                    if (iD_v == null)
                    {
                        iD_v = new ID_v();
                    }
                    iD_v.v = (long)dt.Rows[0]["ID"];
                    return true;
                }
                else
                {
                    string sql_insert = " insert into " + TableName + " (" + col_name + ") values (" + spar + ")";
                    object oret = null;
                    long id = -1;
                    if (DBSync.DBSync.ExecuteNonQuerySQLReturnID(sql_insert, null, ref id, ref oret, ref Err, TableName))
                    {
                        if (iD_v == null)
                        {
                            iD_v = new ID_v();
                        }
                        iD_v.v = id;
                        return true;
                    }
                }
            }
            return false;
        }