示例#1
0
        private void frmMasterListManage_Load(object sender, EventArgs e)
        {
            if (SaleID > 0)
            {
                //do some logic
                var sales = Database.Sales.Where(x => x.ID == SaleID);
                foreach (var s in sales)
                {
                    txtSINO.Text        = s.SIOR;
                    txtPaymentType.Text = s.PaymentType;
                    txtCustomer.Text    = s.CustomerName;
                    txtRemarks.Text     = s.Remarks;
                    dtDate.Value        = s.CreatedDate.Value;
                }

                var details = Database.SaleDetails.Where(x => x.SaleID == SaleID);

                foreach (var d in details)
                {
                    var pro   = Database.Products.SingleOrDefault(x => x.ID == d.ProductID);
                    var net   = (d.Qty.Value * d.Price.Value);
                    var gross = net - (d.Qty.Value * pro.Cost.Value);
                    grv.Rows.Add(d.ID, pro.Code, d.Qty.Value.ToString("N"), d.Price.Value.ToString("N"), pro.Cost.Value.ToString("N"), net.ToString("N"), gross.ToString("N"));

                    TotalGross += gross;
                    TotalNet   += net;
                }

                txtTotalNet.Text   = TotalNet.ToString("N");
                txtTotalGross.Text = TotalGross.ToString("N");
            }
        }
示例#2
0
        private void btnVoid_Click(object sender, EventArgs e)
        {
            if (grv.SelectedRows.Count != 0)
            {
                frmVoidQty manage = new frmVoidQty(decimal.Parse(grv.CurrentRow.Cells[2].Value.ToString()));
                manage.StartPosition = FormStartPosition.CenterParent;
                manage.ShowDialog();

                if (manage.Confirm)
                {
                    Database = new DatabaseDataContext();
                    long    detail_id       = long.Parse(grv.CurrentRow.Cells[0].Value.ToString());
                    var     pro             = Database.Products.SingleOrDefault(x => x.Code == grv.CurrentRow.Cells[1].Value.ToString());
                    decimal return_void_qty = decimal.Parse(manage.txtQty.Text);
                    decimal current_qty     = decimal.Parse(grv.CurrentRow.Cells[2].Value.ToString());

                    //ibabalik sa stock yung qty and product ID
                    Database.ProductStockInVOID(pro.ID, return_void_qty, Helper.FULLNAME, txtCustomer.Text);
                    if (return_void_qty == current_qty)//delete
                    {
                        Database.SaleDetails.DeleteOnSubmit(Database.SaleDetails.SingleOrDefault(x => x.ID == detail_id));
                        Database.SubmitChanges();
                    }
                    else//update
                    {
                        var detail_update = Database.SaleDetails.SingleOrDefault(x => x.ID == detail_id);
                        detail_update.Qty = detail_update.Qty - return_void_qty;
                        Database.SubmitChanges();
                    }
                    //remove or update on the sale detail

                    foreach (DataGridViewRow item in this.grv.SelectedRows)
                    {
                        DataGridViewRow row = this.grv.SelectedRows[0];
                        TotalNet        -= decimal.Parse(row.Cells[5].Value.ToString());
                        txtTotalNet.Text = TotalNet.ToString("N");

                        TotalGross        -= decimal.Parse(row.Cells[6].Value.ToString());
                        txtTotalGross.Text = TotalGross.ToString("N");

                        //
                        grv.Rows.RemoveAt(item.Index);
                    }

                    //-----update grid
                    Database = new DatabaseDataContext();
                    var grid_update = Database.SaleDetails.SingleOrDefault(x => x.ID == detail_id);
                    var net         = (grid_update.Qty.Value * grid_update.Price.Value);
                    var gross       = net - (grid_update.Qty.Value * pro.Cost.Value);
                    grv.Rows.Add(detail_id, pro.Code, (grid_update.Qty.Value).ToString("N"), grid_update.Price.Value.ToString("N"), pro.Cost.Value.ToString("N"), net.ToString("N"), gross.ToString("N"));
                }
            }
        }
示例#3
0
        public override IDeepCopyable CopyTo(IDeepCopyable other)
        {
            var dest = other as Invoice;

            if (dest == null)
            {
                throw new ArgumentException("Can only copy to an object of the same type", "other");
            }

            base.CopyTo(dest);
            if (Identifier != null)
            {
                dest.Identifier = new List <Hl7.Fhir.Model.Identifier>(Identifier.DeepCopy());
            }
            if (StatusElement != null)
            {
                dest.StatusElement = (Code <Hl7.Fhir.Model.Invoice.InvoiceStatus>)StatusElement.DeepCopy();
            }
            if (CancelledReasonElement != null)
            {
                dest.CancelledReasonElement = (Hl7.Fhir.Model.FhirString)CancelledReasonElement.DeepCopy();
            }
            if (Type != null)
            {
                dest.Type = (Hl7.Fhir.Model.CodeableConcept)Type.DeepCopy();
            }
            if (Subject != null)
            {
                dest.Subject = (Hl7.Fhir.Model.ResourceReference)Subject.DeepCopy();
            }
            if (Recipient != null)
            {
                dest.Recipient = (Hl7.Fhir.Model.ResourceReference)Recipient.DeepCopy();
            }
            if (DateElement != null)
            {
                dest.DateElement = (Hl7.Fhir.Model.FhirDateTime)DateElement.DeepCopy();
            }
            if (Participant != null)
            {
                dest.Participant = new List <Hl7.Fhir.Model.Invoice.ParticipantComponent>(Participant.DeepCopy());
            }
            if (Issuer != null)
            {
                dest.Issuer = (Hl7.Fhir.Model.ResourceReference)Issuer.DeepCopy();
            }
            if (Account != null)
            {
                dest.Account = (Hl7.Fhir.Model.ResourceReference)Account.DeepCopy();
            }
            if (LineItem != null)
            {
                dest.LineItem = new List <Hl7.Fhir.Model.Invoice.LineItemComponent>(LineItem.DeepCopy());
            }
            if (TotalPriceComponent != null)
            {
                dest.TotalPriceComponent = new List <Hl7.Fhir.Model.Invoice.PriceComponentComponent>(TotalPriceComponent.DeepCopy());
            }
            if (TotalNet != null)
            {
                dest.TotalNet = (Hl7.Fhir.Model.Money)TotalNet.DeepCopy();
            }
            if (TotalGross != null)
            {
                dest.TotalGross = (Hl7.Fhir.Model.Money)TotalGross.DeepCopy();
            }
            if (PaymentTerms != null)
            {
                dest.PaymentTerms = (Hl7.Fhir.Model.Markdown)PaymentTerms.DeepCopy();
            }
            if (Note != null)
            {
                dest.Note = new List <Hl7.Fhir.Model.Annotation>(Note.DeepCopy());
            }
            return(dest);
        }
