protected override void ExecuteCrmWorkFlowActivity(CodeActivityContext context, LocalWorkflowContext localContext) { if (context == null) { throw new ArgumentNullException(nameof(context)); } if (localContext == null) { throw new ArgumentNullException(nameof(localContext)); } decimal number1 = Number1.Get(context); decimal number2 = Number2.Get(context); int roundDecimalPlaces = RoundDecimalPlaces.Get(context); if (number2 == 0) { Quotient.Set(context, 0); return; } decimal quotient = number1 / number2; if (roundDecimalPlaces != -1) { quotient = Math.Round(quotient, roundDecimalPlaces); } Quotient.Set(context, quotient); }
protected override void Execute(CodeActivityContext executionContext) { var n = Number1.Get <decimal>(executionContext); var n2 = Number2.Get <decimal>(executionContext); switch (Symbol.Get <string>(executionContext)) { case "+": n += n2; break; case "-": n -= n2; break; case "/": n /= n2; break; case "*": n *= n2; break; } Result.Set(executionContext, n); }
static void Main(string[] args) { // Console.WriteLine("Hello World!"); Dog dog = new Dog(); Taidi taidi = new Taidi(); Wolf[] wolves = { dog, taidi }; for (int i = 0; i < wolves.Length; i++) { wolves[i].speak(); } animal an = new cat(); an.Eat(); Shape shape = new Circle(6); double area = shape.Area(); double zhou = shape.Length(); Console.WriteLine("{0} {1}", area, zhou); Number1 number1 = new Number1(); }
protected bool Equals(CultureSample other) { if (Numbers.Where((t, i) => !t.Equals(other.Numbers[i])).Any()) { return(false); } return(Number1.Equals(other.Number1) && Number2.Equals(other.Number2) && Number3.Equals(other.Number3) && Dec1 == other.Dec1 && Dec2 == other.Dec2 && Date1.Equals(other.Date1) && Date2.Equals(other.Date2)); }
// override object.GetHashCode public override int GetHashCode() { int hash = 11; hash = hash * 13 + Number1.GetHashCode(); hash = hash * 13 + Number2.GetHashCode(); hash = hash * 13 + Answer.GetHashCode(); hash = hash * 13 + Oper.GetHashCode(); return(hash); }
public override object Run(object input) { LogDebug("Input to Task2: " + input.ToString());// TRACE < DEBUG < INFO < WARN < ERROR < FATAL long op = (long)input * Number1; LogInfo(input.ToString() + " * " + Number1.ToString() + " = " + Convert.ToString(op)); return(op); }
public override object Run(object input) { // TRACE < DEBUG < INFO < WARN < ERROR < FATAL LogDebug("Starting Task 1!"); long op = Number1 + Number2; LogInfo(Number1.ToString() + " + " + Number2.ToString() + " = " + Convert.ToString(op)); return(op); }
private void button1_Click(object sender, EventArgs e) { Number1 number = new Number1 { Name = nametxt.Text.ToString(), Surname = surnametxt.Text.ToString(), Age = surnametxt.Text.ToString() }; XmlVisualitons xmlVisualitons = new XmlVisualitons(); xmlVisualitons.Write(number); }
protected void btncalculate_Click(object sender, EventArgs e) { float Num, Num2, WeigTea, WeigStu; float SUMScore, Number1, Number2; string strCount = "select count(*) AS COUNT1 from 评分表 where ( 评分表.DID = (select 传值表.TransID from 传值表)) and (select 用户表.urid from 用户表 where 用户表.cid = 评分表.cid) = 1"; DataTable DTC = DBOper.execQueryBySQLText(strCount); if (DTC.Rows.Count > 0) { Num = float.Parse(DTC.Rows[0]["COUNT1"].ToString()); string strSti = "select SUM (Value1+Value2+Value3+Value4) AS SumScore1 from 评分表 where ( 评分表.DID = (select 传值表.TransID from 传值表)) and (select 用户表.urid from 用户表 where 用户表.cid = 评分表.cid) = 1"; DataTable DTT = DBOper.execQueryBySQLText(strSti); if (DTT.Rows.Count > 0) { Number1 = float.Parse(DTT.Rows[0]["SumScore1"].ToString()) / Num; txtScoreTeacher.Text = Number1.ToString(); string strCOUNT = "select count(*) AS COUNT2 from 评分表 where ( 评分表.DID = (select 传值表.TransID from 传值表)) and (select 用户表.urid from 用户表 where 用户表.cid = 评分表.cid) = 2"; DataTable DTCS = DBOper.execQueryBySQLText(strCOUNT); if (DTCS.Rows.Count > 0) { Num2 = float.Parse(DTCS.Rows[0]["COUNT2"].ToString()); string strStiSUM = "select SUM (Value1+Value2+Value3+Value4) AS SumScore2 from 评分表 where ( 评分表.DID = (select 传值表.TransID from 传值表)) and (select 用户表.urid from 用户表 where 用户表.cid = 评分表.cid) = 2"; DataTable DTTSUM = DBOper.execQueryBySQLText(strStiSUM); if (DTT.Rows.Count > 0) { Number2 = float.Parse(DTTSUM.Rows[0]["SumScore2"].ToString()) / Num2; txtScoreStudent.Text = Number2.ToString(); string sqlweight1 = "select UWeight from 用户权重表 where URID = 1"; DataTable DTW1 = DBOper.execQueryBySQLText(sqlweight1); if (DTCS.Rows.Count > 0) { WeigTea = float.Parse(DTW1.Rows[0]["UWeight"].ToString()); string sqlweight2 = "select UWeight from 用户权重表 where URID = 2"; DataTable DTW2 = DBOper.execQueryBySQLText(sqlweight2); if (DTCS.Rows.Count > 0) { WeigStu = float.Parse(DTW2.Rows[0]["UWeight"].ToString()); SUMScore = Number1 * WeigTea + Number2 * WeigStu; //计算总成绩 txtSummaryScore.Text = SUMScore.ToString(); string sqlsummary = "insert into 汇总表 (DID,SValue,TValue,SUValue) values('" + txtkong.Text + "','" + txtScoreStudent.Text + "','" + txtScoreTeacher.Text + "','" + txtSummaryScore.Text + "')"; DataTable DTSum = DBOper.execQueryBySQLText(sqlsummary); if (DTSum.Rows.Count > 0) { ; } } } } } } } }
public IEntity GetDigit(int num, Vector2 pos) { IEntity returnEntity = new Number0(pos); switch (num) { case 0: returnEntity = new Number0(pos); break; case 1: returnEntity = new Number1(pos); break; case 2: returnEntity = new Number2(pos); break; case 3: returnEntity = new Number3(pos); break; case 4: returnEntity = new Number4(pos); break; case 5: returnEntity = new Number5(pos); break; case 6: returnEntity = new Number6(pos); break; case 7: returnEntity = new Number7(pos); break; case 8: returnEntity = new Number8(pos); break; case 9: returnEntity = new Number9(pos); break; } return(returnEntity); }
public override int GetHashCode() { unchecked { var hashCode = Number1.GetHashCode(); hashCode = (hashCode * 397) ^ Number2.GetHashCode(); hashCode = (hashCode * 397) ^ Number3.GetHashCode(); hashCode = (hashCode * 397) ^ (Numbers?.GetHashCode() ?? 0); hashCode = (hashCode * 397) ^ Dec1.GetHashCode(); hashCode = (hashCode * 397) ^ Dec2.GetHashCode(); hashCode = (hashCode * 397) ^ Date1.GetHashCode(); hashCode = (hashCode * 397) ^ Date2.GetHashCode(); return(hashCode); } }
public override int GetHashCode() { unchecked { var hashCode = Number1.GetHashCode(); hashCode = (hashCode * 397) ^ Number2.GetHashCode(); hashCode = (hashCode * 397) ^ Number3; hashCode = (hashCode * 397) ^ Number4.GetHashCode(); hashCode = (hashCode * 397) ^ Number5.GetHashCode(); hashCode = (hashCode * 397) ^ Number6.GetHashCode(); hashCode = (hashCode * 397) ^ (int)Number7; hashCode = (hashCode * 397) ^ Number8.GetHashCode(); // hashCode = (hashCode * 397) ^ Number9.GetHashCode(); return(hashCode); } }
protected override void ExecuteCrmWorkFlowActivity(CodeActivityContext context, LocalWorkflowContext localContext) { if (context == null) { throw new ArgumentNullException(nameof(context)); } if (localContext == null) { throw new ArgumentNullException(nameof(localContext)); } decimal number1 = Number1.Get(context); decimal number2 = Number2.Get(context); decimal maxValue = number1 >= number2 ? number1 : number2; MaxValue.Set(context, maxValue); }
private void ButtonNumberClick(object sender, RoutedEventArgs e) { ContentControl contentControl = (ContentControl)sender; string button = contentControl.Content.ToString(); int inputValue = Convert.ToInt32(button); if (Operation == "") { Number1 = (Number1 * 10) + inputValue; txtResult.Text = Number1.ToString(); } else { Number2 = (Number2 * 10) + inputValue; txtResult.Text = Number2.ToString(); } }
public override int GetHashCode() { int hash = 1; if (Number1 != 0) { hash ^= Number1.GetHashCode(); } if (Number2 != 0) { hash ^= Number2.GetHashCode(); } if (_unknownFields != null) { hash ^= _unknownFields.GetHashCode(); } return(hash); }
protected override void ExecuteCrmWorkFlowActivity(CodeActivityContext context, LocalWorkflowContext localContext) { if (context == null) { throw new ArgumentNullException(nameof(context)); } if (localContext == null) { throw new ArgumentNullException(nameof(localContext)); } decimal number1 = Number1.Get(context); decimal number2 = Number2.Get(context); int roundDecimalPlaces = RoundDecimalPlaces.Get(context); decimal sum = number1 + number2; if (roundDecimalPlaces != -1) { sum = Math.Round(sum, roundDecimalPlaces); } Sum.Set(context, sum); }
protected override void ExecuteCrmWorkFlowActivity(CodeActivityContext context, LocalWorkflowContext localContext) { if (context == null) { throw new ArgumentNullException(nameof(context)); } if (localContext == null) { throw new ArgumentNullException(nameof(localContext)); } decimal number1 = Number1.Get(context); decimal number2 = Number2.Get(context); int roundDecimalPlaces = RoundDecimalPlaces.Get(context); decimal difference = number1 - number2; if (roundDecimalPlaces != -1) { difference = Math.Round(difference, roundDecimalPlaces); } Difference.Set(context, difference); }
protected override void ExecuteCrmWorkFlowActivity(CodeActivityContext context, LocalWorkflowContext localContext) { if (context == null) { throw new ArgumentNullException(nameof(context)); } if (localContext == null) { throw new ArgumentNullException(nameof(localContext)); } decimal number1 = Number1.Get(context); decimal number2 = Number2.Get(context); int roundDecimalPlaces = RoundDecimalPlaces.Get(context); decimal averageValue = (number1 + number2) / 2; if (roundDecimalPlaces != -1) { averageValue = Math.Round(averageValue, roundDecimalPlaces); } AverageValue.Set(context, averageValue); }
private void RemoveSigns() { Number1 = Number1.Replace("-", ""); Number2 = Number2.Replace("-", ""); }
static void Main(string[] args) { // Needed parameters for reading and writing in file(s) FileStream Stream1; FileStream Stream2; StreamWriter Writer; StreamReader Reader; BigInt Test; Test = new BigInt(); int LoopNumber; string Number1; string Number2; string Number3; string Number4; List <char> Result; string Answer; // Multiply Part Stream1 = new FileStream("MultiplyTestCases.txt", FileMode.Open); Reader = new StreamReader(Stream1); Stream2 = new FileStream("MultiplyOutput.txt", FileMode.OpenOrCreate); Writer = new StreamWriter(Stream2); Test = new BigInt(); LoopNumber = int.Parse(Reader.ReadLine()); Reader.ReadLine(); for (int i = 0; i < LoopNumber; i++) { Number1 = Reader.ReadLine(); Number2 = Reader.ReadLine(); Reader.ReadLine(); Result = Test.Multiplication(Number1.ToList <char>(), Number2.ToList <char>()); Answer = new string(Result.ToArray <char>()); Answer = Answer.TrimStart(new Char[] { '0' }); if (Answer == "") { Answer = "0"; } Writer.WriteLine(Answer); if (i != (LoopNumber - 1)) { Writer.WriteLine(); } } Reader.Close(); Writer.Close(); // Add Part Stream1 = new FileStream("AddTestCases.txt", FileMode.Open); Reader = new StreamReader(Stream1); Stream2 = new FileStream("AddOutput.txt", FileMode.OpenOrCreate); Writer = new StreamWriter(Stream2); LoopNumber = int.Parse(Reader.ReadLine()); Reader.ReadLine(); for (int i = 0; i < LoopNumber; i++) { Number1 = Reader.ReadLine(); Number2 = Reader.ReadLine(); Reader.ReadLine(); Result = Test.Addition(Number1.ToList <char>(), Number2.ToList <char>()); Answer = new string(Result.ToArray <char>()); Writer.WriteLine(Answer); if (i != (LoopNumber - 1)) { Writer.WriteLine(); } } Reader.Close(); Writer.Close(); // Subtract Part Stream1 = new FileStream("SubtractTestCases.txt", FileMode.Open); Reader = new StreamReader(Stream1); Stream2 = new FileStream("SubtractOutput.txt", FileMode.OpenOrCreate); Writer = new StreamWriter(Stream2); LoopNumber = int.Parse(Reader.ReadLine()); Reader.ReadLine(); for (int i = 0; i < LoopNumber; i++) { Number1 = Reader.ReadLine(); Number2 = Reader.ReadLine(); Reader.ReadLine(); Result = Test.Subtraction(Number1.ToList <char>(), Number2.ToList <char>()); Answer = new string(Result.ToArray <char>()); Answer = Answer.TrimStart(new Char[] { '0' }); if (Answer == "") { Answer = "0"; } Writer.WriteLine(Answer); if (i != (LoopNumber - 1)) { Writer.WriteLine(); } } Reader.Close(); Writer.Close(); //RSA Sample Test Cases Stream1 = new FileStream("SampleRSA.txt", FileMode.Open); Reader = new StreamReader(Stream1); Stream2 = new FileStream("SampleRSAOutput.txt", FileMode.OpenOrCreate); Writer = new StreamWriter(Stream2); LoopNumber = int.Parse(Reader.ReadLine()); for (int i = 0; i < LoopNumber; i++) { Number1 = Reader.ReadLine(); Number2 = Reader.ReadLine(); Number3 = Reader.ReadLine(); Number4 = Reader.ReadLine(); if (Number4 == "0") { Result = Test.RSAEncryption(Number3.ToList <char>(), Number1.ToList <char>(), Number2.ToList <char>()); Answer = new string(Result.ToArray <char>()); Answer = Answer.TrimStart(new Char[] { '0' }); if (Answer == "") { Answer = "0"; } Writer.WriteLine(Answer); } if (Number4 == "1") { Result = Test.RSADecryption(Number3.ToList <char>(), Number1.ToList <char>(), Number2.ToList <char>()); Answer = new string(Result.ToArray <char>()); Answer = Answer.TrimStart(new Char[] { '0' }); if (Answer == "") { Answer = "0"; } Writer.WriteLine(Answer); } } Reader.Close(); Writer.Close(); //RSA Complete Test Cases Stream1 = new FileStream("TestRSA.txt", FileMode.Open); Reader = new StreamReader(Stream1); Stream2 = new FileStream("TestRSAOutput.txt", FileMode.OpenOrCreate); Writer = new StreamWriter(Stream2); LoopNumber = int.Parse(Reader.ReadLine()); for (int i = 0; i < LoopNumber; i++) { Number1 = Reader.ReadLine(); Number2 = Reader.ReadLine(); Number3 = Reader.ReadLine(); Number4 = Reader.ReadLine(); if (Number4 == "0") { int Before = System.Environment.TickCount; Result = Test.RSAEncryption(Number3.ToList <char>(), Number1.ToList <char>(), Number2.ToList <char>()); int After = System.Environment.TickCount; int Diffrence = After - Before; Console.WriteLine("Time Of Case #: " + (i + 1) + " = " + Diffrence); Answer = new string(Result.ToArray <char>()); Answer = Answer.TrimStart(new Char[] { '0' }); if (Answer == "") { Answer = "0"; } Writer.WriteLine(Answer); } if (Number4 == "1") { int Before = System.Environment.TickCount; Result = Test.RSADecryption(Number3.ToList <char>(), Number1.ToList <char>(), Number2.ToList <char>()); int After = System.Environment.TickCount; int Diffrence = After - Before; Console.WriteLine("Time Of Case #: " + (i + 1) + " = " + Diffrence); Answer = new string(Result.ToArray <char>()); Answer = Answer.TrimStart(new Char[] { '0' }); if (Answer == "") { Answer = "0"; } Writer.WriteLine(Answer); } } Reader.Close(); Writer.Close(); //End of program }
public void ReloadNumberLists() { Number1 !.UnselectAll(); NumberToChoose = -1; Number1.LoadNumberList(_mainGame.GetNumberList()); }
protected override void Execute(CodeActivityContext executionContext) { Result.Set(executionContext, Math.Max(Number1.Get <int>(executionContext), Number2.Get <int>(executionContext))); }
private void Window_ContentRendered(object sender, EventArgs e) { Number1.SelectAll(); Number1.Focus(); }
public async Task ComputerChooseNumberAsync() { await ChooseNumberAsync(Number1.NumberToChoose()); }
public override int GetHashCode() { // xor the hash codes of the elements used to evaluate // equality return(Number1.GetHashCode() ^ Number2.GetHashCode()); }
public List <string> FizzBuzzer() { List <string> result = new List <string>(); if ((Number1 % DivisableBy1 == 0) && (Number1 % DivisableBy2 == 0)) { result.Add(Number1.ToString() + " " + Fizz + Buzz); } else if (Number1 % DivisableBy1 == 0) { result.Add(Number1.ToString() + " " + Fizz); } else if (Number1 % DivisableBy2 == 0) { result.Add(Number1.ToString() + " " + Buzz); } else { result.Add(Number1.ToString()); } if ((Number2 % DivisableBy1 == 0) && (Number2 % DivisableBy2 == 0)) { result.Add(Number2.ToString() + " " + Fizz + Buzz); } else if (Number2 % DivisableBy1 == 0) { result.Add(Number2.ToString() + " " + Fizz); } else if (Number2 % DivisableBy2 == 0) { result.Add(Number2.ToString() + " " + Buzz); } else { result.Add(Number2.ToString()); } if ((Number3 % DivisableBy1 == 0) && (Number3 % DivisableBy2 == 0)) { result.Add(Number3.ToString() + " " + Fizz + Buzz); } else if (Number3 % DivisableBy1 == 0) { result.Add(Number3.ToString() + " " + Fizz); } else if (Number3 % DivisableBy2 == 0) { result.Add(Number3.ToString() + " " + Buzz); } else { result.Add(Number3.ToString()); } if ((Number4 % DivisableBy1 == 0) && (Number4 % DivisableBy2 == 0)) { result.Add(Number4.ToString() + " " + Fizz + Buzz); } else if (Number4 % DivisableBy1 == 0) { result.Add(Number4.ToString() + " " + Fizz); } else if (Number4 % DivisableBy2 == 0) { result.Add(Number4.ToString() + " " + Buzz); } else { result.Add(Number4.ToString()); } if ((Number5 % DivisableBy1 == 0) && (Number5 % DivisableBy2 == 0)) { result.Add(Number5.ToString() + " " + Fizz + Buzz); } else if (Number5 % DivisableBy1 == 0) { result.Add(Number5.ToString() + " " + Fizz); } else if (Number5 % DivisableBy2 == 0) { result.Add(Number5.ToString() + " " + Buzz); } else { result.Add(Number5.ToString()); } return(result); }
// OLD signature notice the case, this did NOT work with the deserialise // public String batch_id, myinterface, voucher_type, trans_type, client, account, dim_1, dim_2, dim_3, dim_4, // dim_5, dim_6, dim_7, tax_code, tax_system, currency, dc_flag, cur_amount, amount, number_1, // value_1, value_2, value_3, description, trans_date, voucher_date, voucher_no, period, tax_flag, ext_inv_ref, // ext_ref, due_date, disc_date, discount, commitment, order_id, kid, pay_transfer, status, apar_type, // apar_id, pay_flag, voucher_ref, sequence_ref, intrule_id, factor_short, responsible, apar_name, address, province, // place, bank_account, pay_method, vat_reg_no, zip_code, curr_licence, account2, base_amount, base_curr, pay_temp_id, // allocation_key, period_no, clearing_code, swift, arrive_id, bank_acc_type //; public String beautifyGL07() { // this function will process the NULL values and return a GL07 fixed width line // ? allows null to not give a runtime error // ?? is effectively a coalesce. do the right side of the ?? if the left side is null else do the left side PayMethod = PayMethod?.Trim().PadRight(2).Substring(0, 2) ?? "".PadRight(2); BatchId = BatchId?.Trim().PadRight(25).Substring(0, 25) ?? "".PadRight(25); Interface = Interface?.Trim().PadRight(25).Substring(0, 25) ?? "".PadRight(25); VoucherType = VoucherType?.Trim().PadRight(25).Substring(0, 25) ?? "".PadRight(25); TransType = TransType?.Trim().PadRight(2).Substring(0, 2) ?? "".PadRight(2); Client = Client?.Trim().PadRight(25).Substring(0, 25) ?? "".PadRight(25); Account = Account?.Trim().PadRight(25).Substring(0, 25) ?? "".PadRight(25); Cat1 = Cat1?.Trim().PadRight(25).Substring(0, 25) ?? "".PadRight(25); Cat2 = Cat2?.Trim().PadRight(25).Substring(0, 25) ?? "".PadRight(25); Cat3 = Cat3?.Trim().PadRight(25).Substring(0, 25) ?? "".PadRight(25); Cat4 = Cat4?.Trim().PadRight(25).Substring(0, 25) ?? "".PadRight(25); Cat5 = Cat5?.Trim().PadRight(25).Substring(0, 25) ?? "".PadRight(25); Cat6 = Cat6?.Trim().PadRight(25).Substring(0, 25) ?? "".PadRight(25); Cat7 = Cat7?.Trim().PadRight(25).Substring(0, 25) ?? "".PadRight(25); TaxCode = TaxCode?.Trim().PadRight(25).Substring(0, 25) ?? "".PadRight(25); TaxSystem = TaxSystem?.Trim().PadRight(25).Substring(0, 25) ?? "".PadRight(25); Currency = Currency?.Trim().PadRight(25).Substring(0, 25) ?? "".PadRight(25); DcFlag = DcFlag?.Trim().PadRight(2).Substring(0, 2) ?? "".PadRight(2); CurAmount = CurAmount.Trim().PadLeft(20); Amount = Amount.Trim().PadLeft(20); Number1 = Number1.Trim().PadLeft(11); Value1 = Value1.Trim().PadLeft(20); Value2 = Value2.Trim().PadLeft(20); Value3 = Value3.Trim().PadLeft(20); Description = Description?.Trim().PadRight(255).Substring(0, 255) ?? "".PadRight(255); TransDate = TransDate?.Trim().PadRight(8).Substring(0, 8) ?? "".PadRight(8); VoucherDate = VoucherDate?.Trim().PadRight(8).Substring(0, 8) ?? "".PadRight(8); VoucherNo = VoucherNo?.Trim().PadRight(15).Substring(0, 15) ?? "".PadRight(15); Period = Period?.Trim().PadRight(6).Substring(0, 6) ?? "".PadRight(6); TaxFlag = TaxFlag?.Trim().PadRight(1).Substring(0, 1) ?? "".PadRight(1); ExtInvRef = ExtInvRef?.Trim().PadRight(100).Substring(0, 100) ?? "".PadRight(100); ExtRef = ExtRef?.Trim().PadRight(255).Substring(0, 255) ?? "".PadRight(255); DueDate = DueDate?.Trim().PadRight(8).Substring(0, 8) ?? "".PadRight(8); DiscDate = DiscDate?.Trim().PadRight(8).Substring(0, 8) ?? "".PadRight(8); Discount = Discount?.Trim().PadRight(20).Substring(0, 20) ?? "".PadRight(20); Commitment = Commitment?.Trim().PadLeft(25).Substring(0, 25) ?? "".PadRight(25); OrderId = OrderId?.Trim().PadRight(15).Substring(0, 15) ?? "".PadRight(15); Kid = Kid?.Trim().PadRight(27).Substring(0, 27) ?? "".PadRight(27); PayTransfer = PayTransfer?.Trim().PadRight(2).Substring(0, 2) ?? "".PadRight(2); Status = Status?.Trim().PadRight(1).Substring(0, 1) ?? "".PadRight(1); AparType = AparType?.Trim().PadRight(1).Substring(0, 1) ?? "".PadRight(1); AparId = AparId?.Trim().PadRight(25).Substring(0, 25) ?? "".PadRight(25); PayFlag = PayFlag?.Trim().PadRight(1).Substring(0, 1) ?? "".PadRight(1); VoucherRef = VoucherRef?.Trim().PadRight(15).Substring(0, 15) ?? "".PadRight(15); SequenceRef = SequenceRef?.Trim().PadRight(9).Substring(0, 9) ?? "".PadRight(9); IntruleId = IntruleId?.Trim().PadRight(25).Substring(0, 25) ?? "".PadRight(25); FactorShort = FactorShort?.Trim().PadRight(25).Substring(0, 25) ?? "".PadRight(25); Responsible = Responsible?.Trim().PadRight(25).Substring(0, 25) ?? "".PadRight(25); AparName = AparName?.Trim().PadRight(255).Substring(0, 255) ?? "".PadRight(255); Address = Address?.Trim().PadRight(160).Substring(0, 160) ?? "".PadRight(160); Province = Province?.Trim().PadRight(40).Substring(0, 40) ?? "".PadRight(40); Place = Place?.Trim().PadRight(40).Substring(0, 40) ?? "".PadRight(40); BankAccount = BankAccount?.Trim().PadRight(35).Substring(0, 35) ?? "".PadRight(35); PayMethod = PayMethod?.Trim().PadRight(2).Substring(0, 2) ?? "".PadRight(2); VatRegNo = VatRegNo?.Trim().PadRight(25).Substring(0, 25) ?? "".PadRight(25); ZipCode = ZipCode?.Trim().PadRight(15).Substring(0, 15) ?? "".PadRight(15); CurrLicence = CurrLicence?.Trim().PadRight(3).Substring(0, 3) ?? "".PadRight(3); Account2 = Account2?.Trim().PadRight(25).Substring(0, 25) ?? "".PadRight(25); BaseAmount = BaseAmount?.Trim().PadLeft(20).Substring(0, 20) ?? "".PadRight(20); BaseCurr = BaseCurr?.Trim().PadLeft(20).Substring(0, 20) ?? "".PadRight(20); PayTempId = PayTempId?.Trim().PadRight(4).Substring(0, 4) ?? "".PadRight(4); AllocationKey = AllocationKey?.Trim().PadRight(2).Substring(0, 2) ?? "".PadRight(2); PeriodNo = PeriodNo?.Trim().PadRight(2).Substring(0, 2) ?? "".PadRight(2); Clearingcode = Clearingcode?.Trim().PadRight(13).Substring(0, 13) ?? "".PadRight(13); Swift = Swift?.Trim().PadRight(11).Substring(0, 11) ?? "".PadRight(11); Arriveid = Arriveid?.Trim().PadRight(15).Substring(0, 15) ?? "".PadRight(15); BankAccType = BankAccType?.Trim().PadRight(2).Substring(0, 2) ?? "".PadRight(2); return(BatchId + Interface + VoucherType + TransType + Client + Account + Cat1 + Cat2 + Cat3 + Cat4 + Cat5 + Cat6 + Cat7 + TaxCode + TaxSystem + Currency + DcFlag + CurAmount + Amount + Number1 + Value1 + Value2 + Value3 + Description + TransDate + VoucherDate + VoucherNo + Period + TaxFlag + ExtInvRef + ExtRef + DueDate + DiscDate + Discount + Commitment + OrderId + Kid + PayTransfer + Status + AparType + AparId + PayFlag + VoucherRef + SequenceRef + IntruleId + FactorShort + Responsible + AparName + Address + Province + Place + BankAccount + PayMethod + VatRegNo + ZipCode + CurrLicence + Account2 + BaseAmount + BaseCurr + PayTempId + AllocationKey + PeriodNo + Clearingcode + Swift + Arriveid + BankAccType ); // String GL07Line = fw.BatchId.Trim().PadRight(25) + fw.Interface?.Trim().PadRight(25) + fw.VoucherType.Trim().PadRight(25) + fw.TransType.Trim().PadRight(2) + fw.Client.Trim().PadRight(25) //+ fw.Account.Trim().PadRight(25) + fw.Cat1.Trim().PadRight(25) + fw.Cat2.Trim().PadRight(25) + fw.Cat3.Trim().PadRight(25) + fw.Cat4.Trim().PadRight(25) //+ fw.Cat5.Trim().PadRight(25) + fw.Cat6.Trim().PadRight(25) + fw.Cat7.Trim().PadRight(25) + fw.TaxCode.Trim().PadRight(25) + fw.TaxSystem.Trim().PadRight(25) + fw.Currency.Trim().PadRight(25) //+ fw.DcFlag.Trim().PadRight(2) + fw.CurAmount.Trim().PadLeft(20) + fw.Amount.Trim().PadLeft(20) + fw.Number1.Trim().PadLeft(11) + fw.Value1.Trim().PadLeft(20) + fw.Value2.Trim().PadLeft(20) //+ fw.Value3.Trim().PadLeft(20) + fw.Description.Trim().PadRight(255) + fw.TransDate.Trim().PadRight(8) + fw.VoucherDate.Trim().PadRight(8) + fw.VoucherNo.Trim().PadRight(15) //+ fw.Period.Trim().PadRight(6) + fw.TaxFlag.Trim().PadRight(1) + fw.ExtInvRef.Trim().PadRight(100) + fw.ExtRef.Trim().PadRight(255) + fw.DueDate.Trim().PadRight(8) + fw.DiscDate.Trim().PadRight(8) //+ fw.Discount.Trim().PadRight(20) + fw.Commitment.Trim().PadLeft(25) + fw.OrderId.Trim().PadRight(15) + fw.Kid.Trim().PadRight(27) + fw.PayTransfer.Trim().PadRight(2) + fw.PayTransfer.Trim().PadRight(1) //+ fw.AparType.Trim().PadRight(1) + fw.AparId.Trim().PadRight(25) + fw.PayFlag.Trim().PadRight(1) + fw.VoucherRef.Trim().PadRight(15) + fw.SequenceRef.Trim().PadRight(9) + fw.IntruleId.Trim().PadRight(25) //+ fw.FactorShort.Trim().PadRight(25) + fw.Responsible.Trim().PadRight(25) + fw.AparName.Trim().PadRight(255) + fw.Address.Trim().PadRight(160) + fw.Province.Trim().PadRight(40) + fw.Place.Trim().PadRight(40) //+ fw.BankAccount.Trim().PadRight(35) + fw.PayMethod + fw.VatRegNo.Trim().PadRight(25) + fw.ZipCode.Trim().PadRight(15) + fw.CurrLicence.Trim().PadRight(3) + fw.Account2.Trim().PadRight(25) //+ fw.BaseAmount.Trim().PadLeft(20) + fw.BaseCurr.Trim().PadLeft(20) + fw.PayTempId.Trim().PadRight(4) + fw.AllocationKey.Trim().PadRight(2) + fw.PeriodNo.Trim().PadRight(2) + fw.Clearingcode.Trim().PadRight(13) //+ fw.Swift.Trim().PadRight(11) + fw.Arriveid.Trim().PadRight(15) + fw.BankAccType.Trim().PadRight(2) // ; }
public string Subtraction(string Number1, string Number2) {// Result = Number1 - Number2 #region For Short Result // if this process can't be made with easy, i am going to make with "String" if (Number1 == Number2) { return("0"); } if (mySortClassObject.NumberIsZero(Number1)) { return("-" + Number2); } if (mySortClassObject.NumberIsZero(Number2)) { return(Number1); } if (!ForDeveloper && !NumberIsSoBig) { double example0, example1; if (double.TryParse(Number1, out example0) && double.TryParse(Number2, out example1)) { return((example0 - example1).ToString()); } } if (Checking) { XtraMessageBox.Show("\tThis process can't do without this algorithm. Because your number is so big.\nError: OverFlow"); Checking = false; return("0"); } #endregion #region For Numbers Containing "," int MaxLengthOfDenominator = 0; string DenominatorNumber0 = "1", DenominatorNumber1 = "1"; // number count is 2 => Number1 and Number2 if (Number1.Contains(",")) // for example, if Number1 is 22,2 (decimal) so, if it is not integer { // 22,2 => 222 / 10 // for caracter length that after comma is "1", Denominator of this number is "10" // if caracter length that after comma were being "2", Denominator of this number was being "100" string Denominator = "1"; int length = Number1.Substring(Number1.IndexOf(",") + 1).Length; // caracter that After comma (",") for (int bx = 0; bx < length; bx++) { Denominator += "0"; } DenominatorNumber0 = Denominator; Number1 = Number1.Replace(",", ""); // i remove ",". 22,2 => 222 / 10 } if (Number2.Contains(",")) { // 22,2 => 222 / 10 string Denominator = "1"; int length = Number2.Substring(Number2.IndexOf(",") + 1).Length; // After comma (",") for (int bx = 0; bx < length; bx++) { Denominator += "0"; } DenominatorNumber1 = Denominator; Number2 = Number2.Replace(",", ""); // i remove ",". 22,2 => 222 / 10 } if (DenominatorNumber0 != "1" || DenominatorNumber1 != "1") // if Denominator numbers is not be "1", comma is there. So we do process numbers with comma { if (DenominatorNumber0.Length > DenominatorNumber1.Length) { MaxLengthOfDenominator = DenominatorNumber0.Length; } else if (DenominatorNumber1.Length > DenominatorNumber0.Length) { MaxLengthOfDenominator = DenominatorNumber1.Length; } else // 2 numbers is equal. Therefore it does not matter { MaxLengthOfDenominator = DenominatorNumber0.Length; } if (DenominatorNumber0.Length != MaxLengthOfDenominator) { string Denominator = "1"; int ZeroCount = MaxLengthOfDenominator - DenominatorNumber0.Length; for (int bx = 0; bx < ZeroCount; bx++) { Denominator += "0"; } Number1 = Multiplication(Number1, Denominator); } if (DenominatorNumber1.Length != MaxLengthOfDenominator) { string Denominator = "1"; int ZeroCount = MaxLengthOfDenominator - DenominatorNumber1.Length; for (int bx = 0; bx < ZeroCount; bx++) { Denominator += "0"; } Number2 = Multiplication(Number2, Denominator); } } #endregion #region Sorting bool ResultIsNegative = false; // Number1 should be the biggest one for my algorithm if (Number2.Replace("-", "").Replace(",", "").Length > Number1.Replace("-", "").Replace(",", "").Length) { string Next = Number1; Number1 = Number2; Number2 = Next; ResultIsNegative = true; // 3 - 4 = -(4 - 3) } else if (Number2.Length == Number1.Length) { if (Number1.Contains(",") || Number2.Contains(",")) { int index1 = Number1.IndexOf(","), index2 = Number2.IndexOf(","); if ((index2 > index1 && index1 != -1) || (index2 == -1 && index1 != -1)) // number2 is big { string Next = Number1; Number1 = Number2; Number2 = Next; ResultIsNegative = true; } else if (index1 == index2)// equal { string[] numberss = { Number1.Replace(",", "").Replace("-", ""), Number2.Replace(",", "").Replace("-", "") }; if (mySortClassObject.SortByStringLength(numberss)[1] == Number2.Replace(",", "").Replace("-", "")) // if number2 is big { string Next = Number1; Number1 = Number2; Number2 = Next; ResultIsNegative = true; } } } else { string[] numberss = { Number1.Replace("-", ""), Number2.Replace("-", "") }; if (mySortClassObject.SortByStringLength(numberss)[1] == Number2.Replace("-", "")) // if number2 is big { string Next = Number1; Number1 = Number2; Number2 = Next; ResultIsNegative = true; } } } #endregion #region Negative Numbers Control if (Number2.StartsWith("-") && Number1.StartsWith("-")) { // for example; -3 - (-2) = -3 + 2 Number1 = Number1.Substring(1); ResultIsNegative = true; // -3 + 2 = -(3 - 2), therefore i will put "-" in the end like that; // 3 - 2 = 1 ---> -1 } else if (Number1.StartsWith("-")) { // for example; -3 - 2 = -(3 + 2) so, i add 3 and 2. Then i will put "-" to result string[] Numbers = { Number1, Number2 }; return("-" + Addition(Numbers)); } else if (Number2.StartsWith("-")) { // for example; 3 - (-2) => 3 + 2 string[] Numbers = { Number1, Number2 }; return(Addition(Numbers)); } #endregion // string Result = Addition(DataToBeCollected); #region Subtraction Process // 987654321 (43211) //- 123456789 //------------- // 97532 string Result = ""; sbyte Data; for (int ax = 1; ax <= Number1.Length; ax++) { if (Number2.Length >= ax) { // 44500000 // 10000008 //-_________ // 2 Data = Convert.ToSByte(Convert.ToByte(Number1.Substring(Number1.Length - ax, 1)) - Convert.ToByte(Number2.Substring(Number2.Length - ax, 1))); if (Data < 0) { Data += 10; Result = Data.ToString() + Result; int NewNumber = ax + 1; while (Number1.Substring(Number1.Length - NewNumber, 1) == "0") { NewNumber++; } // 987654311 (43211) //- 123456789 //------------- // 97532 // 44500000 // 10000008 //-_________ // string NewData = Number1.Substring(0, Number1.Length - NewNumber) + Convert.ToByte(Convert.ToByte(Number1.Substring(Number1.Length - NewNumber, 1)) - 1).ToString(); if (NewNumber > ax + 1) { // i should change "0" to "9". For example; //1000 > 100(0) - (2) > 099(10) - (2) > 0998 // 2 //-____ //0998 , in this example, i changed "ten digits" and "hundered digits". int ZeroCount = (NewNumber - ax - 1); for (int cx = 0; cx < ZeroCount; cx++) { NewData += "9"; } NewData += Number1.Substring(Number1.Length - NewNumber + 1 + ZeroCount); } else { NewData += Number1.Substring(Number1.Length - NewNumber + 1); } Number1 = NewData; } else { Result = Data.ToString() + Result; } } else { Result = Number1.Substring(Number1.Length - ax, 1) + Result; } } #endregion // Result may be "0052" or "024" and such like ... // So, in left of result, it may contains "0" // therefore i should delete in left of result string FinalResult = mySortClassObject.DeleteTheZero(Result); // 55 / 10 > -55 / 10 if (ResultIsNegative) { FinalResult = "-" + FinalResult; } #region For Numbers Containing "," (end) if (MaxLengthOfDenominator > 0) // if number1 or number2 contain comma { // For Example; // (345 / 100) - (220 / 100) // => (345 - 220) / 100 So, // => Result / 100 = True Result // i should divison Result and 100 in this example string Denominator = "1"; for (int ax = 1; ax < MaxLengthOfDenominator; ax++) { Denominator += "0"; } return(Division(FinalResult, Denominator, false)); } #endregion return(FinalResult); }
public static void NumbCalculate() { Number1 numb = new Number1(); numb.Calculation(); }