示例#1
0
 private void btnMoney_Click(object sender, RoutedEventArgs e)
 {
     if (lstShellOut.SelectedIndex > -1)
     {
         ShellOutModel item   = (ShellOutModel)lstShellOut.SelectedItem;
         string        _strId = item.PaymentId.ToString();
         if (_strId.Length >= 3)
         {
             _strId = _strId.Remove(2);
         }
         if (Convert.ToInt32(_strId) == 11)
         {
             return;
         }
         ShellOutModel _default   = (ShellOutModel)lstShellOut.Items[0];
         string        _strval    = ((PayMoney)(sender as Button).DataContext).Money.ToString();
         decimal       _tempVal   = CalculateTotalBalance(Convert.ToInt16(item.PaymentId.ToString()), Convert.ToDecimal(_strval));
         decimal       tmpCompare = (_default.PaymentId == item.PaymentId) ? Convert.ToDecimal(_strval) : StaticClass.GeneralClass.ConverStringToDecimal(_default.PaymentBalance);
         if (_tempVal > tmpCompare)
         {
             ModernDialog md = new ModernDialog();
             md.CloseButton.FindResource("close").ToString();
             md.Content = App.Current.FindResource("payment_balance_less_cash_balance").ToString();
             md.Title   = App.Current.FindResource("notification").ToString();
             md.ShowDialog();
         }
         else
         {
             item.PaymentBalance = StaticClass.GeneralClass.GetNumFormatDisplay(Convert.ToDecimal(_strval));
         }
     }
     isEnableInvoice();
 }
示例#2
0
        private void OnEventSavePaymentOther(object sender, EventArgs e)
        {
            DataTable _chkRow = ShellOutModel.chkOrder(Convert.ToInt32((int)sender));

            if (_chkRow.Rows.Count > 0)
            {
                return;
            }
            OrderPayment.insertMultiRows(ShellOut, Convert.ToInt32((int)sender));
            StaticClass.GeneralClass.lstCash.Clear();
            if (_lstIndex.Count > 0)
            {
                StaticClass.GeneralClass.customerGiftCard.Clear();
                List <int> _lstid = new List <int>();
                foreach (var _shell_ in ShellOut)
                {
                    string _strId = _shell_.PaymentId.ToString();
                    if (_strId == "11")
                    {
                        _lstid.Add(0);
                    }
                    else if (_strId.Length >= 3)
                    {
                        _strId = _strId.Substring(2);
                        _lstid.Add(Convert.ToInt32(_strId));
                    }
                }
                if (_lstid.Count > 0)
                {
                    DataTable _dt;
                    decimal   _decVal;
                    foreach (int j in _lstid)
                    {
                        if (!string.IsNullOrEmpty(_lstIndex[j]) && _lstIndex[j] != "0:0")
                        {
                            string _strVal  = _lstIndex[j];
                            int    found    = _strVal.IndexOf(":");
                            string _giftId  = _strVal.Remove(found);
                            string _giftVal = _strVal.Substring(found + 1);
                            _dt     = GiftCardModel.getGiftCard(Convert.ToInt64(_giftId));
                            _decVal = Convert.ToDecimal(_dt.Rows[0]["Balance"].ToString()) - StaticClass.GeneralClass.ConverStringToDecimal(_giftVal);
                            if (StaticClass.GeneralClass.ConverStringToDecimal(_giftVal) > 0)
                            {
                                StaticClass.GeneralClass.customerGiftCard.Add(Convert.ToInt32(_giftId));
                                StaticClass.GeneralClass.customerGiftValue.Add(_decVal);
                            }
                        }
                    }
                    if (StaticClass.GeneralClass.customerGiftCard.Count > 0)
                    {
                        if (GiftCardModel.updateMultiGiftCardUsed(StaticClass.GeneralClass.customerid_general, StaticClass.GeneralClass.customerGiftCard, StaticClass.GeneralClass.customerGiftValue) > 0)
                        {
                            StaticClass.GeneralClass.customerGiftCard.Clear();
                            StaticClass.GeneralClass.customerGiftValue.Clear();
                            _lstIndex.Clear();
                        }
                    }
                }
            }
        }
