Пример #1
0
        private void RetrieveDjMx(bool recursion)
        {
            DataTable dt = service.ExecuteReturnTb(this.GetType().ToString(), "SearchDj", new string[] { "p_djh:%" + txtRqh.Text + "%" }, out selectSql, out errMsg);

            if (!string.IsNullOrEmpty(errMsg))
            {
                MessageBox.Show(errMsg);
                txtRqh.Focus();
                txtRqh.SelectAll();
                return;
            }
            string selectDjh = "";

            if (dt.Rows.Count > 1)
            {
                SelectItemWindow form = new SelectItemWindow(dt);
                form.StartPosition = FormStartPosition.CenterParent;
                if (form.ShowDialog() != DialogResult.OK)
                {
                    return;
                }

                selectDjh = form.dic["单据号"];
            }
            else if (dt.Rows.Count == 0)
            {
                if (!recursion)
                {
                    MessageBox.Show("没有这张单据");
                    return;
                }
                dt = service.ExecuteReturnTb(this.GetType().ToString(), "PROC_TRANS_YBSJH3", null, out selectSql, out errMsg);
                if (!string.IsNullOrEmpty(errMsg))
                {
                    MessageBox.Show(errMsg);
                    txtRqh.Focus();
                    txtRqh.SelectAll();
                    return;
                }

                RetrieveDjMx(false);
            }
            else
            {
                selectDjh = dt.Rows[0]["单据号"].ToString();
            }

            Clear();
            RefreshDjMx(selectDjh);

            //GridView view = gridControl1.MainView as GridView;
            //view.Columns["ZT"].SortOrder = DevExpress.Data.ColumnSortOrder.Ascending;

            //GridColumnSummaryItem siTotal = new GridColumnSummaryItem();
            //siTotal.SummaryType = SummaryItemType.Count;
            //siTotal.DisplayFormat = "({0} records)";

            //view.Columns["ISBN"].SummaryItem.Collection.Add(siTotal);

            //view.OptionsView.ShowFooter = true;
        }
Пример #2
0
        private void txtIsbn_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter && !string.IsNullOrWhiteSpace(txtIsbn.Text))
            {
                if (string.IsNullOrWhiteSpace(rqh))
                {
                    return;
                }

                GridView view = gridControl1.MainView as GridView;
                if (view == null)
                {
                    return;
                }
                if (view.RowCount == 0)
                {
                    return;
                }

                int    lastJh = -1, rowHandle = 0;
                string sameIsbn   = "0";
                bool   find       = false;
                bool   bdirection = false;
                do
                {
                    rowHandle = view.LocateByDisplayText(rowHandle, view.Columns["ISBN"], txtIsbn.Text);
                    if (rowHandle < 0)
                    {
                        if (find)
                        {
                            view.FocusedRowHandle = lastJh;
                            if (bdirection)
                            {
                                MessageBox.Show("已经校核过了");
                            }
                            else
                            {
                                MessageBox.Show("无去向不能校核");
                            }

                            txtIsbn.Focus();
                            txtIsbn.SelectAll();
                            return;
                        }
                        else
                        {
                            view.FocusedRowHandle = -1;
                            MessageBox.Show("当前书目不在此箱,请重新扫描!");
                            txtIsbn.Focus();
                            txtIsbn.SelectAll();
                            return;
                        }
                    }
                    else
                    {
                        lastJh   = rowHandle;
                        find     = true;
                        sameIsbn = view.GetRowCellValue(rowHandle, "SAMEISBN").ToString();
                        string direction = view.GetRowCellDisplayText(rowHandle, "去向").ToString();
                        string zt        = view.GetRowCellDisplayText(rowHandle, "状态").ToString();
                        if (direction == "无去向")
                        {
                            rowHandle++;
                            bdirection = false;
                            continue;
                        }
                        bdirection = true;
                        if (sameIsbn == "1")
                        {
                            if (zt == "未校核")
                            {
                                break;
                            }
                            else
                            {
                                rowHandle++;
                                continue;
                            }
                        }
                        else
                        {
                            if (zt == "未校核")
                            {
                                break;
                            }
                            else
                            {
                                view.FocusedRowHandle = rowHandle;
                                MessageBox.Show("已经校核过了");
                                txtIsbn.Focus();
                                txtIsbn.SelectAll();
                                return;
                            }
                        }
                    }
                } while (rowHandle >= 0);

                if (sameIsbn == "1")
                {
                    List <string> param1 = new List <string>();
                    param1.Add("p_isbn:" + txtIsbn.Text);
                    param1.Add("p_djh:" + rqh);
                    DataTable dt = service.ExecuteReturnTb(this.GetType().ToString(), "SearchSameIsbn", param1.ToArray(), out selectSql, out errMsg);
                    if (!string.IsNullOrEmpty(errMsg))
                    {
                        MessageBox.Show(errMsg);
                        txtIsbn.Focus();
                        txtIsbn.SelectAll();
                        return;
                    }
                    // DataRow[] drs= (gridControl1.DataSource as DataTable).Select("isbn='"+ txtIsbn.Text+"' and 状态='0'");
                    //SelectItemWindow form = new SelectItemWindow(drs.CopyToDataTable());
                    SelectItemWindow form = new SelectItemWindow(dt);
                    if (form.ShowDialog() != DialogResult.OK)
                    {
                        return;
                    }

                    string selectId = form.dic["ID"];
                    rowHandle = view.LocateByDisplayText(0, view.Columns["ID"], selectId);
                }

                view.FocusedRowHandle = rowHandle;

                string sm = view.GetRowCellValue(rowHandle, "书名").ToString();
                string dj = view.GetRowCellValue(rowHandle, "定价").ToString();
                string id = view.GetRowCellValue(rowHandle, "ID").ToString();
                txtSm.Text = sm;
                txtDj.Text = dj;

                List <string> param = new List <string>();
                param.Add("p_id:" + id);
                param.Add("p_djh:" + rqh);
                param.Add("p_ps:" + (ckbPs.Checked?"1":"0"));
                param.Add("p_jhczy:" + UserInfo.userid);
                param.Add("p_jhname:" + UserInfo.username);

                int rows = service.ExecuteReturnInt(this.GetType().ToString(), "UpdateJH", param.ToArray(), out errMsg);
                if (!string.IsNullOrEmpty(errMsg))
                {
                    MessageBox.Show(errMsg);
                    txtIsbn.Focus();
                    txtIsbn.SelectAll();
                    return;
                }
                if (rows == 0)
                {
                    MessageBox.Show("更新失败");
                    txtIsbn.Focus();
                    txtIsbn.SelectAll();
                    return;
                }
                if (ckbPs.Checked)
                {
                    ckbPs.Checked = false;
                    view.SetRowCellValue(rowHandle, view.Columns["破损"], "破损");
                }
                view.SetRowCellValue(rowHandle, view.Columns["状态"], "已校核");
                txtIsbn.Focus();
                txtIsbn.SelectAll();
            }
        }