Beispiel #1
0
        private void DataGridRow_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            var item = datagrid.SelectedItem as VoucherListItem;

            if (item != null)
            {
                ShowSelectedItemEvent?.Invoke(item.id);
            }
            e.Handled = true;
        }
Beispiel #2
0
        private void Datagrid_MouseDoubleClick(object sender, System.Windows.Input.MouseButtonEventArgs e)
        {
            try
            {
                var item = datagrid.SelectedItem as DataRowView;
                if (item != null)
                {
                    int i       = 0;
                    var bFinded = false;
                    for (i = 0; i < mHeaderList.Count; i++)
                    {
                        var header = mHeaderList[i];
                        if (header.label == "ID")
                        {
                            bFinded = true;
                            break;
                        }
                    }
                    if (bFinded)
                    {
                        var  idStr = item.Row.ItemArray[i].ToString();
                        long id    = 0;
                        if (long.TryParse(idStr, out id))
                        {
                            ShowSelectedItemEvent?.Invoke(id);
                        }
                    }
                }

                e.Handled = true;
            }
            catch (Exception ex)
            {
                FinanceMessageBox.Error(ex.Message + "\r\n以数据集中作为ID列的数字找到凭证的,请检查存储过程是否正确。");
            }
        }
Beispiel #3
0
        private void btn_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                var txt = (sender as Button).Name;
                IDictionary <long, FinanceApiException> dictException = new Dictionary <long, FinanceApiException>();
                switch (txt)
                {
                case "new":
                    ShowSelectedItemEvent?.Invoke(0);
                    break;

                case "query":
                    FormVoucherListFilterPopup frmFilter = new FormVoucherListFilterPopup();
                    frmFilter.Filter            = m_filter;
                    frmFilter.FilterPopupEvent += (args) =>
                    {
                        m_filter = args.Filter;
                        Refresh();
                    };
                    frmFilter.Show();
                    break;

                case "delete":
                    DoActionSelectedItems((id) => {
                        try
                        {
                            DataFactory.Instance.GetVoucherExecuter().Delete(id);
                        }
                        catch (FinanceApiException apiEx)
                        {
                            dictException.Add(id, apiEx);
                        }
                    });
                    break;

                case "check":
                    DoActionSelectedItems((id) => {
                        try
                        {
                            DataFactory.Instance.GetVoucherExecuter().Check(id);
                        }
                        catch (FinanceApiException apiEx)
                        {
                            dictException.Add(id, apiEx);
                        }
                    });
                    break;

                case "uncheck":
                    DoActionSelectedItems((id) => {
                        try
                        {
                            DataFactory.Instance.GetVoucherExecuter().UnCheck(id);
                        }
                        catch (FinanceApiException apiEx)
                        {
                            dictException.Add(id, apiEx);
                        }
                    });
                    break;

                case "cancel":
                    DoActionSelectedItems((id) => {
                        try
                        {
                            DataFactory.Instance.GetVoucherExecuter().Cancel(id);
                        }
                        catch (FinanceApiException apiEx)
                        {
                            dictException.Add(id, apiEx);
                        }
                    });
                    break;

                case "uncancel":
                    DoActionSelectedItems((id) => {
                        try
                        {
                            DataFactory.Instance.GetVoucherExecuter().UnCancel(id);
                        }
                        catch (FinanceApiException apiEx)
                        {
                            dictException.Add(id, apiEx);
                        }
                    });
                    break;

                case "post":
                    DoActionSelectedItems((id) => {
                        try
                        {
                            DataFactory.Instance.GetVoucherExecuter().Post(id);
                        }
                        catch (FinanceApiException apiEx)
                        {
                            dictException.Add(id, apiEx);
                        }
                    });
                    break;

                case "unpost":
                    DoActionSelectedItems((id) => {
                        try
                        {
                            DataFactory.Instance.GetVoucherExecuter().UnPost(id);
                        }
                        catch (FinanceApiException apiEx)
                        {
                            dictException.Add(id, apiEx);
                        }
                    });
                    break;
                }
                if (dictException.Count > 0)
                {
                    StringBuilder sb = new StringBuilder();
                    foreach (KeyValuePair <long, FinanceApiException> kv in dictException)
                    {
                        sb.AppendLine(string.Format("凭证【{0}】操作失败,{1}", GetVoucherWordNo(kv.Key), kv.Value.Message));
                    }
                    FinanceMessageBox.Error(sb.ToString());
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
                FinanceMessageBox.Error(ex.Message);
            }
        }