示例#3
0
        private void btnClear_Click(object sender, RoutedEventArgs e)
        {
            ShellOutModel _shell = (ShellOutModel)lstShellOut.SelectedItem;

            _shell.PaymentBalance = "0";
            buttonAddRemovePayment_Click(null, null);
            isEnableInvoice();
        }
示例#4
0
        private void btnpoint_Click(object sender, RoutedEventArgs e)
        {
            ShellOutModel _shell   = (ShellOutModel)lstShellOut.SelectedItem;
            var           strPoint = (StaticClass.GeneralClass.app_settings["decimalSeparator"].ToString() == "0") ? "." : ",";

            if (!_shell.PaymentBalance.Trim().Contains(strPoint))
            {
                _shell.PaymentBalance += strPoint;
            }
            isEnableInvoice();
        }
示例#5
0
        private void btnEnter_Click(object sender, RoutedEventArgs e)
        {
            decimal cashblane = 0;

            for (int i = 0; i < lstShellOut.Items.Count; i++)
            {
                ShellOutModel msShellout = (ShellOutModel)lstShellOut.Items[i];
                cashblane = cashblane + Convert.ToDecimal(msShellout.PaymentBalance);
            }
            cashblane           = cashblane - Convert.ToDecimal(tblTotal.Text);
            tblCashBalance.Text = StaticClass.GeneralClass.GetNumFormatDisplay(cashblane);
            if (cashblane >= 0)
            {
                btnSaveInvoice.IsEnabled   = true;
                btnSaveSendEmail.IsEnabled = true;
            }
            return;
        }
示例#6
0
        private decimal CalculateTotalBalance(int _id, decimal _val)
        {
            decimal _balane = 0;

            foreach (var _selectedShell in lstShellOut.Items)
            {
                ShellOutModel _shellOut = (ShellOutModel)_selectedShell;
                if (_val < 0)
                {
                    _balane += (_shellOut.PaymentId == _id) ? 0 : StaticClass.GeneralClass.ConverStringToDecimal(_shellOut.PaymentBalance);
                }
                else
                {
                    _balane += (_shellOut.PaymentId == _id) ? _val : StaticClass.GeneralClass.ConverStringToDecimal(_shellOut.PaymentBalance);
                }
            }
            decimal lastBalance = _balane - total;

            return(StaticClass.GeneralClass.ConverStringToDecimal(StaticClass.GeneralClass.GetNumFormatDisplay(lastBalance)));
        }
示例#7
0
        private void loadDefaultShellOut()
        {
            DataTable _shellOut = ShellOutModel.getDefaultPayment();

            if (_shellOut.Rows.Count > 0)
            {
                foreach (DataRow dr in _shellOut.Rows)
                {
                    ShellOut.Add(new ShellOutModel {
                        PaymentId = Convert.ToInt32(dr["PaymentID"].ToString()), PaymentName = dr["Card"].ToString(), PaymentBalance = "0", ShowButtonDel = "Hidden"
                    });
                    StaticClass.GeneralClass.lstCash.Add(Convert.ToInt32(dr["PaymentID"].ToString()));
                }
            }
            else
            {
                ShellOut.Add(new ShellOutModel {
                    PaymentId = 1, PaymentName = "Cash", PaymentBalance = "0", ShowButtonDel = "Hidden"
                });
                StaticClass.GeneralClass.lstCash.Add(Convert.ToInt32(1));
            }
        }
