private void usrc_EditTable_PurchasePrice_after_InsertInDataBase(SQLTable m_tbl, long ID, bool bRes)
        {
            // Now create price lists
            if (bRes)
            {
                SQLTable tbl_Taxation = new SQLTable(DBSync.DBSync.DB_for_Tangenta.m_DBTables.GetTable(typeof(Taxation)));
                tbl_Taxation.CreateTableTree(DBSync.DBSync.DB_for_Tangenta.m_DBTables.items);
                SelectID_Table_Assistant_Form  SelectID_Table_dlg = new SelectID_Table_Assistant_Form(tbl_Taxation,DBSync.DBSync.DB_for_Tangenta.m_DBTables,null);
                SelectID_Table_dlg.ShowDialog();
                long id_Taxation = SelectID_Table_dlg.ID;
                if (id_Taxation>=0)
                {
                    string Err = null;
                    string sql = @" insert into PurchasePrice_Item (Item_ID,PurchasePrice_ID,Taxation_ID,PurchasePricePerUnit,Discount)
                                select id," + ID.ToString() + "," + id_Taxation.ToString() + ",-1,0 from Item where ToOffer = 1";
                    object ores = null;
                    if (DBSync.DBSync.ExecuteNonQuerySQL(sql, null, ref ores, ref Err))
                    {
                        SQLTable tbl_Price_Item = new SQLTable(DBSync.DBSync.DB_for_Tangenta.m_DBTables.GetTable(typeof(Price_Item)));
                        tbl_Price_Item.CreateTableTree(DBSync.DBSync.DB_for_Tangenta.m_DBTables.items);
                        string where_condition = " where PurchasePrice_$_ID = " + ID.ToString() + " ";
                        string selection = @"ID,
                                 PurchasePrice_Item_$$PurchasePricePerUnit,
                                 PurchasePrice_Item_$_pp_$_Cur_$$Symbol,
                                 PurchasePrice_Item_$_i_$$UniqueName,
                                 PurchasePrice_Item_$_tax_$$Name,
                                 PurchasePrice_Item_$_tax_$$Rate,
                                 PurchasePrice_Item_$_pp_$$Valid,
                                 PurchasePrice_Item_$_i_$$Code
            ";

                        if (usrc_EditTable_PurchaseItem.Init(DBSync.DBSync.DB_for_Tangenta.m_DBTables, tbl_Price_Item, selection, "PurchasePrice_Item_$_i_$$Code desc", false, where_condition, null, false,nav))
                        {
                            Edit_PurchasePrice_Item(id_Taxation);
                        }
                    }
                    else
                    {
                        LogFile.Error.Show("ERROR:usrc_PriceList_Edit:usrc_EditTable_PriceList_after_InsertInDataBase:Err=" + Err + "\r\nSql=" + sql);
                    }
                }
            }
            b_InsertInDataBase = false;
        }
        private void usrc_EditTable_PriceList_after_InsertInDataBase(SQLTable m_tbl, long ID, bool bRes)
        {
            // Now create price lists
            if (bRes)
            {
                if (nav.m_eButtons == Navigation.eButtons.OkCancel)
                {
                    SQLTable tbl_Taxation = new SQLTable(DBSync.DBSync.DB_for_Tangenta.m_DBTables.GetTable(typeof(Taxation)));
                    tbl_Taxation.CreateTableTree(DBSync.DBSync.DB_for_Tangenta.m_DBTables.items);
                    SelectID_Table_Assistant_Form SelectID_Table_dlg = new SelectID_Table_Assistant_Form(tbl_Taxation, DBSync.DBSync.DB_for_Tangenta.m_DBTables, null);
                    SelectID_Table_dlg.ShowDialog();
                    long id_Taxation = SelectID_Table_dlg.ID;
                    if (id_Taxation >= 0)
                    {
                        string sql = null;
                        object ores = null;
                        string Err = null;
                        if (m_eShopType == eShopType.ShopB)
                        {

                            sql = @" insert into Price_SimpleItem (SimpleItem_ID,PriceList_ID,Taxation_ID,RetailSimpleItemPrice,Discount)
                                    select id," + ID.ToString() + "," + id_Taxation.ToString() + ",-1,0 from SimpleItem where ToOffer = 1";
                            if (DBSync.DBSync.ExecuteNonQuerySQL(sql, null, ref ores, ref Err))
                            {
                                if (tbl_Price_SimpleItem == null)
                                {
                                    tbl_Price_SimpleItem = new SQLTable(DBSync.DBSync.DB_for_Tangenta.m_DBTables.GetTable(typeof(Price_SimpleItem)));
                                    tbl_Price_SimpleItem.CreateTableTree(DBSync.DBSync.DB_for_Tangenta.m_DBTables.items);
                                }
                                else
                                {
                                    tbl_Price_SimpleItem.DeleteInputControls();
                                }
                                string where_condition = " where Price_SimpleItem_$_pl_$$ID = " + ID.ToString() + " ";
                                string selection = @" ID,
                                                  Price_SimpleItem_$$RetailSimpleItemPrice,
                                                  Price_SimpleItem_$$Discount,
                                                  Price_SimpleItem_$_si_$$Name,
                                                  Price_SimpleItem_$_si_$_siimg_$$Image_Data,
                                                  Price_SimpleItem_$_tax_$$Name,
                                                  Price_SimpleItem_$_tax_$$Rate,
                                                  Price_SimpleItem_$_pl_$_Cur_$$Symbol,
                                                  Price_SimpleItem_$_pl_$_Cur_$$Abbreviation,
                                                  Price_SimpleItem_$_si_$$Code,
                                                  Price_SimpleItem_$_pl_$$Name
                                                  ";
                                if (usrc_EditTable_Shop_Prices != null)
                                {
                                    if (this.usrc_EditTable_Shop_Prices.Init(DBSync.DBSync.DB_for_Tangenta.m_DBTables, tbl_Price_SimpleItem, selection, "Price_SimpleItem_$_si_$$Code desc", false, where_condition, null, false,nav))
                                    {
                                    }
                                }
                            }
                            else
                            {
                                LogFile.Error.Show("ERROR:usrc_PriceList_Edit:usrc_EditTable_PriceList_after_InsertInDataBase:Err=" + Err + "\r\nSql=" + sql);
                                return;
                            }
                        }
                        else
                        {
                            sql = @" insert into Price_Item (Item_ID,PriceList_ID,Taxation_ID,RetailPricePerUnit,Discount)
                                            select id," + ID.ToString() + "," + id_Taxation.ToString() + ",-1,0 from Item where ToOffer = 1";
                            if (DBSync.DBSync.ExecuteNonQuerySQL(sql, null, ref ores, ref Err))
                            {
                                if (tbl_Price_Item == null)
                                {
                                    tbl_Price_Item = new SQLTable(DBSync.DBSync.DB_for_Tangenta.m_DBTables.GetTable(typeof(Price_Item)));
                                    tbl_Price_Item.CreateTableTree(DBSync.DBSync.DB_for_Tangenta.m_DBTables.items);
                                }
                                else
                                {
                                    tbl_Price_Item.DeleteInputControls();
                                }
                                string selection = @" ID,
                                                  Price_Item_$$RetailPricePerUnit,
                                                  Price_Item_$$Discount,
                                                  Price_Item_$_i_$$UniqueName,
                                                  Price_Item_$_i_$_iimg_$$Image_Data,
                                                  Price_Item_$_i_$$Name,
                                                  Price_Item_$_tax_$$Rate,
                                                  Price_Item_$_i_$_exp_$$ExpectedShelfLifeInDays,
                                                  Price_Item_$_i_$_exp_$$SaleBeforeExpiryDateInDays,
                                                  Price_Item_$_pl_$_Cur_$$Symbol,
                                                  Price_Item_$_pl_$_Cur_$$Abbreviation,
                                                  Price_Item_$_i_$$Code,
                                                  Price_Item_$_pl_$$Name
                                                  ";
                                string where_condition = " where Price_Item_$_pl_$$ID = " + ID.ToString() + " ";
                                if (usrc_EditTable_Shop_Prices != null)
                                {
                                    if (usrc_EditTable_Shop_Prices.Init(DBSync.DBSync.DB_for_Tangenta.m_DBTables, tbl_Price_Item, selection, " Price_Item_$_i_$$Code desc ", false, where_condition, null, false,nav))
                                    {
                                        if (!SetPriceListName(ID, ref Err))
                                        {
                                            LogFile.Error.Show("ERROR:usrc_PriceList_Edit:usrc_EditTable_PriceList_after_InsertInDataBase:Err=" + Err);
                                        }
                                        return;
                                    }
                                }
                            }
                            else
                            {
                                LogFile.Error.Show("ERROR:usrc_PriceList_Edit:usrc_EditTable_PriceList_after_InsertInDataBase:Err=" + Err + "\r\nSql=" + sql);
                            }
                        }
                    }
                }
            }
        }
