Пример #1
0
        public static bool Get(
                                 long Office_Data_ID,
                                 ref long Atom_Office_Data_ID)
        {
            long cAddress_Org_ID = -1;
            long Office_ID = -1;
            string Description = null;
            string sql = @"select
                            od.Office_ID,
                            od.cAddress_Org_ID,
                            od.Description
                            from Office_Data od
                            where od.ID = " + Office_Data_ID.ToString();
            DataTable dt = new DataTable();
            string Err = null;
            if (DBSync.DBSync.ReadDataTable(ref dt, sql, null, ref Err))
            {
                if (dt.Rows.Count > 0)
                {

                    object o_Office_ID = dt.Rows[0]["Office_ID"];
                    if (o_Office_ID is long)
                    {
                        Office_ID = (long)o_Office_ID;
                    }
                    else
                    {
                        LogFile.Error.Show("ERROR:f_Atom_Office_Data:Get:Office_ID is null!");
                        return false;
                    }

                    object o_cAddress_Org_ID = dt.Rows[0]["cAddress_Org_ID"];
                    if (o_cAddress_Org_ID is long)
                    {
                        cAddress_Org_ID = (long)o_cAddress_Org_ID;
                    }
                    else
                    {
                        LogFile.Error.Show("ERROR:f_Atom_Office_Data:Get:cAddress_Org_ID is null!");
                        return false;
                    }

                    object o_Description = dt.Rows[0]["Description"];
                    if (o_Description is string)
                    {
                        Description = (string)o_Description;
                    }

                    long Atom_cAddress_Org_ID = -1;
                    long Atom_Office_ID = -1;

                    if (f_Atom_Office.Get(Office_ID, ref Atom_Office_ID))
                    {
                        if (f_Atom_cAddress_Org.Get(cAddress_Org_ID, ref Atom_cAddress_Org_ID))
                        {
                            DBTypes.string_v Office_Name = new DBTypes.string_v();
                            List<SQL_Parameter> lpar = new List<SQL_Parameter>();
                            string scond_Description = null;
                            string sval_Description = "null";
                            if (Description != null)
                            {
                                string spar_Description = "@par_Description";
                                SQL_Parameter par_Description = new SQL_Parameter(spar_Description, SQL_Parameter.eSQL_Parameter.Nvarchar, false, Description);
                                lpar.Add(par_Description);
                                scond_Description = "Description = " + spar_Description;
                                sval_Description = spar_Description;
                            }
                            else
                            {
                                scond_Description = "Description is null";
                                sval_Description = "null";
                            }

                            sql = @"select
                                    ID
                                    from Atom_Office_Data
                                    where  Atom_Office_ID = " + Atom_Office_ID.ToString() + @" and
                                            Atom_cAddress_Org_ID = " + Atom_cAddress_Org_ID.ToString() + @" and
                                            " + scond_Description;
                            dt.Clear();
                            dt.Columns.Clear();
                            if (DBSync.DBSync.ReadDataTable(ref dt, sql, lpar, ref Err))
                            {
                                if (dt.Rows.Count > 0)
                                {
                                    Atom_Office_Data_ID = (long)dt.Rows[0]["ID"];
                                    return true;
                                }
                                else
                                {
                                    sql = @"insert into Atom_Office_Data (Atom_Office_ID,Atom_cAddress_Org_ID,Description) values (" + Atom_Office_ID.ToString() + "," + Atom_cAddress_Org_ID.ToString() + "," + sval_Description + ")";
                                    object objretx = null;
                                    if (DBSync.DBSync.ExecuteNonQuerySQLReturnID(sql, lpar, ref Atom_Office_Data_ID, ref objretx, ref Err, "Atom_Office_Data"))
                                    {
                                        return true;
                                    }
                                    else
                                    {
                                        LogFile.Error.Show("ERROR:f_Atom_Office_Data:Get:" + sql + "\r\nErr=" + Err);
                                    }
                                }
                            }
                            else
                            {
                                LogFile.Error.Show("ERROR:f_Atom_Office_Data:Get:sql=" + sql + "\r\nErr=" + Err);
                            }
                        }
                    }
                    return false;
                }
                else
                {
                    LogFile.Error.Show("ERROR:f_Atom_Office_Data:Get:No Office_Data data link for Office_Data_ID =" + Office_Data_ID.ToString());
                    return false;
                }
            }
            else
            {
                LogFile.Error.Show("ERROR:f_Atom_Office_Data:Get:" + sql + "\r\nErr=" + Err);
                return false;
            }
        }
