Exemple #1
0
        public void InsertDocumentHeader(int Count, string Department, int Cost)
        {
            _ws1.Range["AU6"].Value = ActNumber;
            //_ws1.Range["AE9"].Value = DateTime.Now.Day;
            //_ws1.Range["AL9"].Value = DateTime.Now.ToString("MMMM", CultureInfo.CreateSpecificCulture("ru"));
            //_ws1.Range["AL9"].Value = Utilities.Extensions.IntMonthToRusString(DateTime.Now.Month);
            //_ws1.Range["BG9"].Value = DateTime.Now.Year - 2000;
            _ws1.Range["Y13"].Value  = Department;
            _ws1.Range["BB12"].Value = 7709102090;
            _ws1.Range["CG25"].Value = Count;
            _ws1.Range["CG28"].Value = _cost.ToString("0.00");
            int     IntCost  = Convert.ToInt32(_cost);
            decimal decPenny = _cost % 1.0m;
            int     IntPenny = Convert.ToInt32(decPenny * 100);
            string  Penny    = IntPenny.ToString();

            Penny = (Penny.Length == 1) ? $"0{Penny}" : Penny;
            _ws1.Range["S26"].Value  = RusNumber.Str(IntCost) + " руб. " + Penny + " коп.";
            _ws1.Range["W32"].Value  = "Главный хранитель фондов";
            _ws1.Range["BZ32"].Value = "Баулина А. В.";
            _ws1.Range["W34"].Value  = "Зав. сектором";
            _ws1.Range["BZ34"].Value = "Позднышев А. Е.";
            _ws1.Range["W36"].Value  = "Зав. сектором";
            _ws1.Range["BZ36"].Value = "Русакова Л. В.";
            _ws1.Range["W38"].Value  = "Ведущий бухгалтер";
            _ws1.Range["BZ38"].Value = "Беркетова Е. А.";
            _ws1.Range["W40"].Value  = "Главный библиотекарь";
            _ws1.Range["BZ40"].Value = "Почкина М. В.";
            _ws1.Range["W42"].Value  = "Ведущий библиограф";
            _ws1.Range["BZ42"].Value = "Базилевская И. Н.";

            _ws1.Range["W58"].Value  = "Главный хранитель фондов";
            _ws1.Range["BZ58"].Value = "Баулина А. В.";
            _ws1.Range["W60"].Value  = "Зав. сектором";
            _ws1.Range["BZ60"].Value = "Позднышев А. Е.";
            _ws1.Range["W62"].Value  = "Зав. сектором";
            _ws1.Range["BZ62"].Value = "Русакова Л. В.";
            _ws1.Range["W64"].Value  = "Ведущий бухгалтер";
            _ws1.Range["BZ64"].Value = "Беркетова Е. А.";
            _ws1.Range["W66"].Value  = "Главный библиотекарь";
            _ws1.Range["BZ66"].Value = "Почкина М. В.";
            _ws1.Range["W68"].Value  = "Ведущий библиограф";
            _ws1.Range["BZ68"].Value = "Базилевская И. Н.";

            _ws1.Range["R18"].Value = "Главный хранитель фондов Баулина А. В.; Зав. сектором Позднышев А. Е.;";
            _ws1.Range["A20"].Value = "Зав. сектором Русакова Л. В.; Ведущий бухгалтер Беркетова Е. А.;";
            _ws1.Range["A21"].Value = "Главный библиотекарь Почкина М. В.; Ведущий библиограф Базилевская И. Н.";

            _ws2.Range["AI2"].Value = DateTime.Now.Day;
            _ws2.Range["T2"].Value  = ActNumber;
            _ws2.Range["AO2"].Value = Utilities.Extensions.IntMonthToRusString(DateTime.Now.Month);
            _ws2.Range["BH2"].Value = DateTime.Now.Year - 2000;

            AddSignature();
            _currentWS.Range[$"BK{_countPerPage + _rowIncrement + 1}"].Value = _countPerPage;
            _currentWS.Range[$"CL{_countPerPage + _rowIncrement + 1}"].Value = _costPerPage.ToString("0.00");
            _currentWS.Range[$"CL{_countPerPage + _rowIncrement + 2}"].Value = _cost.ToString("0.00");
            _currentWS.Range[$"BK{_countPerPage + _rowIncrement + 2}"].Value = Count;
        }
        public void Test3()
        {
            const int n = 51200;
            var       s = RusNumber.Str(n);

            Assert.IsTrue(s.Contains("двести"));
            var c = n.ToString("C");
            var a = n.ToString("N");
        }