示例#8
0
        private void btnBackspace_Click(object sender, RoutedEventArgs e)
        {
            ShellOutModel _shell = (ShellOutModel)lstShellOut.SelectedItem;
            string        _strId = _shell.PaymentId.ToString();

            if (_strId.Length >= 3)
            {
                _strId = _strId.Remove(2);
            }
            if (Convert.ToInt32(_strId) == 11)
            {
                return;
            }
            if (_shell.PaymentBalance.Trim().Length == 1)
            {
                _shell.PaymentBalance = "0";
            }
            else
            {
                string  _strSeparator = (StaticClass.GeneralClass.app_settings["decimalSeparator"].ToString() == "0") ? "." : ",";
                string  _tmpVal       = _shell.PaymentBalance.Remove(_shell.PaymentBalance.Length - 1, 1);
                decimal _tmpDec       = StaticClass.GeneralClass.ConverStringToDecimal(_tmpVal);
                _tmpVal = Convert.ToString(_tmpDec);
                int _ind = _tmpVal.IndexOf(_strSeparator);
                if (_ind > 0)
                {
                    string _strNumberDecimalSeparator = _tmpVal.Substring(_ind + 1);
                    _shell.PaymentBalance = StaticClass.GeneralClass.FormatNumberDisplay(_tmpDec, _strNumberDecimalSeparator.Length);
                }
                else
                {
                    _shell.PaymentBalance = StaticClass.GeneralClass.FormatNumberDisplay(_tmpDec, 0);
                }
            }
            buttonAddRemovePayment_Click(null, null);
            isEnableInvoice();
        }
示例#9
0
        private void isEnableInvoice()
        {
            decimal _balane = 0;

            foreach (var _selectedShell in lstShellOut.Items)
            {
                ShellOutModel _shellOut = (ShellOutModel)_selectedShell;
                _balane += StaticClass.GeneralClass.ConverStringToDecimal(_shellOut.PaymentBalance);
            }
            decimal lastBalance = StaticClass.GeneralClass.ConverStringToDecimal(StaticClass.GeneralClass.GetNumFormatDisplay(_balane - total));

            tblCashBalance.Text = StaticClass.GeneralClass.GetNumFormatDisplay(lastBalance);
            if (_balane >= 0 && lastBalance >= 0)
            {
                btnSaveInvoice.IsEnabled   = true;
                btnSaveSendEmail.IsEnabled = true;
                mainButtonAdd.Visibility   = Visibility.Hidden;

                /*
                 * muiBtnAdd.Visibility = Visibility.Hidden;
                 * btRemovePayment.Visibility = Visibility.Hidden;
                 */
                btnSaveInvoice.Focus();
            }
            else
            {
                buttonAddRemovePayment_Click(null, null);
                mainButtonAdd.Visibility = Visibility.Visible;

                /*
                 * muiBtnAdd.Visibility = Visibility.Hidden;
                 * btRemovePayment.Visibility = Visibility.Visible;
                 */
                btnClose.Focus();
            }
        }
