Example #1
0
        private void InsertCustomerPriceClickExecute()
        {
            if (NewCustomerPrice <= 0)
            {
                MessageBox.Show("設定的客戶單價不正確!!");
                return;
            }
            bool newDefaultPriceSuccess = false;

            if (SelectedCustomerCheckBillSheet.DefaultPrice == 0)
            {
                List <AccountTextile> accountTextile = new List <AccountTextile>()
                {
                    new AccountTextile
                    {
                        FactoryID    = SelectedCustomerCheckBillSheet.F_01,
                        ItemID       = SelectedCustomerCheckBillSheet.I_01,
                        ItemName     = SelectedCustomerCheckBillSheet.I_03,
                        DefaultPrice = Convert.ToInt32(SelectedCustomerCheckBillSheet.Price)
                    }
                };
                newDefaultPriceSuccess = AccountSystemModule.InsertDefaultPrice(accountTextile);
            }
            IEnumerable <AccountTextile> accountTextiles      = AccountSystemModule.GetAccountTextile();
            CustomerTextilePrice         customerTextilePrice = new CustomerTextilePrice
            {
                AccountTextileID  = accountTextiles.Where(w => w.FactoryID == SelectedCustomerCheckBillSheet.F_01 && w.ItemID == SelectedCustomerCheckBillSheet.I_01).FirstOrDefault().AccountTextileID,
                AccountCustomerID = SelectedTrashCustomer.CARD_NO,
                Price             = NewCustomerPrice
            };

            if (!AccountSystemModule.GetCustomerTextilePrice(SelectedCustomerCheckBillSheet.C_01).Any(a => a.AccountTextileID == SelectedCustomerCheckBillSheet.AccountTextileID))
            {
                bool success = AccountSystemModule.InsertCustomerTextilePrice(customerTextilePrice);
                if (success)
                {
                    bool updateTrashSystemsuccess = UpdateTrashSystemPrice(SelectedCustomerCheckBillSheet, NewCustomerPrice);
                    if (updateTrashSystemsuccess)
                    {
                        DisplayUpdate(newDefaultPriceSuccess, NewCustomerPrice);
                        MessageBox.Show("新增客戶單價成功!");
                    }
                    else
                    {
                        MessageBox.Show("帳務系統新增失敗!!", "錯誤!", MessageBoxButton.OK, MessageBoxImage.Error);
                    }
                }
                else
                {
                    MessageBox.Show("新增失敗!!", "錯誤!", MessageBoxButton.OK, MessageBoxImage.Error);
                }
            }
            else
            {
                MessageBox.Show("已設定過該客戶的布種單價,請使用更新單價功能!!");
            }
        }
Example #2
0
        /// <summary>
        /// 新增客戶布種單價
        /// </summary>
        /// <returns></returns>
        public int InsertCustomerTextilePrice(CustomerTextilePrice customerTextilePrice)
        {
            string sql    = @"INSERT INTO CustomerTextilePrice
                            ([AccountCustomerID]
                            ,[AccountTextileID]
                            ,[Price])
                           VALUES 
                           (@AccountCustomerID,
                            @AccountTextileID,
                            @Price);";
            var    result = DapperHelper.Execute(AppSettingConfig.ConnectionString(), CommandType.Text, sql, customerTextilePrice);

            return(result);
        }
Example #3
0
        /// <summary>
        /// 新增客戶布種單價
        /// </summary>
        /// <returns></returns>
        public bool InsertCustomerTextilePrice(CustomerTextilePrice customerTextilePrice)
        {
            int count = AccountSystemAdapter.InsertCustomerTextilePrice(customerTextilePrice);

            return(count == 1);
        }