Exemple #3
0
        static string Str(decimal val, bool male, string seniorOne, string seniorTwo, string seniorFive, string juniorOne, string juniorTwo, string juniorFive, bool fractPart)
        {
            bool minus = false;

            if (val < 0)
            {
                val = -val; minus = true;
            }

            int n         = (int)val;
            int remainder = (int)((val - n + 0.005M) * 100);

            StringBuilder r = new StringBuilder();

            if (0 == n)
            {
                r.Append("Ноль ");
            }
            if (n % 1000 != 0)
            {
                r.Append(RusNumber.Str(n, male, seniorOne, seniorTwo, seniorFive));
            }
            else
            {
                r.Append(seniorFive);
            }

            n /= 1000;

            r.Insert(0, RusNumber.Str(n, false, "тысяча", "тысячи", "тысяч"));
            n /= 1000;

            r.Insert(0, RusNumber.Str(n, true, "миллион", "миллиона", "миллионов"));
            n /= 1000;

            r.Insert(0, RusNumber.Str(n, true, "миллиард", "миллиарда", "миллиардов"));
            n /= 1000;

            r.Insert(0, RusNumber.Str(n, true, "триллион", "триллиона", "триллионов"));
            n /= 1000;

            r.Insert(0, RusNumber.Str(n, true, "триллиард", "триллиарда", "триллиардов"));
            if (minus)
            {
                r.Insert(0, "минус ");
            }

            if (fractPart)
            {
                r.Append(remainder.ToString(" 00 "));
                r.Append(RusNumber.Case(remainder, juniorOne, juniorTwo, juniorFive));
            }
            //Делаем первую букву заглавной
            r[0] = char.ToUpper(r[0]);

            return(r.ToString());
        }