示例#10
0
        //ModernDialog_KeyDown
        private void ModernDialog_KeyDown(object sender, KeyEventArgs e)
        {
            ShellOutModel msShellout = (ShellOutModel)lstShellOut.Items[lstShellOut.SelectedIndex];
            string        _strId     = msShellout.PaymentId.ToString();

            if (_strId.Length >= 3)
            {
                _strId = _strId.Remove(2);
            }
            if (Convert.ToInt32(_strId) == 11)
            {
                return;
            }
            ShellOutModel _default      = (ShellOutModel)lstShellOut.Items[0];
            string        _strSeparator = (StaticClass.GeneralClass.app_settings["decimalSeparator"].ToString() == "0") ? "." : ",";
            string        strVal        = msShellout.PaymentBalance.ToString();
            string        strkey        = GetCharFromKey(e.Key).ToString();

            if (GetCharFromKey(e.Key).ToString() == _strSeparator)
            {
                if (!msShellout.PaymentBalance.Trim().Contains(strkey))
                {
                    strVal += GetCharFromKey(e.Key).ToString();
                }
                msShellout.PaymentBalance = strVal;
                isEnableInvoice();
            }
            try
            {
                int num;
                if (int.TryParse(GetCharFromKey(e.Key).ToString(), out num))
                {
                    string _strCompare = Convert.ToString(StaticClass.GeneralClass.ConverStringToDecimal(strVal)) + strkey;
                    if (Convert.ToDouble(_strCompare) < 999999999.99)
                    {
                        if (msShellout.PaymentId == 1)
                        {
                            if (StaticClass.GeneralClass.ConverStringToDecimal(strVal) == 0)
                            {
                                strVal = GetCharFromKey(e.Key).ToString();
                            }
                            else
                            {
                                int ind = strVal.IndexOf(_strSeparator);
                                if (ind > 0)
                                {
                                    string _strNumberDecimalSeparator = strVal.Substring(ind + 1);
                                    if (_strNumberDecimalSeparator.Length < 2)
                                    {
                                        strVal += GetCharFromKey(e.Key).ToString();
                                    }
                                }
                                else
                                {
                                    strVal += GetCharFromKey(e.Key).ToString();
                                }
                            }
                            int _ind = strVal.IndexOf(_strSeparator);
                            if (_ind > 0)
                            {
                                string _strNumberDecimalSeparator = strVal.Substring(_ind + 1);
                                msShellout.PaymentBalance = StaticClass.GeneralClass.FormatNumberDisplay(StaticClass.GeneralClass.ConverStringToDecimal(strVal), _strNumberDecimalSeparator.Length);
                            }
                            else
                            {
                                msShellout.PaymentBalance = StaticClass.GeneralClass.FormatNumberDisplay(StaticClass.GeneralClass.ConverStringToDecimal(strVal), 0);
                            }
                            isEnableInvoice();
                        }
                        else if (CalculateTotalBalance(msShellout.PaymentId, StaticClass.GeneralClass.ConverStringToDecimal(strVal + strkey)) <= StaticClass.GeneralClass.ConverStringToDecimal(_default.PaymentBalance))
                        {
                            if (StaticClass.GeneralClass.ConverStringToDecimal(strVal) == 0)
                            {
                                strVal = GetCharFromKey(e.Key).ToString();
                            }
                            else
                            {
                                int ind = strVal.IndexOf(_strSeparator);
                                if (ind > 0)
                                {
                                    string _strNumberDecimalSeparator = strVal.Substring(ind + 1);
                                    if (_strNumberDecimalSeparator.Length < 2)
                                    {
                                        strVal += GetCharFromKey(e.Key).ToString();
                                    }
                                }
                                else
                                {
                                    strVal += GetCharFromKey(e.Key).ToString();
                                }
                            }
                            int _ind = strVal.IndexOf(_strSeparator);
                            if (_ind > 0)
                            {
                                string _strNumberDecimalSeparator = strVal.Substring(_ind + 1);
                                msShellout.PaymentBalance = StaticClass.GeneralClass.FormatNumberDisplay(StaticClass.GeneralClass.ConverStringToDecimal(strVal), _strNumberDecimalSeparator.Length);
                            }
                            else
                            {
                                msShellout.PaymentBalance = StaticClass.GeneralClass.FormatNumberDisplay(StaticClass.GeneralClass.ConverStringToDecimal(strVal), 0);
                            }
                            isEnableInvoice();
                        }
                        else
                        {
                            ModernDialog md = new ModernDialog();
                            md.CloseButton.FindResource("close").ToString();
                            md.Content = App.Current.FindResource("payment_balance_less_cash_balance").ToString();
                            md.Title   = App.Current.FindResource("notification").ToString();
                            md.ShowDialog();
                        }
                    }
                }
                //enter key press
                if (e.Key.ToString() == "Return")
                {
                    //btnEnter_Click(null, null);
                }

                //back key press
                if (e.Key.ToString() == "Back")
                {
                    string _strVal = msShellout.PaymentBalance.ToString();
                    if (_strVal.Length == 1)
                    {
                        msShellout.PaymentBalance = "0";
                    }
                    else
                    {
                        _strVal = _strVal.Remove(_strVal.Length - 1, 1);
                        decimal _tmpDec = StaticClass.GeneralClass.ConverStringToDecimal(_strVal);
                        _strVal = Convert.ToString(_tmpDec);
                        int _ind = _strVal.IndexOf(_strSeparator);
                        if (_ind > 0)
                        {
                            string _strNumberDecimalSeparator = _strVal.Substring(_ind + 1);
                            msShellout.PaymentBalance = StaticClass.GeneralClass.FormatNumberDisplay(_tmpDec, _strNumberDecimalSeparator.Length);
                        }
                        else
                        {
                            msShellout.PaymentBalance = StaticClass.GeneralClass.FormatNumberDisplay(_tmpDec, 0);
                        }
                    }
                    isEnableInvoice();
                }
            }
            catch (Exception ex)
            {
                Pages.Notification page = new Pages.Notification();
                page.tblNotification.Text = ex.Message;
                page.ShowDialog();
            }
        }
