private void Search()
        {
            this.labelStatus.Text = "搜索中...";

            new Thread(new ThreadStart(() =>
            {
                var wmsEntities = new WMSEntities();
                //ReceiptTicketView[] receiptTicketViews = null;
                SubmissionTicketView[] submissionTicketView = null;
                try
                {
                    submissionTicketView = wmsEntities.Database.SqlQuery <SubmissionTicketView>(String.Format("SELECT * FROM SubmissionTicketView WHERE ReceiptTicketID={0}", receiptTicketID)).ToArray();
                }
                catch
                {
                    MessageBox.Show("无法连接到数据库,请查看网络连接!", "警告", MessageBoxButtons.YesNo, MessageBoxIcon.Error);
                    return;
                }
                this.reoGridControlPutaway.Invoke(new Action(() =>
                {
                    this.labelStatus.Text = "搜索完成";
                    var worksheet         = this.reoGridControlPutaway.Worksheets[0];
                    worksheet.DeleteRangeData(RangePosition.EntireRange);
                    int n = 0;
                    for (int i = 0; i < submissionTicketView.Length; i++)
                    {
                        if (submissionTicketView[i].State == "作废")
                        {
                            continue;
                        }
                        SubmissionTicketView curSubmissionTicketView = submissionTicketView[i];
                        object[] columns = Utilities.GetValuesByPropertieNames(curSubmissionTicketView, (from kn in ReceiptMetaData.submissionTicketKeyName select kn.Key).ToArray());
                        for (int j = 0; j < worksheet.Columns; j++)
                        {
                            if (columns[j] == null)
                            {
                                worksheet[n, j] = columns[j];
                            }
                            else
                            {
                                worksheet[n, j] = columns[j].ToString();
                            }
                        }
                        n++;
                    }
                }));
                this.Invoke(new Action(this.RefreshTextBoxes));
            })).Start();
        }
