コード例 #1
0
        public static bool Get(long PriceList_ID, ref long Atom_PriceList_ID)
        {
            string Err = null;

            DataTable dt = new DataTable();
            string sql = @"select Atom_PriceList.ID
                            from Atom_PriceList
                            inner join PriceList on Atom_PriceList.Name = PriceList.Name
                                                    and Atom_PriceList.Valid = PriceList.Valid
                                                    and ((Atom_PriceList.ValidFrom = PriceList.ValidFrom) or (Atom_PriceList.ValidFrom is null and PriceList.ValidFrom is null))
                                                    and ((Atom_PriceList.ValidTo = PriceList.ValidTo) or (Atom_PriceList.ValidTo is null and PriceList.ValidTo is null))
                                                    and ((Atom_PriceList.Description = PriceList.Description) or (Atom_PriceList.Description is null and PriceList.Description is null))
                            inner join Currency on PriceList.Currency_ID = Currency.ID
                            inner join Atom_Currency on Atom_PriceList.Atom_Currency_ID = Atom_Currency.ID
                            where Currency.Abbreviation = Atom_Currency.Abbreviation and
                                  PriceList.ID = " + PriceList_ID.ToString();

            if (DBSync.DBSync.ReadDataTable(ref dt, sql, null, ref Err))
            {
                if (dt.Rows.Count > 0)
                {
                    Atom_PriceList_ID = (long)dt.Rows[0]["ID"];
                    return true;
                }
                else
                {
                    xPriceList m_xPriceList = new xPriceList();
                    sql = "select Currency_ID from PriceList where PriceList.ID = " + PriceList_ID.ToString();
                    dt.Clear();
                    if (DBSync.DBSync.ReadDataTable(ref dt, sql, null, ref Err))
                    {
                        if (dt.Rows.Count > 0)
                        {
                            long Currency_ID = (long)dt.Rows[0]["Currency_ID"];
                            long Atom_Currency_ID = -1;
                            if (f_Atom_Currency.Get(Currency_ID, ref Atom_Currency_ID))
                            {
                                sql = "insert into Atom_PriceList (Name,Valid,ValidFrom,ValidTo,Description,Atom_Currency_ID) select Name,Valid,ValidFrom,ValidTo,Description," + Atom_Currency_ID.ToString() + " from PriceList where ID = " + PriceList_ID.ToString();

                                object objretx = null;
                                if (DBSync.DBSync.ExecuteNonQuerySQLReturnID(sql, null, ref Atom_PriceList_ID, ref objretx, ref Err, "Atom_PriceList"))
                                {
                                    return true;
                                }
                                else
                                {
                                    LogFile.Error.Show("ERROR:f_Atom_PriceList:Get:" + sql + "\r\nErr=" + Err);
                                    return false;
                                }
                            }
                            else
                            {
                                return false;
                            }
                        }
                        else
                        {
                            LogFile.Error.Show("ERROR:f_Atom_PriceList:PriceList has no Currency!\r\nsql=" + sql);
                            return false;
                        }
                    }
                    else
                    {
                        LogFile.Error.Show("ERROR:f_Atom_PriceList:Get:" + sql + "\r\nErr=" + Err);
                        return false;
                    }
                }
            }
            else
            {
                LogFile.Error.Show("ERROR:f_Atom_PriceList:Get:" + sql + "\r\nErr=" + Err);
                return false;
            }
        }
コード例 #2
0
ファイル: usrc_PriceList.cs プロジェクト: dstrucl/Tangenta40
        public bool Init(long Currency_ID,usrc_PriceList_Edit.eShopType xeShopType,string ShopsInUse, NavigationButtons.Navigation xnav, ref string Err)
        {
            m_eShopType = xeShopType;
            m_Currency_ID = Currency_ID;
            if (m_xPriceList == null)
            {
                m_xPriceList = new xPriceList();
            }

            if (xnav != null)
            {
                if (xnav.LastStartupDialog_TYPE.Equals("TangentaSampleDB.Form_Items_Samples"))
                {
                    return DoEditPriceList(Currency_ID, xnav, ref Err);
                }
            }

            if (m_xPriceList.Get_PriceLists_of_Currency(Currency_ID, ref xPriceList_Count, ref Err))
            {
                if (xPriceList_Count > 0)
                {
                    this.cmb_PriceListType.DataSource = m_xPriceList.List_xPriceList;
                    this.cmb_PriceListType.DisplayMember = "xPriceList_Name";
                    this.cmb_PriceListType.ValueMember = "xPriceList_ID";
                }

                else
                {
                    bool bAsk = ((ShopsInUse.Contains("B") && (xeShopType == usrc_PriceList_Edit.eShopType.ShopB) ) || ((ShopsInUse.Contains("C") && (xeShopType == usrc_PriceList_Edit.eShopType.ShopC))));
                    if (bAsk)
                    {
                        bool bDialogResult = true;
                        if (xnav.m_eButtons == NavigationButtons.Navigation.eButtons.PrevNextExit)
                        {
                            bDialogResult = true;
                        }
                        else
                        {
                            bDialogResult = XMessage.Box.ShowTopMost(this, lngRPM.s_NoPriceList_AskToCreatePriceList, "?", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) == DialogResult.Yes;
                        }
                        if (bDialogResult)
                        {
                            return DoEditPriceList(Currency_ID, xnav, ref Err);
                        }
                    }
                }
                return true;
            }
            else
            {
                LogFile.Error.Show(Err);
                return false;
            }
        }