示例#11
0
        private bool PayOrder()
        {
            int  quantity = StaticClass.GeneralClass.list_ec_tb_orderdetail_general.Count;
            bool result   = false;

            if (quantity > 0)
            {
                //create Order
                EC_tb_Order ec_tb_order = new EC_tb_Order();
                ec_tb_order.CustomerID      = StaticClass.GeneralClass.customerid_general;
                ec_tb_order.CustomerName    = StaticClass.GeneralClass.customername_general;
                ec_tb_order.Quatity         = quantity;
                ec_tb_order.OrderDate       = System.DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss tt");
                ec_tb_order.SalesPersonID   = StaticClass.GeneralClass.salespersonid_login_general;
                ec_tb_order.SalesPersonName = StaticClass.GeneralClass.salespersonname_login_general;
                this.Dispatcher.Invoke((Action)(() =>
                {
                    ShellOutModel shellPayMent = (ShellOutModel)lstShellOut.Items[0];
                    ec_tb_order.PaymentID = Convert.ToInt16(shellPayMent.PaymentId); //paymentid;
                    ec_tb_order.PaymentName = shellPayMent.PaymentName;              //paymentname;
                }));
                ec_tb_order.DiscountType  = StaticClass.GeneralClass.discounttype_general;
                ec_tb_order.Discount      = StaticClass.GeneralClass.discount_general;
                ec_tb_order.TotalDiscount = StaticClass.GeneralClass.totaldiscount_general;
                ec_tb_order.TotalTax      = StaticClass.GeneralClass.totaltaxrate_general;
                ec_tb_order.TotalAmount   = total;

                if (bus_tb_order.InsertOrder(ec_tb_order, StaticClass.GeneralClass.flag_database_type_general) == 1)
                {
                    int num_orderdetail_inserted = 0;

                    foreach (EC_tb_OrderDetail ec_tb_orderdetail in StaticClass.GeneralClass.list_ec_tb_orderdetail_general)
                    {
                        //ec_tb_orderdetail.ID = bus_tb_orderdetail.GetMaxID("") + 1;
                        ec_tb_order.OrderID       = bus_tb_order.GetMaxOrderID("");
                        ec_tb_orderdetail.OrderID = ec_tb_order.OrderID;

                        if (bus_tb_orderdetail.InsertOrderDetail(ec_tb_orderdetail, StaticClass.GeneralClass.flag_database_type_general) == 1)
                        {
                            num_orderdetail_inserted++;

                            //update InventoryCount for Product
                            EC_tb_Product ec_tb_product = new EC_tb_Product();
                            ec_tb_product.ProductID      = ec_tb_orderdetail.ProductID;
                            ec_tb_product.InventoryCount = ec_tb_orderdetail.Qty;
                            bus_tb_product.UpdateInventoryCount(ec_tb_product);
                            ShellOutViewModel.eventSavePaymentOther(ec_tb_order.OrderID, null);
                        }
                    }
                    //if insert orderdetai success
                    if (num_orderdetail_inserted > 0)
                    {
                        result = true;
                    }

                    //if insert orderdetail failed
                    else
                    {
                        if (bus_tb_order.DeleteOrder(ec_tb_order) == 1)
                        {
                            result = false;
                        }
                    }
                }
            }
            return(result);
        }