示例#4
0
        /// <summary>
        /// Serialize to a JSON object
        /// </summary>
        public new void SerializeJson(Utf8JsonWriter writer, JsonSerializerOptions options, bool includeStartObject = true)
        {
            if (includeStartObject)
            {
                writer.WriteStartObject();
            }

            if (!string.IsNullOrEmpty(ResourceType))
            {
                writer.WriteString("resourceType", (string)ResourceType !);
            }


            ((Fhir.R4.Models.DomainResource) this).SerializeJson(writer, options, false);

            if ((Identifier != null) && (Identifier.Count != 0))
            {
                writer.WritePropertyName("identifier");
                writer.WriteStartArray();

                foreach (Identifier valIdentifier in Identifier)
                {
                    valIdentifier.SerializeJson(writer, options, true);
                }

                writer.WriteEndArray();
            }

            if (!string.IsNullOrEmpty(Status))
            {
                writer.WriteString("status", (string)Status !);
            }

            if (_Status != null)
            {
                writer.WritePropertyName("_status");
                _Status.SerializeJson(writer, options);
            }

            if (!string.IsNullOrEmpty(CancelledReason))
            {
                writer.WriteString("cancelledReason", (string)CancelledReason !);
            }

            if (_CancelledReason != null)
            {
                writer.WritePropertyName("_cancelledReason");
                _CancelledReason.SerializeJson(writer, options);
            }

            if (Type != null)
            {
                writer.WritePropertyName("type");
                Type.SerializeJson(writer, options);
            }

            if (Subject != null)
            {
                writer.WritePropertyName("subject");
                Subject.SerializeJson(writer, options);
            }

            if (Recipient != null)
            {
                writer.WritePropertyName("recipient");
                Recipient.SerializeJson(writer, options);
            }

            if (!string.IsNullOrEmpty(Date))
            {
                writer.WriteString("date", (string)Date !);
            }

            if (_Date != null)
            {
                writer.WritePropertyName("_date");
                _Date.SerializeJson(writer, options);
            }

            if ((Participant != null) && (Participant.Count != 0))
            {
                writer.WritePropertyName("participant");
                writer.WriteStartArray();

                foreach (InvoiceParticipant valParticipant in Participant)
                {
                    valParticipant.SerializeJson(writer, options, true);
                }

                writer.WriteEndArray();
            }

            if (Issuer != null)
            {
                writer.WritePropertyName("issuer");
                Issuer.SerializeJson(writer, options);
            }

            if (Account != null)
            {
                writer.WritePropertyName("account");
                Account.SerializeJson(writer, options);
            }

            if ((LineItem != null) && (LineItem.Count != 0))
            {
                writer.WritePropertyName("lineItem");
                writer.WriteStartArray();

                foreach (InvoiceLineItem valLineItem in LineItem)
                {
                    valLineItem.SerializeJson(writer, options, true);
                }

                writer.WriteEndArray();
            }

            if ((TotalPriceComponent != null) && (TotalPriceComponent.Count != 0))
            {
                writer.WritePropertyName("totalPriceComponent");
                writer.WriteStartArray();

                foreach (InvoiceLineItemPriceComponent valTotalPriceComponent in TotalPriceComponent)
                {
                    valTotalPriceComponent.SerializeJson(writer, options, true);
                }

                writer.WriteEndArray();
            }

            if (TotalNet != null)
            {
                writer.WritePropertyName("totalNet");
                TotalNet.SerializeJson(writer, options);
            }

            if (TotalGross != null)
            {
                writer.WritePropertyName("totalGross");
                TotalGross.SerializeJson(writer, options);
            }

            if (!string.IsNullOrEmpty(PaymentTerms))
            {
                writer.WriteString("paymentTerms", (string)PaymentTerms !);
            }

            if (_PaymentTerms != null)
            {
                writer.WritePropertyName("_paymentTerms");
                _PaymentTerms.SerializeJson(writer, options);
            }

            if ((Note != null) && (Note.Count != 0))
            {
                writer.WritePropertyName("note");
                writer.WriteStartArray();

                foreach (Annotation valNote in Note)
                {
                    valNote.SerializeJson(writer, options, true);
                }

                writer.WriteEndArray();
            }

            if (includeStartObject)
            {
                writer.WriteEndObject();
            }
        }