Beispiel #3
0
 public static bool Insert_ShopC_Items_in_PriceList(DataTable dt_Item_NotIn_PriceList, Control parent_ctrl)
 {
     string Err = null;
     for (;;)
     {
         SQLTable tbl_Taxation = new SQLTable(DBSync.DBSync.DB_for_Tangenta.m_DBTables.GetTable(typeof(Taxation)));
         tbl_Taxation.CreateTableTree(DBSync.DBSync.DB_for_Tangenta.m_DBTables.items);
         SelectID_Table_Assistant_Form SelectID_Table_dlg = new SelectID_Table_Assistant_Form(tbl_Taxation, DBSync.DBSync.DB_for_Tangenta.m_DBTables, null);
         if (parent_ctrl is Form)
         {
             if (((Form)parent_ctrl).TopMost)
             {
                 SelectID_Table_dlg.TopMost = true;
             }
         }
         SelectID_Table_dlg.ShowDialog(parent_ctrl);
         long id_Taxation = SelectID_Table_dlg.ID;
         if (id_Taxation >= 0)
         {
             foreach (DataRow dr in dt_Item_NotIn_PriceList.Rows)
             {
                 long PriceList_ID = (long)dr["PriceList_ID"];
                 long Item_ID = (long)dr["Item_ID"];
                 string sql = "insert into Price_Item (RetailPricePerUnit,Discount,Taxation_ID,Item_ID,PriceList_ID) values (-1,0," + id_Taxation.ToString() + "," + Item_ID.ToString() + "," + PriceList_ID.ToString() + ")";
                 object objresult = new object();
                 if (!DBSync.DBSync.ExecuteNonQuerySQL(sql, null, ref objresult, ref Err))
                 {
                     LogFile.Error.Show("ERROR:f_PriceList:Update:sql=" + sql + "\r\nErr=" + Err);
                     return false;
                 }
             }
             return true;
         }
         else
         {
             if (MessageBox.Show(parent_ctrl, lngRPM.s_PriceListIsNotUpdatedBecauseYouDidnotSelect.s, "?", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1) == DialogResult.Cancel)
             {
                 return false;
             }
         }
     }
 }