示例#12
0
        private void btnNum_Click(object sender, RoutedEventArgs e)
        {
            ShellOutModel _shell = (ShellOutModel)lstShellOut.SelectedItem;
            string        _strId = _shell.PaymentId.ToString();

            if (_strId.Length >= 3)
            {
                _strId = _strId.Remove(2);
            }
            if (Convert.ToInt32(_strId) == 11)
            {
                return;
            }
            ShellOutModel _default    = (ShellOutModel)lstShellOut.Items[0];
            string        _strVal     = _shell.PaymentBalance + (sender as Button).Uid;
            string        _strCompare = Convert.ToString(StaticClass.GeneralClass.ConverStringToDecimal(_strVal));
            string        strVal      = _shell.PaymentBalance;

            if (Convert.ToDouble(_strCompare) < 999999999.99)
            {
                string  _strSeparator = (StaticClass.GeneralClass.app_settings["decimalSeparator"].ToString() == "0") ? "." : ",";
                int     ind           = strVal.IndexOf(_strSeparator);
                decimal _totalBalance = StaticClass.GeneralClass.ConverStringToDecimal(tblCashBalance.Text);
                if (_shell.PaymentId == 1)
                {
                    if (strVal != "0")
                    {
                        if (ind > 0)
                        {
                            string _strNumberDecimalSeparator = strVal.Substring(ind + 1);
                            if (_strNumberDecimalSeparator.Length < 2)
                            {
                                strVal += (sender as Button).Uid;
                            }
                        }
                        else
                        {
                            strVal += (sender as Button).Uid;
                        }
                    }
                    else if ((sender as Button).Uid != "0")
                    {
                        strVal = (sender as Button).Uid;
                    }

                    int _ind = strVal.IndexOf(_strSeparator);
                    if (_ind > 0)
                    {
                        string _strNumberDecimalSeparator = strVal.Substring(_ind + 1);
                        _shell.PaymentBalance = StaticClass.GeneralClass.FormatNumberDisplay(StaticClass.GeneralClass.ConverStringToDecimal(strVal), _strNumberDecimalSeparator.Length);
                    }
                    else
                    {
                        _shell.PaymentBalance = StaticClass.GeneralClass.FormatNumberDisplay(StaticClass.GeneralClass.ConverStringToDecimal(strVal), 0);
                    }
                    isEnableInvoice();
                }
                else if (CalculateTotalBalance(_shell.PaymentId, StaticClass.GeneralClass.ConverStringToDecimal(_strVal)) <= StaticClass.GeneralClass.ConverStringToDecimal(_default.PaymentBalance))
                {
                    if (strVal != "0")
                    {
                        if (ind > 0)
                        {
                            string _strNumberDecimalSeparator = strVal.Substring(ind + 1);
                            if (_strNumberDecimalSeparator.Length < 2)
                            {
                                strVal += (sender as Button).Uid;
                            }
                        }
                        else
                        {
                            strVal += (sender as Button).Uid;
                        }
                    }
                    else if ((sender as Button).Uid != "0")
                    {
                        strVal = (sender as Button).Uid;
                    }

                    int _ind = strVal.IndexOf(_strSeparator);
                    if (_ind > 0)
                    {
                        string _strNumberDecimalSeparator = strVal.Substring(_ind + 1);
                        _shell.PaymentBalance = StaticClass.GeneralClass.FormatNumberDisplay(StaticClass.GeneralClass.ConverStringToDecimal(strVal), _strNumberDecimalSeparator.Length);
                    }
                    else
                    {
                        _shell.PaymentBalance = StaticClass.GeneralClass.FormatNumberDisplay(StaticClass.GeneralClass.ConverStringToDecimal(strVal), 0);
                    }
                    isEnableInvoice();
                }
                else
                {
                    ModernDialog md = new ModernDialog();
                    md.CloseButton.FindResource("close").ToString();
                    md.Content = App.Current.FindResource("payment_balance_less_cash_balance").ToString();
                    md.Title   = App.Current.FindResource("notification").ToString();
                    md.ShowDialog();
                }
            }
        }