コード例 #3
0
        public static bool Get(ref Atom_DocInvoice_ShopC_Item_Price_Stock_Data appisd, ref long Atom_PriceList_ID)
        {
            string Err = null;
            if (appisd.Atom_PriceList_Name != null)
            {
                List<SQL_Parameter> lpar = new List<SQL_Parameter>();
                string spar_Atom_PriceList_Name = "@par_Atom_PriceList_Name";
                SQL_Parameter par_Atom_PriceList_Name = new SQL_Parameter(spar_Atom_PriceList_Name, SQL_Parameter.eSQL_Parameter.Nvarchar, false, appisd.Atom_PriceList_Name.v);
                lpar.Add(par_Atom_PriceList_Name);

                string spar_Atom_Currency_Abbreviation = "@par_Atom_Currency_Abbreviation";
                SQL_Parameter par_Atom_Currency_Abbreviation = new SQL_Parameter(spar_Atom_Currency_Abbreviation, SQL_Parameter.eSQL_Parameter.Nvarchar, false, appisd.Atom_Currency_Abbreviation.v);
                lpar.Add(par_Atom_Currency_Abbreviation);

                string spar_Atom_Currency_Name = "@par_Atom_Currency_Name";
                SQL_Parameter par_Atom_Currency_Name = new SQL_Parameter(spar_Atom_Currency_Name, SQL_Parameter.eSQL_Parameter.Nvarchar, false, appisd.Atom_Currency_Name.v);
                lpar.Add(par_Atom_Currency_Name);

                DataTable dt = new DataTable();
                string sql = @"select Atom_PriceList.ID
                            from Atom_PriceList
                            inner join Atom_Currency on Atom_PriceList.Atom_Currency_ID = Atom_Currency.ID
                            where Atom_PriceList.Name = " + spar_Atom_PriceList_Name + " and  Atom_Currency.Name = " + spar_Atom_Currency_Name + " and  Atom_Currency.Abbreviation = " + spar_Atom_Currency_Abbreviation;

                if (DBSync.DBSync.ReadDataTable(ref dt, sql, lpar, ref Err))
                {
                    if (dt.Rows.Count > 0)
                    {
                        Atom_PriceList_ID = (long)dt.Rows[0]["ID"];
                        return true;
                    }
                    else
                    {
                        sql = @"select PriceList.ID
                                      from PriceList
                                      inner join Currency on PriceList.Currency_ID = Currency.ID
                                      where PriceList.Name = " + spar_Atom_PriceList_Name + " and  Currency.Name = " + spar_Atom_Currency_Name + " and  Currency.Abbreviation = " + spar_Atom_Currency_Abbreviation;
                        dt.Clear();
                        dt.Rows.Clear();
                        dt.Columns.Clear();
                        if (DBSync.DBSync.ReadDataTable(ref dt, sql, lpar, ref Err))
                        {
                            if (dt.Rows.Count > 0)
                            {
                                long PriceList_ID = (long)dt.Rows[0]["ID"];
                                xPriceList m_xPriceList = new xPriceList();
                                sql = "select Currency_ID from PriceList where PriceList.ID = " + PriceList_ID.ToString();
                                dt.Clear();
                                if (DBSync.DBSync.ReadDataTable(ref dt, sql, null, ref Err))
                                {
                                    if (dt.Rows.Count > 0)
                                    {
                                        long Currency_ID = (long)dt.Rows[0]["Currency_ID"];
                                        long Atom_Currency_ID = -1;
                                        if (f_Atom_Currency.Get(Currency_ID, ref Atom_Currency_ID))
                                        {
                                            sql = "insert into Atom_PriceList (Name,Valid,ValidFrom,ValidTo,Description,Atom_Currency_ID) select Name,Valid,ValidFrom,ValidTo,Description," + Atom_Currency_ID.ToString() + " from PriceList where ID = " + PriceList_ID.ToString();

                                            object objretx = null;
                                            if (DBSync.DBSync.ExecuteNonQuerySQLReturnID(sql, null, ref Atom_PriceList_ID, ref objretx, ref Err, "Atom_PriceList"))
                                            {
                                                return true;
                                            }
                                            else
                                            {
                                                LogFile.Error.Show("ERROR:f_Atom_PriceList:Get:" + sql + "\r\nErr=" + Err);
                                                return false;
                                            }
                                        }
                                        else
                                        {
                                            return false;
                                        }
                                    }
                                    else
                                    {
                                        LogFile.Error.Show("ERROR:f_Atom_PriceList:PriceList has no Currency!\r\nsql=" + sql);
                                        return false;
                                    }
                                }
                                else
                                {
                                    LogFile.Error.Show("ERROR:f_Atom_PriceList:Get:" + sql + "\r\nErr=" + Err);
                                    return false;
                                }
                            }
                            else
                            {
                                LogFile.Error.Show("ERROR:f_Atom_PriceList:PriceList has no data!\r\nsql=" + sql);
                                return false;
                            }
                        }
                        else
                        {
                            LogFile.Error.Show("ERROR:f_Atom_PriceList:Get:" + sql + "\r\nErr=" + Err);
                            return false;
                        }
                    }
                }
                else
                {
                    LogFile.Error.Show("ERROR:f_Atom_PriceList:Get:" + sql + "\r\nErr=" + Err);
                    return false;
                }

            }
            else
            {
                LogFile.Error.Show("ERROR:f_Atom_PriceList:Get:appisd.Atom_PriceList_Name==null");
                return false;
            }
        }