Пример #2
0
            public void GetRowData(DataTable dt_xPriceList, int index)
            {
                if (index < dt_xPriceList.Rows.Count)
                {
                    ID = (long)dt_xPriceList.Rows[index]["ID"];
                    Name = (string)dt_xPriceList.Rows[index]["Name"];
                    Valid = (bool)dt_xPriceList.Rows[index]["Valid"];
                    object oValidFrom = dt_xPriceList.Rows[index]["ValidFrom"];
                    if (oValidFrom.GetType() == typeof(DateTime))
                    {
                        if (ValidFrom == null)
                        {
                            ValidFrom = new DBTypes.DateTime_v();
                        }
                        ValidFrom.v = (DateTime)oValidFrom;
                    }
                    else
                    {
                        ValidFrom = null;
                    }

                    object oValidTo = dt_xPriceList.Rows[index]["ValidTo"];

                    if (oValidTo.GetType() == typeof(DateTime))
                    {
                        if (ValidTo == null)
                        {
                            ValidTo = new DBTypes.DateTime_v();
                        }
                        ValidTo.v = (DateTime)oValidTo;
                    }
                    else
                    {
                        ValidTo = null;
                    }
                    object oCreationDate = dt_xPriceList.Rows[index]["CreationDate"];
                    if (oCreationDate.GetType() == typeof(DateTime))
                    {
                        if (CreationDate == null)
                        {
                            CreationDate = new DBTypes.DateTime_v();
                        }
                        CreationDate.v = (DateTime)oCreationDate;
                    }
                    else
                    {
                        CreationDate = null;
                    }
                    object oDescription = dt_xPriceList.Rows[index]["Description"];
                    if (oDescription.GetType() == typeof(string))
                    {
                        if (Description == null)
                        {
                            Description = new DBTypes.string_v();
                        }
                        Description.v = (string)oDescription;
                    }
                    else
                    {
                        Description = null;
                    }
                    //object omyOrganisation_Person_UserName = dt_xPriceList.Rows[index]["UserName"];
                    //if (omyOrganisation_Person_UserName.GetType() == typeof(string))
                    //{
                    //    if (myOrganisation_Person_UserName == null)
                    //    {
                    //        myOrganisation_Person_UserName = new DBTypes.string_v();
                    //    }
                    //    myOrganisation_Person_UserName.v = (string)omyOrganisation_Person_UserName;
                    //}
                    //else
                    //{
                    //    myOrganisation_Person_UserName = null;
                    //}

                    //object omyOrganisation_Person_FirstName = dt_xPriceList.Rows[index]["FirstName"];
                    //if (omyOrganisation_Person_FirstName.GetType() == typeof(string))
                    //{
                    //    if (myOrganisation_Person_FirstName == null)
                    //    {
                    //        myOrganisation_Person_FirstName = new DBTypes.string_v();
                    //    }
                    //    myOrganisation_Person_FirstName.v = (string)omyOrganisation_Person_FirstName;
                    //}
                    //else
                    //{
                    //    myOrganisation_Person_FirstName = null;
                    //}
                    //object omyOrganisation_Person_LastName = dt_xPriceList.Rows[index]["LastName"];
                    //if (omyOrganisation_Person_LastName.GetType() == typeof(string))
                    //{
                    //    if (myOrganisation_Person_LastName == null)
                    //    {
                    //        myOrganisation_Person_LastName = new DBTypes.string_v();
                    //    }
                    //    myOrganisation_Person_LastName.v = (string)omyOrganisation_Person_LastName;
                    //}
                    //else
                    //{
                    //    myOrganisation_Person_LastName = null;
                    //}

                    //object omyOrganisation_Person_Job = dt_xPriceList.Rows[index]["Job"];
                    //if (omyOrganisation_Person_Job.GetType() == typeof(string))
                    //{
                    //    if (myOrganisation_Person_Job == null)
                    //    {
                    //        myOrganisation_Person_Job = new DBTypes.string_v();
                    //    }
                    //    myOrganisation_Person_Job.v = (string)omyOrganisation_Person_Job;
                    //}
                    //else
                    //{
                    //    myOrganisation_Person_Job = null;
                    //}

                    //object omyOrganisation_Person_Description = dt_xPriceList.Rows[index]["myOrganisation_Person_Description"];
                    //if (omyOrganisation_Person_Description.GetType() == typeof(string))
                    //{
                    //    if (myOrganisation_Person_Description == null)
                    //    {
                    //        myOrganisation_Person_Description = new DBTypes.string_v();
                    //    }
                    //    myOrganisation_Person_Description.v = (string)omyOrganisation_Person_Description;
                    //}
                    //else
                    //{
                    //    myOrganisation_Person_Description = null;
                    //}

                    //object omyOrganisation_Person_Active = dt_xPriceList.Rows[index]["Active"];
                    //if (omyOrganisation_Person_Active.GetType() == typeof(bool))
                    //{
                    //    if (myOrganisation_Person_Active == null)
                    //    {
                    //        myOrganisation_Person_Active = new DBTypes.bool_v();
                    //    }
                    //    myOrganisation_Person_Active.v = (bool)omyOrganisation_Person_Active;
                    //}
                    //else
                    //{
                    //    myOrganisation_Person_Active = null;
                    //}

                    object oCurrency_ID = dt_xPriceList.Rows[index]["Currency_ID"];
                    if (oCurrency_ID.GetType() == typeof(long))
                    {
                        m_xCurrency.ID = (long)oCurrency_ID;
                    }
                    else
                    {
                        m_xCurrency.ID = -1;
                    }

                    object oCurrency_Name = dt_xPriceList.Rows[index]["Currency_Name"];
                    if (oCurrency_Name.GetType() == typeof(string))
                    {
                        m_xCurrency.Name = (string)oCurrency_Name;
                    }
                    else
                    {
                        m_xCurrency.Name = null;
                    }

                    object oCurrency_Abbreviation = dt_xPriceList.Rows[index]["Currency_Abbreviation"];
                    if (oCurrency_Abbreviation.GetType() == typeof(string))
                    {
                        m_xCurrency.Abbreviation = (string)oCurrency_Abbreviation;
                    }
                    else
                    {
                        m_xCurrency.Abbreviation = null;
                    }

                    object oCurrency_Symbol = dt_xPriceList.Rows[index]["Currency_Symbol"];
                    if (oCurrency_Symbol.GetType() == typeof(string))
                    {
                        m_xCurrency.Symbol = (string)oCurrency_Symbol;
                    }
                    else
                    {
                        m_xCurrency.Symbol = null;
                    }
                    object oCurrency_CurrencyCode = dt_xPriceList.Rows[index]["Currency_CurrencyCode"];
                    if (oCurrency_CurrencyCode.GetType() == typeof(int))
                    {
                        m_xCurrency.CurrencyCode = (int)oCurrency_CurrencyCode;
                    }
                    else
                    {
                        m_xCurrency.CurrencyCode = -1;
                    }
                }
                else
                {
                    LogFile.Error.Show("ERROR:dt_xPriceList:GetRowData:index our of range! index = " + index.ToString() + ",dt_xPriceList.Rows.Count = " + dt_xPriceList.Rows.Count.ToString());
                }
            }