示例#13
0
        private void OnEventFillValueGiftCard(object sender, EventArgs e)
        {
            ShellOutModel _shell       = SelectedShellOut as ShellOutModel;
            string        _objToString = sender as string;
            decimal       _strVal      = 0;
            int           found        = 0;

            if (!string.IsNullOrEmpty(_objToString))
            {
                found   = _objToString.IndexOf(":");
                _strVal = StaticClass.GeneralClass.ConverStringToDecimal(_objToString.Substring(found + 1));
            }
            decimal decTotal  = 0;
            decimal tmpTotal_ = 0;
            Int32   _indTemp  = 0;

            foreach (var __shell in ShellOut)
            {
                decTotal += (_indTemp == SelectedIndex) ? 0 : StaticClass.GeneralClass.ConverStringToDecimal(__shell.PaymentBalance.ToString());
                _indTemp++;
            }
            tmpTotal_ = decTotal - _total + Convert.ToDecimal(_strVal);
            if (Convert.ToDecimal(_strVal) == 0)
            {
                _shell.PaymentBalance = StaticClass.GeneralClass.GetNumFormatDisplay(0);
                int    _found     = 0;
                string _strVal_   = string.Empty;
                string _giftValue = string.Empty;
                if (_shell.PaymentId == 11)
                {
                    _giftValue   = _lstIndex[0];
                    _lstIndex[0] = string.Empty;
                    if (!string.IsNullOrEmpty(_giftValue))
                    {
                        _found   = _giftValue.IndexOf(":");
                        _strVal_ = _giftValue.Remove(_found);
                        StaticClass.GeneralClass.customerGiftCard.Remove(Convert.ToInt32(_strVal_));
                    }
                }
                else
                {
                    string _tmpInd = Convert.ToString(_shell.PaymentId).Substring(2);
                    _giftValue = _lstIndex[Convert.ToInt32(_tmpInd)];
                    _lstIndex[Convert.ToInt32(_tmpInd)] = string.Empty;
                    if (!string.IsNullOrEmpty(_giftValue))
                    {
                        _found   = _giftValue.IndexOf(":");
                        _strVal_ = _giftValue.Remove(_found);
                        StaticClass.GeneralClass.customerGiftCard.Remove(Convert.ToInt32(_strVal_));
                    }
                }
            }
            else
            {
                string _giftId = _objToString.Remove(found);
                Int32  _tempIndex;
                if (_shell.PaymentId == 11)
                {
                    _tempIndex = 0;
                }
                else
                {
                    string _tmpInd = Convert.ToString(_shell.PaymentId).Substring(2);
                    _tempIndex = Convert.ToInt32(_tmpInd);
                }
                if (StaticClass.GeneralClass.ConverStringToDecimal(ShellOut[0].PaymentBalance.ToString()) == 0)
                {
                    if (Convert.ToDecimal(_strVal) > ((decTotal - _total) * -1))
                    {
                        _shell.PaymentBalance = StaticClass.GeneralClass.GetNumFormatDisplay(((decTotal - _total) * -1));
                        _lstIndex[_tempIndex] = _giftId + ":" + _shell.PaymentBalance;
                        System.Diagnostics.Debug.WriteLine("1) " + _lstIndex[_tempIndex]);
                    }
                    else
                    {
                        _shell.PaymentBalance = StaticClass.GeneralClass.GetNumFormatDisplay(Convert.ToDecimal(_strVal));
                        _lstIndex[_tempIndex] = _giftId + ":" + _shell.PaymentBalance;
                        System.Diagnostics.Debug.WriteLine("2) " + _lstIndex[_tempIndex]);
                    }
                }
                else
                {
                    decimal _compare = StaticClass.GeneralClass.ConverStringToDecimal(ShellOut[0].PaymentBalance.ToString());
                    if (tmpTotal_ > _compare)
                    {
                        if (StaticClass.GeneralClass.ConverStringToDecimal(txtTotal) < 0)
                        {
                            _strVal = StaticClass.GeneralClass.ConverStringToDecimal(txtTotal) * (-1) + _compare;
                        }
                        else
                        {
                            _strVal = _compare - StaticClass.GeneralClass.ConverStringToDecimal(txtTotal);
                        }
                        _shell.PaymentBalance = StaticClass.GeneralClass.GetNumFormatDisplay(_strVal);
                        _lstIndex[_tempIndex] = _giftId + ":" + _shell.PaymentBalance;
                        System.Diagnostics.Debug.WriteLine("3) " + _lstIndex[_tempIndex]);
                    }
                    else
                    {
                        _shell.PaymentBalance = StaticClass.GeneralClass.GetNumFormatDisplay(_strVal);
                        _lstIndex[_tempIndex] = _giftId + ":" + _shell.PaymentBalance;
                        System.Diagnostics.Debug.WriteLine("4) " + _lstIndex[_tempIndex]);
                    }
                }
            }
            CanculatorTotalBalance();
        }
