Exemple #1
0
        void Init()
        {
            this.lblPODCount.Text = PurchasingOrderUtil.GetPurchasingOrderDetailStatus();

            decimal total = 0.0M;

            SourceListDao slDao = new SourceListDao();
            List <Model.PurchasingOrderDetail> pods = PurchasingOrderUtil.GetPurchasingOrderDetail();

            var q = from s in pods
                    select s.SourceListOID;

            DataTable dt        = new DataTable();
            object    resultObj = null;

            if (!(pods == null || pods.Count == 0))
            {
                dt = slDao.FineSourceListForPOAddMain(q.ToList());

                dt.PrimaryKey = new DataColumn[] { dt.Columns["SourceListOID"] };
                var qs = from pod in pods
                         select new
                {
                    料件編號  = GetDTValue(dt, "料件編號", pod.SourceListOID),
                    料件品名  = GetDTValue(dt, "料件品名", pod.SourceListOID),
                    供應商名稱 = GetDTValue(dt, "供應商名稱", pod.SourceListOID),
                    批量    = GetDTValue(dt, "批量", pod.SourceListOID),
                    批量單價  = $"{Convert.ToDecimal(GetDTValue(dt, "批量單價", pod.SourceListOID)):#.#}",
                    採購數量  = $"{pod.Qty:#.#}",
                    小計    = (Convert.ToDecimal(GetDTValue(dt, "批量單價", pod.SourceListOID)) * pod.Qty).ToString("#.#"),
                    pod.SourceListOID
                };
                var result = qs.ToList();

                foreach (var item in result)
                {
                    total += Convert.ToDecimal(item.小計);
                }
                resultObj = result;
            }

            this.lblTotal.Text = $"採購單金額總計:{total:0.#}";

            this.dataGridView1.Columns.Clear();
            if (resultObj != null)
            {
                this.DataGridViewAddButton();
            }
            this.POD.DataSource           = resultObj;
            this.dataGridView1.DataSource = this.POD;
            if (resultObj != null)
            {
                this.dataGridView1.Columns[this.dataGridView1.GetColumnIndex("SourceListOID")].Visible = false;
            }
            this.btnSendPO.Enabled = !(PurchasingOrderUtil.GetPurchasingOrderDetailCount() == 0);
        }
Exemple #2
0
        void SetShowData(string pn)
        {
            //string partNumber = Convert.ToString(Util.GetSessionValueThenRemove("PartNumber"));
            PartDao pDao = new PartDao();

            this.PartData             = pDao.FindPartByPartNumber(pn);
            this.lblPartNumber.Text   = PartData.PartNumber;
            this.lblPartName.Text     = PartData.PartName;
            this.lblPartSpec.Text     = PartData.PartSpec;
            this.lblUnitPrice.Text    = PartData.UnitPrice.ToString();
            this.lblSupplierName.Text = PartData.GetSupplierInfo().SupplierName;
            SourceListDao slDao = new SourceListDao();

            this.sourceLists = slDao.FindSourceListByPartNumber(PartData.PartNumber);
            var q = from sl in sourceLists
                    select new { Value = sl.SourceListOID, Display = $"批量:{sl.Batch,4} - 折扣:{Math.Round(sl.Discount * 10, 1)}折  - 單價:{Math.Round(PartData.UnitPrice.Value * sl.Batch * sl.Discount, 0)}" };

            this.cbSourceList.DataSource    = q.ToList();
            this.cbSourceList.DisplayMember = "Display";
            this.cbSourceList.ValueMember   = "Value";
        }
 public SourceList GetSourceList()
 {
     PMSWin.PurchasingOrder.SourceListDao dao = new PMSWin.PurchasingOrder.SourceListDao();
     return(dao.FindSourceListBySourceListOID(this.SourceListOID));
 }