Epicor_Integration.RevCompare.toExcel_btn_Click C# (CSharp) Метод

toExcel_btn_Click() приватный Метод

private toExcel_btn_Click ( object sender, EventArgs e ) : void
sender object
e EventArgs
Результат void
        private void toExcel_btn_Click(object sender, EventArgs e)
        {
            string s = "";

            foreach (DataGridViewRow dr in Billgrid.Rows)
            {
                decimal Q1 = Convert.ToDecimal(dr.Cells["Qty1"].Value);

                decimal Q2 = Convert.ToDecimal(dr.Cells["Qty2"].Value);

                string s2 = "";

                if (Q1 > Q2)
                {
                    s2 = "DEL (" + Math.Abs(Q2 - Q1) + ") " + dr.Cells["Pnum"].Value.ToString() + " (" + Q2 + ")";
                }

                if (Q1 < Q2)
                {
                    s2 = "ADD (" + Math.Abs(Q2 - Q1) + ") " + dr.Cells["Pnum"].Value.ToString() + " (" + Q2 + ")";
                }

                if (s2 != "")
                    s += s2 + "\n";
            }

            if(!FromSW)
            foreach (DataGridViewRow dr in Opsgrid.Rows)
            {
                string s3 = "";

                Nullable<decimal> P1 = null;

                Nullable<decimal> P2 = null;

                try
                {
                    P1 = decimal.Parse(dr.Cells["ProdHrs1"].Value.ToString());
                }
                catch { P1 = null; }

                try
                {
                    P2 = decimal.Parse(dr.Cells["ProdHrs2"].Value.ToString());
                }
                catch { P2 = null; }

                if (P1 == null && P2 != null)
                {
                    s3 = "ADD (" + P2 + ") OP" + dr.Cells["Seq"].Value.ToString() + " - " + dr.Cells["Code"].Value.ToString() + " (" + P2 + ")";
                }

                if (P2 == null && P1 != null)
                {
                    s3 = "DEL (" + P1 + ") OP" + dr.Cells["Seq"].Value.ToString() + " - " + dr.Cells["Code"].Value.ToString() + " (0)";
                }
                if (P1 != null && P2 != null)
                {
                    if (P1 > P2)
                    {
                        s3 = "DEL (" + Math.Abs((decimal)P2 - (decimal)P1) + ") OP" + dr.Cells["Seq"].Value.ToString() + " - " + dr.Cells["Code"].Value.ToString() + " (" + P2 + ")";
                    }

                    if (P1 < P2)
                    {
                        s3 = "ADD (" + Math.Abs((decimal)P2 - (decimal)P1) + ") OP" + dr.Cells["Seq"].Value.ToString() + " - " + dr.Cells["Code"].Value.ToString() + " (" + P2 + ")";
                    }
                }

                s += s3 + "\n";
            }

            Clipboard.SetText(s);
        }