public string Update() { CommissionAmount = (CommissionRate * Amount) / 100; CommissionAmount = Math.Round((decimal)CommissionAmount); VatOnAmount = Amount + CommissionAmount; VatAmount = (CommissionAmount + Amount) * VatRate / 100; VatAmount = Math.Round((decimal)VatAmount); InvoiceAmount = Amount + CommissionAmount + VatAmount; XDocument doc = XDocument.Load(@"Transactions.xml"); var record = from r in doc.Descendants("Transaction") where (int)r.Element("Invoice").Attribute("Id") == InvoiceId select r; foreach (XElement r in record) { r.Element("Invoice").Element("InvoiceNo").Value = InvoiceNo; r.Element("Invoice").Element("InvoiceDate").Value = XmlConvert.ToString(InvoiceDate, XmlDateTimeSerializationMode.RoundtripKind); r.Element("Invoice").Element("CommissionRate").Value = CommissionRate.ToString(); r.Element("Invoice").Element("CommissionAmount").Value = CommissionAmount.ToString(); r.Element("Invoice").Element("VatRate").Value = VatRate.ToString(); r.Element("Invoice").Element("VatAmount").Value = VatAmount.ToString(); r.Element("Invoice").Element("InvoiceAmount").Value = InvoiceAmount.ToString(); r.Element("Invoice").Element("Source").Value = Source; r.Element("Invoice").Element("Destination").Value = Destination; r.Element("Invoice").Element("TruckNo").Value = TruckNo; } doc.Save(@"Transactions.xml"); return("Record Updated"); }
} // end Parameterized constructor /// <summary> /// To override the ToString method so object property values are returned /// </summary> /// <returns>The string containing the object property values</returns> public override string ToString() { return "\r\n" + FirstName.ToString() + " " + LastName.ToString() + ":\r\n\t" + "Type: " + EmpType.ToString().ToLowerInvariant() + "\r\n\t" + "ID: " + EmpID.ToString() + "\r\n\t" + "Monthly Salary: " + MonthlySalary.ToString("C") + "\r\n\t" + "Commission Rate: " + CommissionRate.ToString("C") + "\n"; } // end method ToString()
} // End public override double CalculateEarnings() //************************************************ // Overridden ToString() //************************************************ public override string ToString() { // Begin public override string ToString() string outputStr = ""; outputStr += "Employee Name: " + FirstName + " " + MiddleInit + " " + LastName + "\n"; outputStr += "Union Status: " + IsUnion.ToString() + "\n"; outputStr += "Employee Number: " + EmpNum.ToString() + "\n"; outputStr += "Commission Rate: " + CommissionRate.ToString("f2") + "\n"; outputStr += "Weekly Sales: " + WeeklySales.ToString("c") + "\n"; outputStr += "Gross Pay: " + grossPay.ToString("c") + "\n"; return(outputStr); } // End public override string ToString()
public string Update() { //Rounding off for direct costings if (this.PostageCost.HasValue) { this.PostageCost = Math.Round((decimal)this.PostageCost); } if (this.JafferyActualCost.HasValue) { this.JafferyActualCost = Math.Round((decimal)this.JafferyActualCost); } if (this.SampleCuttingCost.HasValue) { this.SampleCuttingCost = Math.Round((decimal)this.SampleCuttingCost); } if (this.GodownRentCost.HasValue) { this.GodownRentCost = Math.Round((decimal)this.GodownRentCost); } if (this.StockInsuranceCost.HasValue) { this.StockInsuranceCost = Math.Round((decimal)this.StockInsuranceCost); } if (this.FreightCost.HasValue) { this.FreightCost = Math.Round((decimal)this.FreightCost); } //Calculation and Rounding for calculated costings this.CommissionAmount = (this.CommissionRate * this.AmountAndVat) / 100; if (this.CommissionAmount.HasValue) { this.CommissionAmount = Math.Round((decimal)this.CommissionAmount); } this.CharityAmount = (this.CharityRate * this.AmountAndVat) / 100; if (this.CharityAmount.HasValue) { this.CharityAmount = Math.Round((decimal)this.CharityAmount); } this.BrokerageAmount = (this.BrokerageRate * this.AmountAndVat) / 100; if (this.BrokerageAmount.HasValue) { this.BrokerageAmount = Math.Round((decimal)this.BrokerageAmount); } this.CottonDeliveryExpAmount = this.CottonDeliveryExpRate * this.Bales; if (this.CottonDeliveryExpAmount.HasValue) { this.CottonDeliveryExpAmount = Math.Round((decimal)this.CottonDeliveryExpAmount); } this.MarkingAmount = this.MarkingRate * this.Bales; if (this.MarkingAmount.HasValue) { this.MarkingAmount = Math.Round((decimal)this.MarkingAmount); } this.CartagePlatformAmount = this.CartagePlatformRate * this.Bales; if (this.CartagePlatformAmount.HasValue) { this.CartagePlatformAmount = Math.Round((decimal)this.CartagePlatformAmount); } this.StackingAmount = this.StackingRate * this.Bales; if (this.StackingAmount.HasValue) { this.StackingAmount = Math.Round((decimal)this.StackingAmount); } this.KatlaExpAmount = this.KatlaExpRate * this.Bales; if (this.KatlaExpAmount.HasValue) { this.KatlaExpAmount = Math.Round((decimal)this.KatlaExpAmount); } this.CartageFactoryAmount = this.CartageFactoryRate * this.Bales; if (this.CartageFactoryAmount.HasValue) { this.CartageFactoryAmount = Math.Round((decimal)this.CartageFactoryAmount); } this.StationExpAmount = this.StationExpRate * this.Bales; if (this.StationExpAmount.HasValue) { this.StationExpAmount = Math.Round((decimal)this.StationExpAmount); } this.TruckLoadingAmount = this.TruckLoadingRate * this.Bales; if (this.TruckLoadingAmount.HasValue) { this.TruckLoadingAmount = Math.Round((decimal)this.TruckLoadingAmount); } this.BankChargeAmount = this.BankChargeCost; if (this.BankChargeAmount.HasValue) { this.BankChargeAmount = Math.Round((decimal)this.BankChargeAmount); } if (this.CarringChargesFrom != null && this.CarringChargesTo != null) { DateTime d1 = (DateTime)this.CarringChargesFrom; DateTime d2 = (DateTime)this.CarringChargesTo; TimeSpan t1 = d2.Subtract(d1); this.CarringChargesFor = t1.Days; } this.CarringChargesAmount = this.CarringChargesOn * this.CarringChargesFor * this.CarringChargesRate / 3000; if (CarringChargesAmount.HasValue) { this.CarringChargesAmount = Math.Round((decimal)this.CarringChargesAmount); } //AmountAndVat //Debit Note Total this.DebitNoteTotal = (this.CommissionAmount ?? 0) + (this.CharityAmount ?? 0) + (this.BrokerageAmount ?? 0) + (this.PostageCost ?? 0) + (this.CottonDeliveryExpAmount ?? 0) + (this.JafferyActualCost ?? 0) + (this.MarkingAmount ?? 0) + (this.SampleCuttingCost ?? 0) + (this.CartagePlatformAmount ?? 0) + (this.StackingAmount ?? 0) + (this.KatlaExpAmount ?? 0) + (this.CartageFactoryAmount ?? 0) + (this.StationExpAmount ?? 0) + (this.TruckLoadingAmount ?? 0) + (this.BankChargeAmount ?? 0) + (this.GodownRentCost ?? 0) + (this.StockInsuranceCost ?? 0) + (this.FreightCost ?? 0) + (this.CarringChargesAmount ?? 0); //Update XML XDocument doc = XDocument.Load(@"Transactions.xml"); var record = from r in doc.Descendants("Transaction") where (int)r.Element("DebitNote").Attribute("Id") == DebitNoteId select r; foreach (XElement r in record) { r.Element("DebitNote").Element("DebitNoteNo").Value = DebitNoteNo; r.Element("DebitNote").Element("DebitNoteDate").Value = XmlConvert.ToString(DebitNoteDate, XmlDateTimeSerializationMode.RoundtripKind); r.Element("DebitNote").Element("CommissionRate").Value = CommissionRate.ToString(); r.Element("DebitNote").Element("CommissionAmount").Value = CommissionAmount.ToString(); r.Element("DebitNote").Element("CharityRate").Value = CharityRate.ToString(); r.Element("DebitNote").Element("CharityAmount").Value = CharityAmount.ToString(); r.Element("DebitNote").Element("BrokerageRate").Value = BrokerageRate.ToString(); r.Element("DebitNote").Element("BrokerageAmount").Value = BrokerageAmount.ToString(); r.Element("DebitNote").Element("Postage").Value = Postage; r.Element("DebitNote").Element("PostageCost").Value = PostageCost.ToString(); r.Element("DebitNote").Element("CottonDeliveryExpRate").Value = CottonDeliveryExpRate.ToString(); r.Element("DebitNote").Element("CottonDeliveryExpAmount").Value = CottonDeliveryExpAmount.ToString(); r.Element("DebitNote").Element("JafferyActual").Value = JafferyActual; r.Element("DebitNote").Element("JafferyActualCost").Value = JafferyActualCost.ToString(); r.Element("DebitNote").Element("MarkingRate").Value = MarkingRate.ToString(); r.Element("DebitNote").Element("MarkingAmount").Value = MarkingAmount.ToString(); r.Element("DebitNote").Element("SampleCutting").Value = SampleCutting; r.Element("DebitNote").Element("SampleCuttingCost").Value = SampleCuttingCost.ToString(); r.Element("DebitNote").Element("PostageCost").Value = PostageCost.ToString(); r.Element("DebitNote").Element("CartagePlatformRate").Value = CartagePlatformRate.ToString(); r.Element("DebitNote").Element("CartagePlatformAmount").Value = CartagePlatformAmount.ToString(); r.Element("DebitNote").Element("StackingRate").Value = StackingRate.ToString(); r.Element("DebitNote").Element("StackingAmount").Value = StackingAmount.ToString(); r.Element("DebitNote").Element("KatlaExp").Value = KatlaExp; r.Element("DebitNote").Element("KatlaExpRate").Value = KatlaExpRate.ToString(); r.Element("DebitNote").Element("KatlaExpAmount").Value = KatlaExpAmount.ToString(); r.Element("DebitNote").Element("CartageFactoryRate").Value = CartageFactoryRate.ToString(); r.Element("DebitNote").Element("CartageFactoryAmount").Value = CartageFactoryAmount.ToString(); r.Element("DebitNote").Element("StationExpRate").Value = StationExpRate.ToString(); r.Element("DebitNote").Element("StationExpAmount").Value = StationExpAmount.ToString(); r.Element("DebitNote").Element("TruckLoadingRate").Value = TruckLoadingRate.ToString(); r.Element("DebitNote").Element("TruckLoadingAmount").Value = TruckLoadingAmount.ToString(); r.Element("DebitNote").Element("BankChargeCost").Value = BankChargeCost.ToString(); r.Element("DebitNote").Element("BankChargeAmount").Value = BankChargeAmount.ToString(); r.Element("DebitNote").Element("GodownRentFrom").Value = GodownRentFrom.HasValue? XmlConvert.ToString(GodownRentFrom.Value, XmlDateTimeSerializationMode.RoundtripKind) : ""; r.Element("DebitNote").Element("GodownRentTo").Value = GodownRentTo.HasValue ? XmlConvert.ToString(GodownRentTo.Value, XmlDateTimeSerializationMode.RoundtripKind) : ""; r.Element("DebitNote").Element("GodownRentCost").Value = GodownRentCost.ToString(); r.Element("DebitNote").Element("StockInsurance").Value = StockInsurance; r.Element("DebitNote").Element("StockInsuranceCost").Value = StockInsuranceCost.ToString(); r.Element("DebitNote").Element("FreightFrom").Value = FreightFrom; r.Element("DebitNote").Element("FreightTo").Value = FreightTo; r.Element("DebitNote").Element("FreightCost").Value = FreightCost.ToString(); r.Element("DebitNote").Element("CarringChargesOn").Value = CarringChargesOn.ToString(); r.Element("DebitNote").Element("CarringChargesFrom").Value = CarringChargesFrom.HasValue ? XmlConvert.ToString(CarringChargesFrom.Value, XmlDateTimeSerializationMode.RoundtripKind) : ""; r.Element("DebitNote").Element("CarringChargesTo").Value = CarringChargesTo.HasValue ? XmlConvert.ToString(CarringChargesTo.Value, XmlDateTimeSerializationMode.RoundtripKind) : ""; r.Element("DebitNote").Element("CarringChargesFor").Value = CarringChargesFor.ToString(); r.Element("DebitNote").Element("CarringChargesRate").Value = CarringChargesRate.ToString(); r.Element("DebitNote").Element("CarringChargesAmount").Value = CarringChargesAmount.ToString(); r.Element("DebitNote").Element("AmountAndVat").Value = AmountAndVat.ToString(); r.Element("DebitNote").Element("DebitNoteTotal").Value = DebitNoteTotal.ToString(); } doc.Save(@"Transactions.xml"); return("Record Updated"); }