Exemple #2
0
        private void buttonGo_Click(object sender, EventArgs e)
        {
            var worksheet = this.reoGridControl1.Worksheets[0];
            //try
            //{
            WMSEntities wmsEntities = new WMSEntities();

            if (worksheet.SelectionRange.Rows != 1)
            {
                MessageBox.Show("请选择一项进行修改", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            int submissionTicketID;

            try
            {
                submissionTicketID = int.Parse(worksheet[worksheet.SelectionRange.Row, 0].ToString());
            }
            catch
            {
                MessageBox.Show("请选择一项进行修改", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            SubmissionTicketView submissionTicketView = (from rt in wmsEntities.SubmissionTicketView where rt.ID == submissionTicketID select rt).FirstOrDefault();

            if (submissionTicketView == null)
            {
                MessageBox.Show("该送检单不存在", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            else
            {
                string key   = "ReceiptTicketNo";
                string name  = (from r in ReceiptMetaData.receiptNameKeys where r.Key == key select r.Name).FirstOrDefault();
                string value = submissionTicketView.ReceiptTicketNo;
                ToPutaway(key, value);
            }
            //}

            //catch (Exception)
            //{
            //    MessageBox.Show("无法连接到数据库,请查看网络连接!", "警告", MessageBoxButtons.YesNo, MessageBoxIcon.Error);
            //    return;
            //}
        }
        private void buttonAll_Click(object sender, EventArgs e)
        {
            WMSEntities wmsEntities = new WMSEntities();
            StandardFormPreviewExcel standardFormPreviewExcel = new StandardFormPreviewExcel("送检单预览");

            SubmissionTicket[] submissionTicket = idsToSubmissionTickets(this.ids);
            try
            {
                foreach (SubmissionTicket st in submissionTicket)
                {
                    string worksheetName = st.ID.ToString();
                    SubmissionTicketView       submissionTicketView     = (from stv in wmsEntities.SubmissionTicketView where stv.ID == st.ID select stv).FirstOrDefault();
                    SubmissionTicketItemView[] submissionTicketItemView =
                        (from p in wmsEntities.SubmissionTicketItemView
                         where p.SubmissionTicketID == st.ID
                         select p).ToArray();
                    ReceiptTicketView receiptTicketView = (from rt in wmsEntities.ReceiptTicketView where rt.ID == st.ReceiptTicketID select rt).FirstOrDefault();
                    if (standardFormPreviewExcel.AddPatternTable(@"Excel\SubmissionTicket.xlsx", worksheetName) == false)
                    {
                        this.Close();
                        return;
                    }
                    if (st != null)
                    {
                        standardFormPreviewExcel.AddData("SubmissionTicket", submissionTicketView, worksheetName);
                    }
                    if (receiptTicketView != null)
                    {
                        standardFormPreviewExcel.AddData("ReceiptTicket", receiptTicketView, worksheetName);
                    }
                    standardFormPreviewExcel.AddData("SubmissionTicketItem", submissionTicketItemView, worksheetName);
                    standardFormPreviewExcel.SetPrintScale(0.82f, worksheetName);
                }
                standardFormPreviewExcel.Show();
                this.Close();
            }
            catch
            {
                MessageBox.Show("无法连接到数据库,请查看网络连接!", "警告", MessageBoxButtons.YesNo, MessageBoxIcon.Error);
                return;
            }

            //StartPreview(submissionTicketItemView);
        }
 private void InitPanel()
 {
     Utilities.CreateEditPanel(this.tableLayoutPanel2, ReceiptMetaData.submissionTicketKeyName);
     this.DeliverSubmissionPersonIDGetter = Utilities.BindTextBoxSelect <FormSelectPerson, Person>(this, "textBoxDeliverSubmissionPersonName", "Name");
     this.SubmissionPersonIDGetter        = Utilities.BindTextBoxSelect <FormSelectPerson, Person>(this, "textBoxSubmissionPersonName", "Name");
     this.ReceivePersonIDGetter           = Utilities.BindTextBoxSelect <FormSelectPerson, Person>(this, "textBoxReceivePersonName", "Name");
     this.PersonIDGetter = Utilities.BindTextBoxSelect <FormSelectPerson, Person>(this, "textBoxPersonName", "Name");
     if (this.formMode == FormMode.ADD)
     {
     }
     else
     {
         WMSEntities          wmsEntities          = new WMSEntities();
         SubmissionTicketView submissionTicketView = (from stv in wmsEntities.SubmissionTicketView where stv.ID == this.submissionTicketID select stv).FirstOrDefault();
         if (submissionTicketView == null)
         {
             MessageBox.Show("找不到此送检单");
             return;
         }
         Utilities.CopyPropertiesToTextBoxes(submissionTicketView, this);
         Utilities.CopyPropertiesToComboBoxes(submissionTicketView, this);
     }
 }
Exemple #5
0
        private void Search(string key, string value)
        {
            this.toolStripStatusLabel2.Text = "搜索中...";

            new Thread(new ThreadStart(() =>
            {
                var wmsEntities = new WMSEntities();
                //ReceiptTicketView[] receiptTicketViews = null;
                SubmissionTicketView[] submissionTicketView = null;
                if (key == null || value == null)        //搜索所有
                {
                    try
                    {
                        submissionTicketView = wmsEntities.Database.SqlQuery <SubmissionTicketView>("SELECT * FROM SubmissionTicketView WHERE WarehouseID = @warehouseID AND ProjectID = @projectID ORDER BY ID DESC", new SqlParameter[] { new SqlParameter("warehouseID", this.warehouseID), new SqlParameter("projectID", this.projectID) }).ToArray();
                    }
                    catch
                    {
                        MessageBox.Show("无法连接到数据库,请查看网络连接!", "警告", MessageBoxButtons.YesNo, MessageBoxIcon.Error);
                        return;
                    }
                }
                else
                {
                    //double tmp;
                    //if (Double.TryParse(value, out tmp) == false) //不是数字则加上单引号
                    //{
                    //    value = "'" + value + "'";
                    //}
                    try
                    {
                        submissionTicketView = wmsEntities.Database.SqlQuery <SubmissionTicketView>(String.Format("SELECT * FROM SubmissionTicketView WHERE {0} = @key AND WarehouseID = @warehouseID AND ProjectID = @projectID ORDER BY ID DESC", key), new SqlParameter[] { new SqlParameter("@key", value), new SqlParameter("@warehouseID", this.warehouseID), new SqlParameter("@projectID", this.projectID) }).ToArray();
                    }
                    catch (EntityException)
                    {
                        MessageBox.Show("查询的值不合法,请输入正确的值!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        return;
                    }
                    catch (Exception)
                    {
                        MessageBox.Show("无法连接到数据库,请查看网络连接!", "警告", MessageBoxButtons.YesNo, MessageBoxIcon.Error);
                        return;
                    }
                }

                this.reoGridControl1.Invoke(new Action(() =>
                {
                    this.toolStripStatusLabel2.Text = "搜索完成";
                    var worksheet = this.reoGridControl1.Worksheets[0];
                    worksheet.DeleteRangeData(RangePosition.EntireRange);
                    int n = 0;
                    for (int i = 0; i < submissionTicketView.Length; i++)
                    {
                        if (submissionTicketView[i].State == "作废")
                        {
                            continue;
                        }
                        SubmissionTicketView curSubmissionTicketView = submissionTicketView[i];
                        object[] columns = Utilities.GetValuesByPropertieNames(curSubmissionTicketView, (from kn in ReceiptMetaData.submissionTicketKeyName select kn.Key).ToArray());
                        for (int j = 0; j < worksheet.Columns; j++)
                        {
                            if (columns[j] == null)
                            {
                                worksheet[n, j] = columns[j];
                            }
                            else
                            {
                                worksheet[n, j] = columns[j].ToString();
                            }
                        }
                        n++;
                    }
                    if (submissionTicketView.Length == 0)
                    {
                        int m = ReceiptUtilities.GetFirstColumnIndex(ReceiptMetaData.submissionTicketKeyName);

                        //this.reoGridControl1.Worksheets[0][6, 8] = "32323";
                        this.reoGridControl1.Worksheets[0][0, m] = "没有查询到符合条件的记录";
                    }
                }));
            })).Start();
        }