示例#14
0
        private void onEventRemoveShellOut(object parameter)
        {
            int _shellSelected = SelectedIndex;

            if (ShellOut.Count() == 1)
            {
                _shellSelected = 0;
            }
            else if (_shellSelected == ShellOut.Count() - 1)
            {
                _shellSelected = ShellOut.Count() - 2;
            }
            if (parameter == null)
            {
                ModernDialog md = new ModernDialog();
                md.CloseButton.FindResource("close").ToString();
                md.Content = "Please select payment to delete !";
                md.Title   = App.Current.FindResource("notification").ToString();
                md.ShowDialog();
            }
            else
            {
                ShellOutModel shellout = (ShellOutModel)parameter;
                StaticClass.GeneralClass.lstCash.Remove(shellout.PaymentId);
                int    _index       = SelectedIndex;
                string _customgift_ = ShellOut[_index].PaymentId.ToString();
                if (Convert.ToInt32(_customgift_) == 11)
                {
                    string _giftValue = _lstIndex[0];
                    if (!string.IsNullOrEmpty(_giftValue))
                    {
                        _lstIndex[0] = string.Empty;
                        int    _found   = _giftValue.IndexOf(":");
                        string _strVal_ = _giftValue.Remove(_found);
                        StaticClass.GeneralClass.customerGiftCard.Remove(Convert.ToInt32(_strVal_));
                    }
                }
                else if (_customgift_.Length >= 3)
                {
                    int    _tempIndex_ = Convert.ToInt16(_customgift_.Remove(0, 2));
                    string _giftValue  = _lstIndex[_tempIndex_];
                    if (!string.IsNullOrEmpty(_giftValue))
                    {
                        _lstIndex[_tempIndex_] = string.Empty;
                        int    _found   = _giftValue.IndexOf(":");
                        string _strVal_ = _giftValue.Remove(_found);
                        StaticClass.GeneralClass.customerGiftCard.Remove(Convert.ToInt32(_strVal_));
                    }
                }
                ShellOut.RemoveAt(_index);
                CanculatorTotalBalance();
                SelectedIndex = _shellSelected;
                _isDeleting   = false;
                string _strId = ShellOut[SelectedIndex].PaymentId.ToString();
                if (_strId.Length >= 3)
                {
                    _strId = _strId.Remove(2);
                }
                if (Convert.ToInt32(_strId) == 11 && !_isDeleting)
                {
                    onMouseDownCmdEvent(null);
                }
            }
        }