Exemple #4
0
        public bool Handle(IAttributeModifier modifier, ObjectCardContext context)
        {
            var isObjectModification = context.EditiedObject != null;

            if (context.IsReadOnly)
            {
                return(false);
            }

            if (_tripleNumberTextAttr == null)
            {
                return(false);
            }

            foreach (var item in _tripleNumberTextAttr)
            {
                if (context.AttributesValues.TryGetValue(item.NumberAttr, out var attr))
                {
                    if (attr is decimal n)
                    {
                        var st    = n.ToString(CultureInfo.CurrentCulture);
                        var kop   = string.Empty;
                        var split = st.Split('.');
                        if (split.Length == 2)
                        {
                            kop = split[1];
                        }
                        var split1 = st.Split(',');
                        if (split1.Length == 2)
                        {
                            kop = split1[1];
                        }

                        var t = Math.Truncate(n);
                        var j = decimal.ToInt32(t);

                        var s = RusNumber.Str(j).Trim();

                        if (!string.IsNullOrEmpty(kop))
                        {
                            s = s + " " + kop + " копеек";
                        }

                        var s2 = n.ToString("N");

                        var pos       = s2.LastIndexOf(',');
                        var substring = s2.Substring(0, pos);

                        modifier.SetValue(item.StrAttr, s);
                        modifier.SetValue(item.StrNumberAttr, substring + " рублей " + kop + " копеек");
                    }
                }
            }

            return(true);
        }
        public void Test2()
        {
            const int n = 1402368;
            var       s = RusNumber.Str(n);

            Assert.IsTrue(s.Contains("четыреста"));
            const double d = 1402368.5;
            var          c = d.ToString("C");
            var          a = d.ToString("N");
        }
        // Вывод оценки прописью
        private void label27_TextChanged(object sender, EventArgs e)
        {
            if (label10.Text.Length == 0)
            {
                return;
            }
            int val = int.Parse(label10.Text);

            label27.Text = RusNumber.Str(val);
        }
        public void Test2()
        {
            const int n = 1402368;
            var       s = RusNumber.Str(n).Trim();

            Assert.IsTrue(s.Contains("четыреста"));
            const double d = 1402368.5;
            var          c = d.ToString("C");
            var          a = d.ToString("N");

            Assert.AreEqual(s, "Один миллион четыреста две тысячи триста шестьдесят восемь");
            Assert.AreEqual(c, "1 402 368,50 ₽");
            Assert.AreEqual(a, "1 402 368,50");
        }
        /// <summary>
        /// ////////////////////////////////////////////////////////////////////////////////////////////////
        /// </summary>
        private void DoExcelThings()
        {
            string           old_ser, ser = "";
            OracleCommand    cmd1;
            OracleDataReader dr1;
            string           date_bill, ch_date;

            excelFilePath = Path.GetFullPath("invoice_t.xlsx");

            openExcel();

            OracleCommand cmd = con.CreateCommand();

            cmd.CommandText = $"select * from table_billing where num_of_bill = {ID}";
            cmd.CommandType = CommandType.Text;
            OracleDataReader dr = cmd.ExecuteReader();

            dr.Read();
            date_bill = dr[1].ToString();
            ch_date   = date_bill[6].ToString() + date_bill[7].ToString() + '.';
            ch_date   = ch_date + date_bill[4].ToString() + date_bill[5].ToString() + '.';
            ch_date   = ch_date + date_bill[0].ToString() + date_bill[1].ToString() + date_bill[2].ToString() + date_bill[3].ToString();


            myExcelWorkSheet.Cells[1, 2].Value = "СЧЕТ НА ОПЛАТУ";

            myExcelWorkSheet.Cells[2, "B"].Value = $"№ {ID} от {ch_date}";

            date_bill = dr[4].ToString();
            ch_date   = date_bill[6].ToString() + date_bill[7].ToString() + '.';
            ch_date   = ch_date + date_bill[4].ToString() + date_bill[5].ToString() + '.';
            ch_date   = ch_date + date_bill[0].ToString() + date_bill[1].ToString() + date_bill[2].ToString() + date_bill[3].ToString();
            myExcelWorkSheet.Cells[3, "B"].Value = $"к договору {dr[0].ToString()} от {ch_date}";

            cmd1             = con.CreateCommand();
            cmd1.CommandText = $"select CRP_NM, REG_ADDR_CONT from tbcb_crp_info where CRP_CD = '{dr[5]}'";
            cmd1.CommandType = CommandType.Text;

            dr1 = cmd1.ExecuteReader();

            dr1.Read();
            myExcelWorkSheet.Cells[6, "AX"].Value = dr1[0].ToString();
            myExcelWorkSheet.Cells[8, "AX"].Value = dr1[1].ToString();
            dr1.Close();

            myExcelWorkSheet.Cells[10, "AX"].Value = $"{dr[7]}";
            if (dr[8].ToString() == "")
            {
                myExcelWorkSheet.Cells[12, "AX"].Value = "\t" + dr[9].ToString();
            }
            else
            {
                myExcelWorkSheet.Cells[12, "AX"].Value = "\t" + dr[8].ToString();
            }
            cmd1             = con.CreateCommand();
            cmd1.CommandText = $"Select bk_acnt_no, mfo_cd from tbcb_crp_bk where crp_cd = '{dr[5]}'";
            cmd1.CommandType = CommandType.Text;

            dr1 = cmd1.ExecuteReader();
            dr1.Read();

            myExcelWorkSheet.Cells[14, "AX"].Value = $"{dr1[0]}";
            myExcelWorkSheet.Cells[16, "AX"].Value = $"{dr1[1]}";

            string num_double = dr[11].ToString();
            bool   flag = false;
            var    DS = System.Globalization.CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator[0];
            string val = "", frac = "";;

            for (int i = 0; i < num_double.Count(); i++)
            {
                if (num_double[i] != DS && flag == false)
                {
                    val += num_double[i];
                }
                else if (num_double[i] != DS && flag == true)
                {
                    frac += num_double[i];
                }
                else if (num_double[i] == DS)
                {
                    flag = true;
                }
            }

            if (flag == false)
            {
                frac = "00";
            }


            myExcelWorkSheet.Cells[27, "J"].Value = $"{dr[16]}"; // комментарий
            myExcelWorkSheet.Cells[29, "J"].Value = $"{dr[17]}"; // основание

            myExcelWorkSheet.Cells[37, "AE"].Value = $"{dr[15]}";

            dr1.Close();
            ser = dr[3].ToString();
            //old_ser = dr[2].ToString();
            //flag = false;
            //for (int i = 0; i < old_ser.Count(); i++)
            //{
            //    if (old_ser[i] == '/')
            //    {
            //        flag = true;
            //    }
            //    else if (old_ser[i] != '/' && flag == true)
            //    {
            //        ser += old_ser[i];
            //    }
            //}

            cmd1             = con.CreateCommand();
            cmd1.CommandText = $"select NDS from tbcb_cd where CD like '{ser}%' AND CD_NM = '{dr[10].ToString()}'";
            cmd1.CommandType = CommandType.Text;
            dr1 = cmd1.ExecuteReader();
            dr1.Read();

            double percent = double.Parse(dr1[0].ToString());

            dr1.Close();
            myExcelWorkSheet.Cells[22, "AE"].Value = $"{dr[18]}";  ///валюта
            myExcelWorkSheet.Cells[22, "D"].Value  = $"{dr[10]}";  //услуга
            myExcelWorkSheet.Cells[22, "AI"].Value = double.Parse(dr[11].ToString().Replace('.', DS));
            myExcelWorkSheet.Cells[22, "BF"].Value = double.Parse(dr[11].ToString().Replace('.', DS));
            double sum_without_NDS;

            sum_without_NDS = double.Parse(dr[11].ToString().Replace('.', DS)) / (1 + percent / 100);
            myExcelWorkSheet.Cells[22, "AO"].Value = sum_without_NDS;
            MessageBox.Show(RusNumber.Str(Int32.Parse(val)));

            if (percent == 0)
            {
                myExcelWorkSheet.Cells[22, "AZ"].Value = "БЕЗ НДС";
                myExcelWorkSheet.Cells[22, "AW"].Value = "БЕЗ НДС";
                myExcelWorkSheet.Cells[25, "B"].Value  = "Всего к оплате:          " + RusNumber.Str(Int32.Parse(val)) + dr[18].ToString() + " " + frac + " тийин";
            }
            else
            {
                myExcelWorkSheet.Cells[22, "AZ"].Value = double.Parse(dr[11].ToString().Replace('.', DS)) - sum_without_NDS;
                myExcelWorkSheet.Cells[22, "AW"].Value = $"{percent}%"; // процент
                myExcelWorkSheet.Cells[25, "B"].Value  = "Всего к оплате:          " + RusNumber.Str(Int32.Parse(val)) + dr[18].ToString() + " " + frac + " тийин, в.т.ч. НДС: " + Math.Round(myExcelWorkSheet.Cells[22, "AZ"].Value, 2) + " " + dr[18].ToString();
            }

            dr.Close();
            myExcelApplication.Visible = true;  // true will open Excel
            myExcelWorkSheet.PrintPreview();
            myExcelApplication.Visible = false; // hides excel file when user closes preview
        }