Ejemplo n.º 1
0
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                prices = Convert.ToInt32(textBox1.Text);
                counts = Convert.ToInt32(textBox2.Text);

                string sql = $@"update [GoodsItems] set [ItemQuantity] = '{counts}' where [GoodsId] = '{GoodID}'";

                if (db._SQL_IDU(sql) > 0)
                {
                    sql  = $@"
begin tran
begin try  
";
                    sql += $@"update [GoodsItemBasicPrices] set [BasicSalePrice] = '{prices}' where [GoodsID] = '{GoodID}';";
                    sql += $@"update  [GoodsSalePricePolicies] set [SalePrice] = '{prices}' where [GoodsID] = '{GoodID}';";
                    sql += $@"
                end try
begin catch
   select Error_number() as ErrorNumber,
          Error_severity() as ErrorSeverity,
          Error_state() as ErrorState ,
          Error_Procedure() as ErrorProcedure ,
          Error_line() as ErrorLine,
          Error_message() as ErrorMessage 
   if(@@trancount>0)
      rollback tran
end catch
if(@@trancount>0)
commit tran
";
                    if (db._SQL_IDU(sql) > 0)
                    {
                        this.DialogResult = DialogResult.OK;
                    }
                    else
                    {
                        this.DialogResult = DialogResult.No;
                    }
                }
                else
                {
                    this.DialogResult = DialogResult.No;
                }


                this.Close();
            }
            catch (Exception ex)
            {
                this.Close();
                this.DialogResult = DialogResult.No;
            }
        }
Ejemplo n.º 2
0
        private bool InsertStore(int GoodsId, int itemID, string GoodsDisplayName, int ItemQuantity, double BasicSalePrice, string gameItemKey)
        {
            try
            {
                string sql = string.Empty;
                //sql = $@"select max([GoodsId]) from {_db}.[dbo].[Goods] ";
                //int GoodsId = Convert.ToInt32(db._SQLScalar(sql)) + 1;//自增1

                sql = $@"
begin tran
begin try  
";

                sql += $@"insert into {_db}.[dbo].[Goods](GoodsId,GoodsName,GoodsAppGroupCode,GoodsType,DeliveryType,SaleStatus,EffectiveFrom,EffectiveTo,SaleableQuantity,RefundUnitCode,IsRefundable,IsAvailableRecurringPayment,Changed,ChangerAdminAccount,GoodsDescription,GoodsData,ParentGoodsId,GoodsPurchaseType,SelectableItemQuantity, GoodsPurchaseCheckMask) 
            values ('{GoodsId}',N'{textBox5.Text.Trim()}','bnsgrnTH','3','1','2','2017-09-05','2099-12-31',0,1,'False','True','2017-09-05','TestAdminAccount',N'{textBox5.Text.Trim()}','AAAAAAE=',NULL,'1',NULL,'0');";

                sql += $@"insert into {_db}.[dbo].[GoodsChanges](ChangeId,ChangeType,Registered,RegistrarAdminAccount,ChangeDescription,GoodsAppGroupCode,IsDisplayable) values
        ('{GoodsId}', '2', '2017-09-05 20:00', 'TestAdminAccount', NULL, 'bnsgrnTH', 'True');";

                sql += $@"insert into {_db}.[dbo].[GoodsDisplay](GoodsId,LanguageCode,GoodsDisplayName,GoodsDisplayDescription) values
                ('{GoodsId}','11',N'{textBox5.Text.Trim()}',N'{textBox5.Text.Trim()}');";

                sql += $@"insert into {_db}.[dbo].[GoodsSalePricePolicies](GoodsId,CurrencyGroupId,PricePolicyType,EffectiveFrom,EffectiveTo,SalePrice) 
                    values('{GoodsId}', 71, 1, '2017-06-06 00:00', '2099-12-31 23:59', '{BasicSalePrice}');";

                sql += $@"insert into {_db}.[dbo].[Items](ItemId,ItemName,ItemAppGroupCode,ItemType,IsConsumable,BasicPrice,BasicCurrencyGroupId,Changed,ChangerAdminAccount,ItemDescription) 
                    values('{itemID}', N'{GoodsDisplayName}', 'bnsgrnTH', '3', 'False', '{BasicSalePrice}', '69', '2015-02-13 00:00', 'TestAdminAccount', N'{GoodsDisplayName}');";

                sql += $@"insert into {_db}.[dbo].[ItemDisplay](ItemId,LanguageCode,ItemDisplayName,ItemDisplayDescription) 
                values ('{itemID}', 11, N'{GoodsDisplayName}',  N'{GoodsDisplayName}');";

                sql += $@"insert into {_db}.[dbo].[GoodsItems](GoodsId,ItemId,ItemQuantity,ItemExpirationType,ItemData,DeliveryPriority) values
                ('{GoodsId}', '{itemID}', '{ItemQuantity}', 0, 'AAAAAAEA', 1);";

                sql += $@"insert into {_db}.[dbo].[GameItems](ItemId,GameItemKey,GameItemData) 
                values('{itemID}', '{gameItemKey}', 'AAAAAAAAAAA=');";

                sql += $@"insert into {_db}.[dbo].[GoodsBasicPrices](GoodsId,CurrencyGroupId,BasicSalePrice,RefundFee) values
                ('{GoodsId}', 71, '{BasicSalePrice}', 0);";

                sql += $@"insert into {_db}.[dbo].[GoodsItemBasicPrices] (GoodsId,ItemId,CurrencyGroupId,BasicSalePrice) values
                ('{GoodsId}', '{itemID}', 71, '{BasicSalePrice}');";

                sql += $@"
                end try
begin catch
   if(@@trancount>0)
      rollback tran
end catch
if(@@trancount>0)
commit tran
";

                int code = db._SQL_IDU(sql);
                if (code > 0)
                {
                    return(true);
                }
                return(false);
            }
            catch (Exception)
            {
                return(false);
            }
        }