//销售单
 private void querySaleOrder()
 {
     if (this.dgvMain.SelectedRows.Count <= 0)
     {
         return;
     }
     Business.Models.DeliveryModel          dm  = this.dgvMain.SelectedRows[0].DataBoundItem as Business.Models.DeliveryModel;
     Models.SalesOrder                      c   = this.PharmacyDatabaseService.GetSalesOrder(out msg, dm.SalesOrderID);
     Forms.SalesBusiness.FormSalesOrderEdit frm = new SalesBusiness.FormSalesOrderEdit(c, false);
     frm.ShowDialog();
 }
Beispiel #2
0
        //右键方法
        private void RightMenuClick(int qType)
        {
            if (qType == 0)//查销售单
            {
                Guid sid = ((Business.Models.DrugPath) this.dataGridView1.CurrentRow.DataBoundItem).salesOrderID;
                SalesBusiness.FormSalesOrderEdit frm = new SalesBusiness.FormSalesOrderEdit(this.PharmacyDatabaseService.GetSalesOrder(out msg, sid), true);
                frm.ShowDialog();
            }
            if (qType == 1)//查采购单
            {
                Guid pid = ((Business.Models.DrugPath) this.dataGridView1.CurrentRow.DataBoundItem).purchaseOrderID;
                if (pid.Equals(Guid.Empty))
                {
                    MessageBox.Show("前期库存,无入信息");
                    return;
                }
                Business.Models.PurchaseOrdeEntity           poe = this.PharmacyDatabaseService.GetPurchaseOrderEntity(out msg, pid);
                Forms.PurchaseBusiness.FormPurchaseOrderEdit frm = new Forms.PurchaseBusiness.FormPurchaseOrderEdit(poe, false, true);
                frm.ShowDialog();
            }
            if (qType == 2)//查看该批号
            {
                string batchNumber = ((DrugPathExpandable)this.dataGridView1.CurrentRow.DataBoundItem).batchNumber;
                Guid   sid         = ((DrugPathExpandable)this.dataGridView1.CurrentRow.DataBoundItem).salesOrderID;
                this.dataGridView1.DataSource = null;
                this.ListDrugPath             = this.GetListPathExpandable(batchNumber, Guid.Empty);
                this.dataGridView1.DataSource = this.ListDrugPath;
            }
            if (qType == 8)//按批号查询
            {
                string batchNumber = ((DrugPathExpandable)this.dataGridView1.CurrentRow.DataBoundItem).batchNumber;
                if (this.Batchfrm == null || this.Batchfrm.IsDisposed)
                {
                    this.Batchfrm = new PurchaseBusiness.Form_FormPurchaseHistoryBySupplyer_Batch(batchNumber);
                }
                Batchfrm.StartPosition = FormStartPosition.CenterScreen;
                Batchfrm.Show(this);
                Batchfrm.GetBatch += (sender, ex) =>
                {
                    this.dataGridView1.DataSource = null;
                    this.ListDrugPath             = this.GetListPathExpandable(batchNumber, Guid.Empty, ex.IsPrecise);
                    this.dataGridView1.DataSource = this.ListDrugPath;
                };
            }
            if (qType == 3)//查看该品种最近入库的购销记录
            {
                var d = this.ListDrugPathAll.Where(r => r.inInventoryDate != null);
                if (d.Count() <= 0)
                {
                    MessageBox.Show("前期库存,无入信息");
                    return;
                }
                var    LastInventoryDate = d.Max(r => r.inInventoryDate);
                string batch             = this.ListDrugPathAll.Where(r => r.inInventoryDate == LastInventoryDate).FirstOrDefault().batchNumber;
                this.ListDrugPath = this.GetListPathExpandable(batch, Guid.Empty);

                this.dataGridView1.DataSource = new BindingCollection <DrugPathExpandable>(this.ListDrugPath);
            }
            if (qType == 4)//查看该批次最近入库的购销记录
            {
                string batchNumber = ((Business.Models.DrugPath) this.dataGridView1.CurrentRow.DataBoundItem).batchNumber;
                var    c           = this.ListDrugPathAll.Where(r => r.batchNumber == batchNumber);
                var    d           = c.Where(r => r.inInventoryDate != null);
                if (d.Count() <= 0)
                {
                    MessageBox.Show("前期库存,无入信息");
                    return;
                }
                var    LastInventoryDate = d.Max(r => r.inInventoryDate);
                string batch             = this.ListDrugPathAll.Where(r => r.inInventoryDate == LastInventoryDate).FirstOrDefault().batchNumber;
                this.ListDrugPath             = this.GetListPathExpandable(batch, Guid.Empty);
                this.dataGridView1.DataSource = new BindingCollection <DrugPathExpandable>(this.ListDrugPath);
            }
            if (qType == 5)//查看全部
            {
                this.ListDrugPath             = this.GetListPathExpandable(string.Empty, Guid.Empty);
                this.dataGridView1.DataSource = this.ListDrugPath;
            }
            if (qType == 6)//求和
            {
                DataGridViewSelectedCellCollection sc = this.dataGridView1.SelectedCells;
                List <decimal> ListD = new List <decimal>();
                foreach (DataGridViewCell r in sc)
                {
                    decimal d = 0m;
                    bool    b = Decimal.TryParse(r.Value.ToString(), out d);
                    if (!b)
                    {
                        MessageBox.Show("您所选择的单元格含有非数字,请取消其选择,谢谢!");
                        return;
                    }
                    ListD.Add(d);
                }
                decimal result = ListD.Sum();
                MessageBox.Show("统计结果是:" + result.ToString("F4"));
                cms.Items["Sum"].Enabled = false;
            }
            if (qType == 7)//汇总
            {
                var c = from i in this.GetListPathExpandable(string.Empty, Guid.Empty)
                        group i by i.batchNumber into g
                        select new DrugPathExpandable
                {
                    drugName    = g.FirstOrDefault().drugName,
                    batchNumber = g.FirstOrDefault().batchNumber,
                    PurchaseOrderDocumentNumber = g.FirstOrDefault().PurchaseOrderDocumentNumber,
                    dosage          = g.FirstOrDefault().dosage,
                    specific        = g.FirstOrDefault().specific,
                    factoryName     = g.FirstOrDefault().factoryName,
                    permitNumber    = g.FirstOrDefault().permitNumber,
                    saleCount       = g.Sum(r => r.saleCount),
                    invenotryNumber = g.FirstOrDefault().invenotryNumber,

                    cansaleNum     = g.FirstOrDefault().cansaleNum,
                    SupplyUnitName = g.FirstOrDefault().SupplyUnitName,
                    IsExpandable   = false,
                    IsExpanded     = false
                };
                this.dataGridView1.DataSource          = new BindingCollection <DrugPathExpandable>(c.OrderBy(r => r.batchNumber).ToList());
                cms.Items["OpenSaleOrder"].Enabled     = false;
                cms.Items["OpenPurchaseOrder"].Enabled = false;
            }
            else
            {
                cms.Items["OpenSaleOrder"].Enabled     = true;
                cms.Items["OpenPurchaseOrder"].Enabled = true;
            }
        }