private void Selecting_Row(object sender, EventArgs e)
        {
            MetroGrid grid = sender as MetroGrid;

            if (grid.SelectedRows.Count > 0)
            {
                List <POReceiptHeaderModel> rcvs = new List <POReceiptHeaderModel>(); // grid.SelectedRows.DataBoundItem;
                foreach (DataGridViewRow item in grid.SelectedRows)
                {
                    try
                    {
                        POReceiptHeaderModel po = (POReceiptHeaderModel)item.DataBoundItem;
                        rcvs.Add(po);
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message, "Failed", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
                if (rcvs.Count != 0)
                {
                    _view.rcvsSelected = rcvs;
                }
            }
        }
        public void Delete(POReceiptHeaderModel model)
        {
            string sql = @"DELETE FROM po_receipt_headers WHERE receipt_header_id = @receipt_header_id";

            object[] parms = { "@receipt_header_id", model.ReceiptHeaderId };
            db.Update(sql, parms);
        }
        private void GenerateGRN(object sender, EventArgs e)
        {
            if (_view.headSeleted.ReceiptHeaderId == 0)
            {
                MessageBox.Show("Please save this receipt before generate GRN.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            if (!_view.headSeleted.GenReceiptNumberFlag)
            {
                POReceiptHeaderModel rcv = _view.headSeleted;
                rcv.ReceiptNum = _repository.GenGRN("RECEIVING_PO", rcv.ReceiptDate);
                if (rcv.ReceiptNum != "")
                {
                    rcv.GenReceiptNumberFlag = true;
                    _repository.UpdateRcvHead(rcv);

                    _view.headSeleted = rcv;
                }
                else
                {
                    MessageBox.Show("Cannot generate GRN.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
            }
        }
        private void HaeaderValidation()
        {
            POReceiptHeaderModel head = _view.headSeleted;

            if (head.QCInspectionFlag)
            {
                var results = from p in _view.rcvLines
                              group p by p.QcInspectionStatus into g
                              select new { QcInspectionStatus = g.Key, rowsStatus = g.FirstOrDefault() };

                if (results.Count() > 1)
                {
                    head.InspectionStatus = "HOLD";
                }
                else if (results.Count() == 1)
                {
                    if (results.FirstOrDefault().QcInspectionStatus == 1)
                    {
                        head.InspectionStatus = "QC INCOMING";
                    }
                    else if (results.FirstOrDefault().QcInspectionStatus == 2)
                    {
                        head.InspectionStatus = "PASS ALL";
                    }
                    else if (results.FirstOrDefault().QcInspectionStatus == 3)
                    {
                        head.InspectionStatus = "NG ALL";
                    }
                }
            }
            _repository.UpdateRcvHead(head);
            _view.headSeleted = head;
        }
Ejemplo n.º 5
0
        public int InsertRcvHead(POReceiptHeaderModel model)
        {
            model.CreationDate   = DateTime.Now;
            model.LastUpdateDate = DateTime.Now;

            return(factory.POReceiptHaeaderDao.Insert(model));
        }
        private void Method_Change(object sender, EventArgs e)
        {
            MetroComboBox        cbo = sender as MetroComboBox;
            POReceiptHeaderModel rcv = _view.headSeleted;

            rcv.ReceiptMethod = cbo.Text;

            _view.headSeleted = rcv;
        }
        private void Save_Click(object sender, EventArgs e)
        {
            POReceiptHeaderModel rcv = _view.headSeleted;
            string typeLookup        = string.Empty;

            if (!rcv.ReceivedFlag)
            {
                rcv.ShippedDate       = rcv.ReceiptDate;
                rcv.ReceiptSourceCode = "PURCHASE";
                if (rcv.VendorId == 0)
                {
                    MessageBox.Show("Vendor is required.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                if (string.IsNullOrEmpty(rcv.InvoiceNum) && rcv.ReceiptMethod == "RECEIVE")
                {
                    MessageBox.Show("Invoice No. is required.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                if (string.IsNullOrEmpty(rcv.ReceiptMethod))
                {
                    MessageBox.Show("Receipt Method is required.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                //po.Remarks = _view.GetNote();

                if (rcv.ReceiptHeaderId == 0)
                {
                    if (rcv.ReceiptMethod == "RETURN")
                    {
                        rcv.ReceiptNum           = _repository.GenReturn("RETURN_PO");
                        rcv.GenReceiptNumberFlag = true;
                    }

                    rcv.ReceiptHeaderId = _repository.InsertRcvHead(rcv);
                }
                else
                {
                    _repository.UpdateRcvHead(rcv);
                    if (rcv.ReceiptMethod == "RECEIVE")
                    {
                        Save_Lines();
                    }
                }
            }
            else
            {
                MessageBox.Show("This PO was submited cannot save your change.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            _view.headSeleted = _repository.GetReceiptHeaderByID(rcv.ReceiptHeaderId);
        }
        private void Seleted_RCV(object sender, EventArgs e)
        {
            MetroGrid            grid = sender as MetroGrid;
            POReceiptHeaderModel rcv  = new POReceiptHeaderModel();
            int id = Convert.ToInt32(grid.CurrentRow.Cells[0].Value);

            rcv = _repository.GetReceiptHeaderByID(id);

            _view.headSeleted = rcv;
            _view.rcvLines    = _repository.GetRcvLineByHeaderID(id);
            _view.BindingRcvLines(_view.rcvLines);
        }
        private void New_Click(object sender, EventArgs e)
        {
            POReceiptHeaderModel rcv = new POReceiptHeaderModel();

            rcv.ReceiptDate    = DateTime.Now;
            rcv.ReceivedBy     = _view.EpiSession.User.Id;
            rcv.ReceivedByName = _view.EpiSession.User.UserName;
            rcv.CreatedBy      = _view.EpiSession.User.Id;
            rcv.LastUpdatedBy  = _view.EpiSession.User.Id;
            rcv.ReceiptMethod  = "RECEIVE";

            _view.headSeleted = rcv;
            _view.rcvLines    = new List <POReceiptLineModel>();
            _view.BindingRcvLines(_view.rcvLines);
        }
        public int Insert(POReceiptHeaderModel model)
        {
            string sql =
                @"INSERT INTO po_receipt_headers
	                (receipt_num,receipt_date,last_update_date
	                ,last_updated_by,creation_date,created_by
	                ,received_flag,receipt_source_code,vendor_id
	                ,vendor_site_id,organization_id,shipment_num
	                ,ship_to_location_id,bill_of_lading,packing_slip
	                ,shipped_date,employee_id,comments
	                ,attribute1,attribute2,attribute3
	                ,attribute4,attribute5,attribute6
	                ,attribute7,attribute8,attribute9
	                ,attribute10,attribute11,attribute12
	                ,attribute13,attribute14,attribute15
	                ,government_context,gross_weight,gross_weight_uom_code
	                ,net_weight,net_weight_uom_code,freight_terms
	                ,freight_bill_number,invoice_num,invoice_date
	                ,invoice_amount,tax_name,tax_amount
	                ,freight_amount,invoice_status_code,currency_code
	                ,conversion_rate_type,conversion_rate,conversion_date
	                ,approval_status,performance_period_from,performance_period_to
	                ,request_date, source_type, received_by, generate_grn_flag
                    ,qc_require_inspc_flag,qc_inspection_step,receipt_method)
                VALUES
	                (@receipt_num,@receipt_date,@last_update_date
	                ,@last_updated_by,@creation_date,@created_by
	                ,@received_flag,@receipt_source_code,@vendor_id
	                ,@vendor_site_id,@organization_id,@shipment_num
	                ,@ship_to_location_id,@bill_of_lading,@packing_slip
	                ,@shipped_date,@employee_id,@comments
	                ,@attribute1,@attribute2,@attribute3
	                ,@attribute4,@attribute5,@attribute6
	                ,@attribute7,@attribute8,@attribute9
	                ,@attribute10,@attribute11,@attribute12
	                ,@attribute13,@attribute14,@attribute15
	                ,@government_context,@gross_weight,@gross_weight_uom_code
	                ,@net_weight,@net_weight_uom_code,@freight_terms
	                ,@freight_bill_number,@invoice_num,@invoice_date
	                ,@invoice_amount,@tax_name,@tax_amount
	                ,@freight_amount,@invoice_status_code,@currency_code
	                ,@conversion_rate_type,@conversion_rate,@conversion_date
	                ,@approval_status,@performance_period_from,@performance_period_to
	                ,@request_date,@source_type,@received_by,@generate_grn_flag
                    ,@qc_require_inspc_flag,@qc_inspection_step,@receipt_method)";

            return(db.Insert(sql, Take(model)));
        }
        private void Received_Click(object sender, EventArgs e)
        {
            POReceiptHeaderModel head = _view.headSeleted;

            if (!string.IsNullOrEmpty(head.ReceiptNum))
            {
                if (head.QCInspectionFlag && head.ReceiptMethod == "RECEIVE")
                {
                    if (head.InspectionStatus.Trim() != "PASS ALL")
                    {
                        MessageBox.Show("QC Inspection status is not PASS. Cannot Received.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                }

                IEnumerable <POReceiptLineModel> lines = _view.rcvLines;
                if (lines.Count() > 0)
                {
                    if (ValidateLines(lines))
                    {
                        if (head.ReceiptMethod == "RETURN")
                        {
                            lines = GenerateReturnLines(lines);
                        }

                        if (head.ReceiptMethod == "RECEIVE")
                        {
                            lines = GenerateLotNumber(lines);
                        }

                        GeneratePOLocation(lines);
                        if (GenerateTransaction(lines))
                        {
                            ConfirmPOLocation(lines);

                            head.ReceivedFlag = true;
                            _repository.UpdateRcvHead(head);
                            UpdateReceivedLines(lines);
                            MessageBox.Show("Received process completed.", "Result", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                    }
                }
            }

            _view.headSeleted = head;
        }
        private void Find_Vendor(object sender, EventArgs e)
        {
            using (VendorListForm frm = new VendorListForm())
            {
                frm.VendorNumber = _view.headSeleted.VendorCode;
                frm.ShowDialog();
                if (frm.vendorSelected != null)
                {
                    POReceiptHeaderModel rcv = _view.headSeleted;
                    rcv.VendorId   = frm.vendorSelected.VendorId;
                    rcv.VendorCode = frm.vendorSelected.VendorNumber;
                    rcv.VendorName = frm.vendorSelected.VendorName;

                    _view.headSeleted = rcv;
                }
            }
        }
Ejemplo n.º 13
0
 public void DeleteRcvHead(POReceiptHeaderModel model)
 {
     factory.POReceiptHaeaderDao.Delete(model);
 }
        public void Update(POReceiptHeaderModel model)
        {
            string sql =
                @"UPDATE po_receipt_headers
               SET receipt_num = @receipt_num
                  ,receipt_date = @receipt_date
                  ,last_update_date = @last_update_date
                  ,last_updated_by = @last_updated_by
                  ,received_flag = @received_flag
                  ,receipt_source_code = @receipt_source_code
                  ,vendor_id = @vendor_id
                  ,vendor_site_id = @vendor_site_id
                  ,organization_id = @organization_id
                  ,shipment_num = @shipment_num
                  ,ship_to_location_id = @ship_to_location_id
                  ,bill_of_lading = @bill_of_lading
                  ,packing_slip = @packing_slip
                  ,shipped_date = @shipped_date
                  ,employee_id = @employee_id
                  ,comments = @comments
                  ,attribute1 = @attribute1
                  ,attribute2 = @attribute2
                  ,attribute3 = @attribute3
                  ,attribute4 = @attribute4
                  ,attribute5 = @attribute5
                  ,attribute6 = @attribute6
                  ,attribute7 = @attribute7
                  ,attribute8 = @attribute8
                  ,attribute9 = @attribute9
                  ,attribute10 = @attribute10
                  ,attribute11 = @attribute11
                  ,attribute12 = @attribute12
                  ,attribute13 = @attribute13
                  ,attribute14 = @attribute14
                  ,attribute15 = @attribute15
                  ,government_context = @government_context
                  ,gross_weight = @gross_weight
                  ,gross_weight_uom_code = @gross_weight_uom_code
                  ,net_weight = @net_weight
                  ,net_weight_uom_code = @net_weight_uom_code
                  ,freight_terms = @freight_terms
                  ,freight_bill_number = @freight_bill_number
                  ,invoice_num = @invoice_num
                  ,invoice_date = @invoice_date
                  ,invoice_amount = @invoice_amount
                  ,tax_name = @tax_name
                  ,tax_amount = @tax_amount
                  ,freight_amount = @freight_amount
                  ,invoice_status_code = @invoice_status_code
                  ,currency_code = @currency_code
                  ,conversion_rate_type = @conversion_rate_type
                  ,conversion_rate = @conversion_rate
                  ,conversion_date = @conversion_date
                  ,approval_status = @approval_status
                  ,performance_period_from = @performance_period_from
                  ,performance_period_to = @performance_period_to
                  ,request_date = @request_date
                  ,source_type = @source_type
                  ,received_by = @received_by
                  ,generate_grn_flag = @generate_grn_flag
                  ,qc_require_inspc_flag = @qc_require_inspc_flag
                  ,qc_inspection_step = @qc_inspection_step
                  ,receipt_method = @receipt_method
             WHERE receipt_header_id = @receipt_header_id";

            db.Update(sql, Take(model));
        }
        private void Get_GRN(object sender, EventArgs e)
        {
            if (!string.IsNullOrEmpty(_view.headSeleted.VendorCode))
            {
                POReceiptHeaderModel h       = _view.headSeleted;
                POReceiptHeaderModel rcvHead = null;
                if (!string.IsNullOrEmpty(_view.grnFileter))
                {
                    var head = _repository.GetReceiptHeaderByNumber(_view.grnFileter);
                    if (_view.headSeleted.VendorCode == head.VendorCode)
                    {
                        rcvHead = head;
                    }
                    else
                    {
                        MessageBox.Show("Vendor not match with header.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                }

                if (rcvHead != null)
                {
                    _view.rcvLines = _repository.GetRcvLineByHeaderID(rcvHead.ReceiptHeaderId);
                }
                else
                {
                    List <POReceiptHeaderModel> list = _repository.GetRcvHeaderByDate(DateTime.Now.AddDays(-30), DateTime.Now)
                                                       .Where(x => x.ReceivedFlag &&
                                                              x.VendorCode == _view.headSeleted.VendorCode &&
                                                              x.ReceiptMethod == "RECEIVE").ToList();
                    using (POReceiptListForm frm = new POReceiptListForm(list))
                    {
                        frm.startDate = DateTime.Now;
                        frm.endDate   = DateTime.Now;
                        frm.rcvMethod = "RECEIVE";
                        frm.ShowDialog();
                        if (frm.rcvsSelected != null)
                        {
                            var head = frm.rcvsSelected.FirstOrDefault();
                            if (_view.headSeleted.VendorCode == head.VendorCode)
                            {
                                rcvHead        = head;
                                _view.rcvLines = _repository.GetRcvLineByHeaderID(rcvHead.ReceiptHeaderId);
                            }
                            else
                            {
                                MessageBox.Show("Vendor not match with header.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                return;
                            }
                        }
                    }
                }

                if (_view.rcvLines != null)
                {
                    _view.rcvLines.ToList().ForEach(c => c.QuantityShipped = 0);
                    h.InvoiceNum = rcvHead.InvoiceNum;
                    h.Attribute1 = rcvHead.ReceiptHeaderId.ToString();
                    h.Attribute2 = rcvHead.ReceiptNum;
                    h.SourceType = rcvHead.SourceType;
                    _view.BindingRcvLines(_view.rcvLines);
                    _view.headSeleted = h;
                }
            }
            else
            {
                MessageBox.Show("Please select Vendor!.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
        }
        private void AddReceivingLine(List <POLineModel> poLines)
        {
            if (poLines.Count > 0)
            {
                POReceiptHeaderModel recHead = _view.headSeleted;
                foreach (var poLine in poLines)
                {
                    POReceiptLineModel recLine = new POReceiptLineModel();
                    recLine.CreatedBy          = _view.EpiSession.User.Id;
                    recLine.LastUpdatedBy      = _view.EpiSession.User.Id;
                    recLine.ReceiptHeaderId    = _view.headSeleted.ReceiptHeaderId;
                    recLine.LineNum            = 0;                                         //When to generate line num after Received status
                    recLine.QuantityShipped    = poLine.Quantity - poLine.QuantityReceived; //Default 0
                    recLine.QuantityReceived   = poLine.QuantityReceived;
                    recLine.UnitOfMeasure      = string.IsNullOrEmpty(poLine.Uom) ? "PCS" : poLine.Uom;
                    recLine.ItemDescription    = poLine.ItemDescription;
                    recLine.ItemId             = poLine.ItemId;
                    recLine.SourceDocumentCode = "PURCHASING";
                    recLine.PoHeaderId         = poLine.PoHeaderId;
                    recLine.PoLineId           = poLine.PoLineId;
                    recLine.ToSubinventory     = poLine.RefProjectNum;
                    recLine.ProjectId          = poLine.RefProjectId;
                    recLine.ProjectNum         = poLine.RefProjectNum;
                    recLine.ShipmentUnitPrice  = poLine.UnitPrice;
                    recLine.TaxName            = poLine.TaxCode;
                    recLine.TaxAmount          = poLine.TaxAmount;
                    recLine.InvoiceStatusCode  = "N";
                    recLine.PrjCostId          = poLine.ProjCostId;
                    recLine.QuantityOrdered    = poLine.Quantity;
                    recLine.CostCode           = poLine.CostCode;
                    recLine.Attribute1         = poLine.BOM; /*Bom Number*/

                    CostGroupModel cost = _view.costs.Where(x => x.CostCode == poLine.CostCode).FirstOrDefault();
                    if (cost == null)
                    {
                        MessageBox.Show("Cost Code : " + cost.CostCode +
                                        " in PO Line : " + poLine.PoLineNum + " dose not exist.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        break;
                    }

                    int dup = _view.rcvLines.Where(x => x.PoLineId == poLine.PoLineId).ToList().Count();
                    if (dup > 0)
                    {
                        MessageBox.Show("PO Line : " + poLine.PoLineNum + " was existing within Receive.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        break;
                    }

                    recLine.QcRequireInspcFlag = cost.MakingFlag;

                    if (recLine.QcRequireInspcFlag)
                    {
                        recLine.QcInspectionStatus = 2; //Default PASS
                    }
                    else
                    {
                        recLine.QcInspectionStatus = 0; //NOTHING
                    }

                    if (_view.rcvLines.Count() == 0)
                    {
                        recHead.SourceType = poLine.LineType;
                        if (recLine.QcRequireInspcFlag)
                        {
                            recHead.QCInspectionFlag = true;
                            recHead.InspectionStatus = "HOLD";
                        }
                        else
                        {
                            recHead.QCInspectionFlag = false;
                            recHead.InspectionStatus = "NO INSPECTION";
                        }
                    }
                    else
                    {
                        if (poLine.LineType.Trim() != recHead.SourceType.Trim())
                        {
                            MessageBox.Show("PO Type is not match Receive.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            break;
                        }

                        if (cost.MakingFlag != recHead.QCInspectionFlag)
                        {
                            MessageBox.Show("PO Type is not match Receive for Job process.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            break;
                        }
                    }

                    _repository.InsertRcvLine(recLine);
                }

                _view.rcvLines = _repository.GetRcvLineByHeaderID(recHead.ReceiptHeaderId);
                _view.BindingRcvLines(_view.rcvLines);
                _repository.UpdateRcvHead(recHead);
                _view.headSeleted = recHead;
            }
        }
 private object[] Take(POReceiptHeaderModel model)
 {
     return(new object[]
     {
         "@receipt_header_id", model.ReceiptHeaderId,
         "@receipt_num", model.ReceiptNum,
         "@receipt_date", model.ReceiptDate,
         "@last_update_date", model.LastUpdateDate,
         "@last_updated_by", model.LastUpdatedBy,
         "@creation_date", model.CreationDate,
         "@created_by", model.CreatedBy,
         "@received_flag", (model.ReceivedFlag) ? "Y" : "N",
         "@receipt_source_code", model.ReceiptSourceCode,
         "@vendor_id", model.VendorId,
         "@vendor_site_id", 0,
         "@organization_id", model.OrganizationId,
         "@shipment_num", model.ShipmentNum,
         "@ship_to_location_id", model.ShipToLocationId,
         "@bill_of_lading", model.BillOfLading,
         "@packing_slip", model.PackingSlip,
         "@shipped_date", model.ShippedDate,
         "@employee_id", model.EmployeeId,
         "@comments", model.Comments,
         "@attribute1", model.Attribute1,
         "@attribute2", model.Attribute2,
         "@attribute3", model.Attribute3,
         "@attribute4", model.Attribute4,
         "@attribute5", model.Attribute5,
         "@attribute6", model.Attribute6,
         "@attribute7", model.Attribute7,
         "@attribute8", model.Attribute8,
         "@attribute9", model.Attribute9,
         "@attribute10", model.Attribute10,
         "@attribute11", model.Attribute11,
         "@attribute12", model.Attribute12,
         "@attribute13", model.Attribute13,
         "@attribute14", model.Attribute14,
         "@attribute15", model.Attribute15,
         "@government_context", model.GovernmentContext,
         "@gross_weight", model.GrossWeight,
         "@gross_weight_uom_code", model.GrossWeightUomCode,
         "@net_weight", model.NetWeight,
         "@net_weight_uom_code", model.NetWeightUomCode,
         "@freight_terms", model.FreightTerms,
         "@freight_bill_number", model.FreightBillNumber,
         "@invoice_num", model.InvoiceNum,
         "@invoice_date", model.InvoiceDate,
         "@invoice_amount", model.InvoiceAmount,
         "@tax_name", model.TaxName,
         "@tax_amount", model.TaxAmount,
         "@freight_amount", model.FreightAmount,
         "@invoice_status_code", model.InvoiceStatusCode,
         "@currency_code", model.CurrencyCode,
         "@conversion_rate_type", model.ConversionRateType,
         "@conversion_rate", model.ConversionRate,
         "@conversion_date", model.ConversionDate,
         "@approval_status", model.ApprovalStatus,
         "@performance_period_from", model.PerformancePeriodFrom,
         "@performance_period_to", model.PerformancePeriodTo,
         "@request_date", model.RequestDate,
         "@source_type", model.SourceType,
         "@received_by", model.ReceivedBy,
         "@generate_grn_flag", (model.GenReceiptNumberFlag) ? "Y" : "N",
         "@qc_require_inspc_flag", (model.QCInspectionFlag) ? "Y" : "N",
         "@qc_inspection_step", model.InspectionStatus,
         "@receipt_method", model.ReceiptMethod
     });
 }
        private bool GenerateTransaction(IEnumerable <POReceiptLineModel> lines)
        {
            bool result = true;

            try
            {
                POReceiptHeaderModel recHead = _view.headSeleted;

                foreach (var recLine in lines)
                {
                    ItemTransactionModel trans = new ItemTransactionModel();
                    trans.InventoryItemId       = recLine.ItemId;
                    trans.SubinventoryCode      = recLine.ToSubinventory;
                    trans.TransactionSourceName = "PO RECEIVING";
                    trans.TransactionQuantity   = recLine.QuantityShipped;
                    trans.TransactionUom        = string.IsNullOrEmpty(recLine.UnitOfMeasure) ? "PCS" : recLine.UnitOfMeasure;
                    trans.PrimaryQuantity       = recLine.QuantityShipped;
                    trans.TransactionDate       = recHead.ReceiptDate;
                    trans.TransactionReference  = recHead.ReceiptNum;
                    trans.CostedFlag            = "Y";
                    trans.ActualCost            = recLine.ShipmentUnitPrice;
                    trans.TransactionCost       = recLine.ShipmentUnitPrice;
                    trans.Attribute1            = recLine.ProjectNum;
                    trans.Attribute2            = recLine.CostCode;
                    trans.Attribute3            = recLine.LotNumber;
                    trans.Attribute4            = recLine.Attribute1; //BOM No.
                    trans.TrxSourceLineId       = recLine.ReceiptLineId;
                    trans.TransferSubinventory  = recLine.ToSubinventory;

                    //Update po_line_id to task_id For PO line is Job Process.
                    if (recLine.QcRequireInspcFlag)
                    {
                        trans.TaskId = recLine.PoLineId;
                    }

                    int id = _repoTrans.InsertTrans(trans);

                    ItemOnhandModel onhand = _repoOnhand.GetDupplicated(recLine.ItemId
                                                                        , recLine.ToSubinventory
                                                                        , recLine.LotNumber
                                                                        , string.IsNullOrEmpty(recLine.Attribute1) ? "999" : recLine.Attribute1  //If BOM No. is null default '999'
                                                                        );
                    if (onhand != null)
                    {
                        double trxQty = onhand.PrimaryTransactionQuantity + recLine.QuantityShipped;
                        onhand.PrimaryTransactionQuantity = trxQty;
                        onhand.TransactionQuantity        = trxQty;
                        onhand.UpdateTransactionId        = id;
                        onhand.TransactionUnitCost        = recLine.ShipmentUnitPrice;

                        _repoOnhand.UpdateOnhand(onhand);
                    }
                    else
                    {
                        onhand = new ItemOnhandModel();
                        onhand.InventoryItemId            = recLine.ItemId;
                        onhand.DateReceived               = _view.headSeleted.RequestDate;
                        onhand.PrimaryTransactionQuantity = recLine.QuantityShipped;
                        onhand.TransactionQuantity        = recLine.QuantityShipped;
                        onhand.SubinventoryCode           = recLine.ToSubinventory;
                        onhand.LotNumber           = recLine.LotNumber;
                        onhand.TransactionUomCode  = recLine.UnitOfMeasure;
                        onhand.CreateTransactionId = id;
                        onhand.UpdateTransactionId = id;
                        onhand.BomNo = string.IsNullOrEmpty(recLine.Attribute1) ? "999" : recLine.Attribute1;  //If BOM No. is null default '999'
                        onhand.TransactionUnitCost = recLine.ShipmentUnitPrice;
                        onhand.ProjectId           = recLine.ProjectId;
                        onhand.ProjectNum          = recLine.ProjectNum;
                        onhand.ProjectCostCode     = recLine.CostCode;

                        //Update po_line_id to task_id For PO line is Job Process.
                        if (recLine.QcRequireInspcFlag)
                        {
                            onhand.TaskId = recLine.PoLineId;
                        }

                        int onhandId = _repoOnhand.InsertOnhand(onhand);
                    }
                }

                result = true;
            }
            catch (Exception ex)
            {
                MessageBox.Show("Received process error : ." + Environment.NewLine + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                result = false;
            }
            return(result);
        }
Ejemplo n.º 19
0
        public void UpdateRcvHead(POReceiptHeaderModel model)
        {
            model.LastUpdateDate = DateTime.Now;

            factory.POReceiptHaeaderDao.Update(model);
        }