Пример #1
0
 /// <summary>
 /// コンストラクタ
 /// </summary>
 /// <param name="parentForm"></param>
 /// <param name="webBrowser"></param>
 public WebTestController(Form parentForm, WebBrowser webBrowser, ExcelController excelController, FormLog formLog)
 {
     this.parentForm      = parentForm;
     this.webBrowser      = webBrowser;
     this.excelController = excelController;
     this.formLog         = formLog;
 }
Пример #2
0
        public void SaveFile()
        {
            ExcelController controller = new ExcelController();
            ViewResult      result     = controller.SaveFile() as ViewResult;

            Assert.IsNotNull(result);
        }
Пример #3
0
        private void crearExcelToolStripMenuItem_Click(object sender, EventArgs e)
        {
            ExcelController excon = new ExcelController();

            try
            {
                string   texto         = String.Empty;
                string[] textoSeparado = null;
                string   nombreArchivo = String.Empty;
                Archivo  archivo       = new Archivo();
                texto         = richTextBox1.Text;
                nombreArchivo = label1.Text;
                nombreArchivo.Replace(".txt", "");
                if (!texto.Equals(""))
                {
                    textoSeparado = archivo.SeparadorInicial(texto);
                    excon.CrearArchivo(textoSeparado, nombreArchivo);
                    MessageBox.Show("Se generó Excel con " + textoSeparado.Length + " elementos en c:/archivos", "Información", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    MessageBox.Show("No hay información para generar archivo Excel :'(", "Información", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error: " + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Пример #4
0
        public void GetWeatherExcel(string file)
        {
            ExcelController excelController = new ExcelController();
            List <Weather>  weathers        = excelController.GetWeathers(file + ".xlsx");

            BinaryController.WriteDataToBinary(file, weathers);
        }
Пример #5
0
 /// <inheritdoc />
 /// <summary>
 /// </summary>
 /// <param name="form"></param>
 /// <param name="filePath"></param>
 public ExcelForm(Form form, string filePath)
 {
     InitializeComponent();
     _form               = form;
     ForceClose          = true;
     Controller          = new ExcelController(filePath);
     CbSheets.DataSource = new List <string>(Controller.QuerySheets());
 }
Пример #6
0
        public List <Sun> GetSunConditionsFromExcel(string file)
        {
            ExcelController excelController = new ExcelController();
            List <Sun>      sunConditions   = excelController.GetSunConditions(file + ".xlsx");

            //BinaryController.WriteDataToBinary(file, sunConditions);
            return(sunConditions);
        }
Пример #7
0
        private void button4_Click(object sender, EventArgs e)
        {
            ExcelController _excelController        = new ExcelController();
            List <Dictionary <string, string> > dic = new List <Dictionary <string, string> >();

            foreach (var el in listBoxZIPPMSelected.Items)
            {
                var element  = el as dynamic;
                int zippm_id = (int)element.id;

                Dictionary <string, string> buf = new Dictionary <string, string>();
                buf["Наименование ЗИП/РМ"] = TablesModel.entities.sp_ZIP_AND_PM_Element.Where(x => zippm_id == x.zipPM_element_id).First().zipPM_element_name;
                buf["Дата закупки"]        = DateTime.Now.ToShortDateString();


                var           rnd            = new Random(zippm_id);
                List <double> y_val          = new List <double>();
                List <double> x_val          = new List <double>();
                int           current_date   = DateTime.Now.Year * 100 + DateTime.Now.Month;
                List <double> dates_comments = new List <double>();
                current_date += 1;
                for (int i = 0; i < 12; i++)
                {
                    current_date -= 1;
                    if (current_date % 100 == 0)
                    {
                        current_date += 12;
                        current_date -= 100;
                    }
                    dates_comments.Add(current_date);
                    //x_val.Add(current_date / 100.0);
                    var current_year  = (int)(current_date / 100);
                    var current_month = (int)(current_date % 100);
                    var countItems    = TablesModel.entities.ZIPPMMoves.Where(o => o.date_move.Year == current_year && o.date_move.Month == current_month && o.zipPM_element_id == zippm_id).Count();
                    y_val.Add(countItems);
                    x_val.Add(12 - i);
                }

                for (int i = 0; i < y_val.Count(); i++)
                {
                    var year  = ((int)(dates_comments[11 - i] / 100));
                    var month = (dates_comments[11 - i] % 100);

                    var count = TablesModel.entities.ZIPPMMoves.Where(x => x.date_move.Year == year && x.date_move.Month == month && x.zipPM_element_id == zippm_id).Count();
                }
                double pred = Interpolation.InterpolateLagrangePolynomial(13, x_val.ToArray(), y_val.ToArray(), 12);
                pred = Math.Abs(pred);
                pred = pred > 1.5 * y_val.First() ? (int)(y_val.First() * 1.5): pred;



                buf["Количество"] = pred.ToString();
                dic.Add(buf);
            }
            _excelController.GeneratePLans(dic, "Планы закупок");
            //TODO
        }
Пример #8
0
        public void Index()
        {
            ExcelController controller = new ExcelController();
            ViewResult      result     = controller.Index() as ViewResult;

            Assert.IsNotNull(result);
            Assert.IsNotNull(result.ViewBag.HelpUrl);
            Assert.IsNotNull(result.ViewBag.VersionInfo);
            Assert.IsNotNull(result.ViewBag.PublishDate);
        }
Пример #9
0
        public Form1()
        {
            InitializeComponent();

            //Initialize log
            DBCommon.Logger.InitializeLogs("Log", DBCommon.Utilities.GetDateTimeInUnixTimeStamp().ToString());

            ExcelController.InitializeExcel(Common.EXCEL_PATH);

            //Initialize the neo4j controller
            Neo4jController.InitializeController("localhost", 7474);
            Neo4jController.connect();
        }
Пример #10
0
        private void button1_Click(object sender, EventArgs e)
        {
            List <Dictionary <string, string> > answer = new List <Dictionary <string, string> >();
            var selectedIdCorpuses = selectedValues();

            foreach (var corpusId in selectedIdCorpuses)
            {
                var result = TablesModel.entities
                             .sp_Standarts
                             .Where(x => x.corpus_id == corpusId)
                             .Select(x => x.model_type_id).ToList();
                foreach (var modeltypes in result)
                {
                    var count = TablesModel.entities
                                .ElementsPlaces
                                .Where(x => x.corpus_id == corpusId && x.ModelElement.model_type_id == modeltypes)
                                .Count();
                    Dictionary <string, string> buf = new Dictionary <string, string>();
                    buf.Add("Наименование модели", TablesModel.entities.ModelType.Where(x => x.model_type_id == modeltypes).Select(x => x.model_type_name).First());
                    buf.Add("Фактическое количество в отделении", count.ToString());
                    var count_doos = (TablesModel.entities.sp_Standarts.Where(x => x.model_type_id == modeltypes && x.corpus_id == corpusId).Select(x => x.count - count).First());
                    count_doos = count_doos < 0 ? 0 : count_doos;
                    buf.Add("Необходимое дооснащение", count_doos.ToString());
                    buf.Add("Отделение", TablesModel.entities.sp_Corpus.Where(x => x.corpus_id == corpusId).Select(x => x.corpus_name).First());
                    buf.Add("Требуемое количество по стандарту", TablesModel.entities.sp_Standarts.Where(x => x.model_type_id == modeltypes && x.corpus_id == corpusId).Select(x => x.count).First().ToString());
                    answer.Add(buf);
                    //Отделение
                }
            }

            //int selectedValue = selectedId.First();
            //var result = TablesModel.entities.sp_Standarts.Where(x => x.corpus_id == selectedValue).Select(x=> x.model_type_id ).ToList();
            //foreach (var el in result)
            //{
            //    var res1 = TablesModel.entities.ModelElement.Where(x => el == x.model_type_id && x.ElementsPlaces.First().sp_Corpus.corpus_id == selectedValue).Count();
            //    Dictionary<string, string> buf = new Dictionary<string, string>();
            //    buf.Add("Наименование модели", TablesModel.entities.ModelType.Where(x => x.model_type_id == el).Select(x => x.model_type_name).First());
            //    buf.Add("Количество в отделении", res1.ToString());
            //    buf.Add("Недостающее", TablesModel.entities.sp_Standarts.Where(x => x.model_type_id == el && x.corpus_id == selectedValue).Select(x => x.count - res1).ToString());
            //    buf.Add("Отделение", TablesModel.entities.sp_Corpus.Where(x => x.corpus_id == selectedValue).Select(x => x.corpus_name).First());
            //    answer.Add(buf);
            //}

            ExcelController a = new ExcelController();

            a.GenerateStandart(answer, "Информация об оснащенности по стандартам");
        }
Пример #11
0
        /// <summary>
        /// webBrowserコンストラクタ
        /// webBrowserインスタンスはForm上からでないと実行できないっぽい(ActiveXの関係らしい?)
        /// </summary>
        /// <param name="webBrowser">webBrowserインスタンスを設定</param>
        public WebBrowserReceiver(Form parentForm, WebBrowser webBrowser, ExcelController excelController, FormLog formLog)
        {
            //webBrowserのインスタンスを設定
            this.webBrowser = webBrowser;

            //excelControllerのインスタンスを設定
            this.excelController = excelController;

            //親フォームのインスタンスを設定
            this.parentForm = parentForm;

            //ログ出力画面を設定
            this.formLog = formLog;

            //Web画面表示完了イベント登録
            this.webBrowser.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(documentCompleted);

            //非シグナル状態でAutoResetEventオブジェクトを作成
            UrlMoveCompleatEvent = new System.Threading.AutoResetEvent(false);
            CommandCompleatEvent = new System.Threading.AutoResetEvent(false);

            //operationクラスを生成
            setUrlImpl     = new SetUrl(this);
            setValueImpl   = new SetValue(this);
            clickImpl      = new Click(this);
            submitImpl     = new Submit(this);
            getValueImpl   = new GetValue(this);
            reLoadImpl     = new ReLoad(this);
            checkValueImpl = new CheckValue(this);

            captEvidence = new CaptEvidence(this);
            captHtml     = new CaptHtml(this);
            //dbEvidence      = new DBEvidence(this);
            doJavaScript = new DoJavaScript(this);

            getStateBySourceImpl = new GetStateBySource(this);
        }
 public void Setup()
 {
     resourcePath = @"../../../../test.xlsx";
     app = new Excel.Application();
     var excelSheetPath = Path.GetFullPath(resourcePath);
     wbs = app.Workbooks;
     wb = wbs.Open(excelSheetPath);
     wss = wb.Worksheets;
     ws = (Excel.Worksheet)wss["Tasks"];
     excelController = new ExcelController(resourcePath);
 }
Пример #13
0
        /// <summary>
        /// テスト情報を取得VOを作成する
        /// </summary>
        /// <param name="oXls"></param>
        /// <param name="testFilePass"></param>
        //public List<WebTestDto> makeTestInfoVO(Microsoft.Office.Interop.Excel.Application oXls, string testFilePass)
        public List <WebTestDto> makeTestInfoVO(string testFilePass)
        {
            //テスト情報
            WebTestDto webTest;

            //テストNo
            string no = "0";

            //テスト名称
            string testName = "";

            // URL
            string url = "";

            // SubmitボタンName
            string buttonName = "";

            // PostBack回数
            string postBackCntStr = "";
            int    postBackCnt    = 0;

            //Submit Type
            string submitTypeStr = "";
            int    submitType    = 0;

            bool isNumber = false;

            Dictionary <string, int> idDictionary = new Dictionary <string, int>();

            //画面設定項目 マスタ
            List <FormElement> webTestDictionaryList = null;

            //画面設定項目 設定
            List <FormElement> webTestDictionaryListSet = null;

            //テスト情報クリア
            webTestList = new List <WebTestDto>();

            //Excelファイルに設定されているテスト項目を読み取り
            //ExcelController excelController = new ExcelController(oXls);
            ExcelController excelController = new ExcelController();

            excelController.setExcelFilePass(testFilePass);

            //ファイルをOpenする
            excelController.openExcelFile();

            //シートリスト情報を取得
            List <String> sheetList = excelController.getSheetList();

            //エラーメッセージ文字列
            string errorMsgStr = "";

            try
            {
                //シートごとループ
                foreach (String sheetName in sheetList)
                {
                    string captureSQL = "";

                    // URL取得
                    url          = excelController.getValue(sheetName, CommonConst.CSV_URL_COL, CommonConst.CSV_URL_ROW);
                    errorMsgStr += checkAndSetCsvErrorMsgStrValNotSet(url, "テスト対象URL", sheetName, CommonConst.CSV_URL_COL, CommonConst.CSV_URL_ROW);

                    // DBエビデンス取得SQL
                    captureSQL = excelController.getValue(sheetName, 3, 3);

                    //設定カラム名称を取得
                    List <string> colNameList      = new List <string>();
                    int           rowSetStart      = 10;
                    int           rowEbidenceStart = 10;
                    int           row       = 10;
                    int           inOutFlag = 0; // IN
                    int           index     = 0;

                    //設定カラム名称を取得、マスタ情報を作成
                    webTestDictionaryList = new List <FormElement>();
                    for (row = rowSetStart; !string.IsNullOrWhiteSpace(excelController.getValue(sheetName, 1, row)); row++)
                    {
                        string elementVal  = excelController.getValue(sheetName, CommonConst.TESTCASE_ELEMENT_VAL_COL, row);
                        string elementType = excelController.getValue(sheetName, CommonConst.TESTCASE_ELEMENT_TYPE_COL, row);

                        errorMsgStr += checkAndSetCsvErrorMsgStrValNotSet(elementVal, "項目値", sheetName, CommonConst.TESTCASE_ELEMENT_VAL_COL, row);
                        errorMsgStr += checkAndSetCsvErrorMsgStrValNotSet(elementType, "項目種別", sheetName, CommonConst.TESTCASE_ELEMENT_TYPE_COL, row);


                        //設定情報開始位置
                        if ("TestResoult".Equals(elementVal))
                        {
                            rowEbidenceStart = row;
                            inOutFlag        = 1; //OUT
                        }
                        else
                        {
                            switch (elementType)
                            {
                            case "TextBox":
                                webTestDictionaryList.Add(new FormElement(elementVal, "", FormElement.ElementType.TextBox, inOutFlag, index));
                                break;

                            case "DropDownList":
                                webTestDictionaryList.Add(new FormElement(elementVal, "", FormElement.ElementType.DropDownList, inOutFlag, index));
                                break;

                            case "RadioButton":
                                webTestDictionaryList.Add(new FormElement(elementVal, "", FormElement.ElementType.RadioButton, inOutFlag, index));   //ラジオボタン チェック「1」チェック外す「0」
                                break;

                            case "CheckBox":
                                webTestDictionaryList.Add(new FormElement(elementVal, "", FormElement.ElementType.CheckBox, inOutFlag, index));    //ラジオボタン チェック「1」チェック外す「0」RadioButtonと動作は同じ
                                break;

                            case "Label":
                                webTestDictionaryList.Add(new FormElement(elementVal, "", FormElement.ElementType.Label, inOutFlag, index));
                                break;

                            case "HiddenValue":
                                webTestDictionaryList.Add(new FormElement(elementVal, "", FormElement.ElementType.HiddenValue, inOutFlag, index));
                                break;

                            default:
                                errorMsgStr += setCsvErrorMsgStr("指定外の項目タイプです", sheetName, CommonConst.TESTCASE_ELEMENT_TYPE_COL, row);
                                break;
                            }
                        }

                        colNameList.Add(excelController.getValue(sheetName, 1, row));
                    }

                    // 設定値情報を取得(テスト番号が設定されている行を実行)
                    idDictionary.Clear();
                    for (int col = 3; !string.IsNullOrWhiteSpace(excelController.getValue(sheetName, col, 4)); col++)
                    {
                        int valNum = -1;

                        // テストNO取得
                        no           = excelController.getValue(sheetName, col, CommonConst.TESTCASE_TEST_NO_ROW);
                        errorMsgStr += checkAndSetCsvErrorMsgStrValNotSet(no, "テストNO", sheetName, col, CommonConst.TESTCASE_TEST_NO_ROW);

                        // テスト名称取得
                        testName     = excelController.getValue(sheetName, col, CommonConst.TESTCASE_TEST_NAME_ROW);
                        errorMsgStr += checkAndSetCsvErrorMsgStrValNotSet(no, "テスト名称", sheetName, col, CommonConst.TESTCASE_TEST_NAME_ROW);

                        // SubmitボタンID取得
                        buttonName   = excelController.getValue(sheetName, col, CommonConst.TESTCASE_SUBMIT_BUTTON_ID_ROW);
                        errorMsgStr += checkAndSetCsvErrorMsgStrValNotSet(no, "SubmitボタンID", sheetName, col, CommonConst.TESTCASE_SUBMIT_BUTTON_ID_ROW);

                        //ポストバック回数を取得
                        postBackCntStr = excelController.getValue(sheetName, col, CommonConst.TESTCASE_POSTBACK_COUNT_ROW);
                        errorMsgStr   += checkAndSetCsvErrorMsgStrValNotSet(postBackCntStr, "ポストバック回数", sheetName, col, CommonConst.TESTCASE_POSTBACK_COUNT_ROW);
                        //valueが数値かを確認
                        isNumber = int.TryParse(postBackCntStr, out postBackCnt);
                        if (!isNumber || postBackCnt < 0)
                        {
                            errorMsgStr += setCsvErrorMsgStr("ポストバック回数は、0または正の値で指定してください", sheetName, CommonConst.TESTCASE_POSTBACK_COUNT_ROW, row);
                        }

                        //Submitタイプを取得
                        submitTypeStr = excelController.getValue(sheetName, col, CommonConst.TESTCASE_SUBMIT_TYPE_ROW);
                        errorMsgStr  += checkAndSetCsvErrorMsgStrValNotSet(no, "押下ボタン種別", sheetName, col, CommonConst.TESTCASE_SUBMIT_TYPE_ROW);
                        //valueが数値かを確認
                        isNumber = int.TryParse(submitTypeStr, out submitType);
                        if (!isNumber || submitType < 0 || submitType > 1)
                        {
                            errorMsgStr += setCsvErrorMsgStr("押下ボタン種別は、Submit「1」、click「0」いずれかで指定してください", sheetName, CommonConst.TESTCASE_SUBMIT_TYPE_ROW, row);
                        }

                        // 設定項目情報取得
                        int rowSub = rowSetStart;
                        webTestDictionaryListSet = new List <FormElement>();
                        idDictionary.Clear();
                        foreach (FormElement formElement in webTestDictionaryList)
                        {
                            //エビデンス取得開始行のマーカー行はスキップする
                            if (rowEbidenceStart.Equals(rowSub))
                            {
                                rowSub++;
                            }

                            //Index の値を設定する
                            index = 0;
                            if (idDictionary.ContainsKey(formElement.id))
                            {
                                index = idDictionary[formElement.id];
                                idDictionary.Remove(formElement.id);
                            }

                            //テスト値取得
                            string valStr = excelController.getValue(sheetName, col, rowSub);

                            //テスト値妥当性確認
                            isNumber = int.TryParse(valStr, out valNum);
                            switch (formElement.elementType)
                            {
                            case FormElement.ElementType.TextBox:
                                break;

                            case FormElement.ElementType.DropDownList:
                                if (!isNumber)
                                {
                                    errorMsgStr += setCsvErrorMsgStr("Index値を数字で指定してください", sheetName, CommonConst.TESTCASE_ELEMENT_VAL_COL, row);
                                }
                                break;

                            case FormElement.ElementType.RadioButton:
                                if (!isNumber || valNum < 0 || valNum > 1)
                                {
                                    errorMsgStr += setCsvErrorMsgStr("チェック有り「1」、チェック無し「0」いずれかで指定してください", sheetName, CommonConst.TESTCASE_ELEMENT_VAL_COL, row);
                                }
                                break;

                            case FormElement.ElementType.CheckBox:
                                if (!isNumber || valNum < 0 || valNum > 1)
                                {
                                    errorMsgStr += setCsvErrorMsgStr("チェック有り「1」、チェック無し「0」いずれかで指定してください", sheetName, CommonConst.TESTCASE_ELEMENT_VAL_COL, row);
                                }
                                break;

                            case FormElement.ElementType.Label:
                                break;

                            case FormElement.ElementType.HiddenValue:
                                break;

                            default:
                                break;
                            }

                            //テストNoごとの情報を追加
                            webTestDictionaryListSet.Add(new FormElement(
                                                             formElement.id,
                                                             valStr,
                                                             formElement.elementType,
                                                             formElement.inOutFlag,
                                                             index)
                                                         );

                            //加算
                            index++;
                            idDictionary.Add(formElement.id, index);

                            rowSub++;
                        }

                        // テストデータをコマンドクラスに設定
                        webTest = new WebTestDto(
                            sheetName,
                            testName,
                            int.Parse(no),
                            url,
                            captureSQL,
                            webTestDictionaryListSet,
                            buttonName,
                            postBackCnt,
                            submitType);

                        webTestList.Add(webTest);
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
            finally
            {
                //ファイルをCloseする
                excelController.closeExcelFile();
            }

            if (!string.IsNullOrEmpty(errorMsgStr))
            {
                formLog.setLogStrList(errorMsgStr);
            }

            //作成情報を返す(グローバルにも情報を保管)
            return(webTestList);
        }
Пример #14
0
        private void button1_Click_1(object sender, EventArgs e)
        {
            var list = UpdateState();

            if (checkedListBox1.SelectedIndex < 0)
            {
                return;
            }
            ExcelController excel = new ExcelController();

            if (checkedListBox1.SelectedIndex == 0)
            {//3
                list = list.Where(x => DateTime.Parse(x["date_utilisation"]).Year > DateTime.Now.Year ||
                                  ((DateTime.Parse(x["date_utilisation"]).Year < dateTimePickerAfter.Value.Year) && DateTime.Parse(x["date_utilisation"]).Month < dateTimePickerAfter.Value.Month) ||
                                  1 == 0);
                excel.GenerateModelElementsExample(list);
            }
            else if (checkedListBox1.SelectedIndex == 1)
            {//0
                list = list.Where(x => x["reason_write_off"] == "0");
                excel.GenerateModelElementsExample(list);
            }
            else if (checkedListBox1.SelectedIndex == 2)
            {//4
                list = list.Where(x => (DateTime.Parse(x["date_utilisation"]).Year * 100 + DateTime.Parse(x["date_utilisation"]).Month > dateTimePickeBbefore.Value.Year * 100 + dateTimePickeBbefore.Value.Month &&
                                        DateTime.Parse(x["date_utilisation"]).Year * 100 + DateTime.Parse(x["date_utilisation"]).Month < dateTimePickerAfter.Value.Year * 100 + dateTimePickerAfter.Value.Month));
                excel.GenerateModelElementsExample(list);
            }
            else if (checkedListBox1.SelectedIndex == 3)
            {//1
                list = list.Where(x => (DateTime.Parse(x["date_utilisation"]).Year * 100 + DateTime.Parse(x["date_utilisation"]).Month > dateTimePickeBbefore.Value.Year * 100 + dateTimePickeBbefore.Value.Month &&
                                        DateTime.Parse(x["date_utilisation"]).Year * 100 + DateTime.Parse(x["date_utilisation"]).Month < dateTimePickerAfter.Value.Year * 100 + dateTimePickerAfter.Value.Month));
                excel.GenerateModelElementsExample(list);
            }
            else if (checkedListBox1.SelectedIndex == 4)
            {
                list = list.Where(x => int.Parse(x["broken_count"]) > 0);
                excel.GenerateModelElementsExample(list);
            }
            else if (checkedListBox1.SelectedIndex == 5)
            {
                list = list.Where(x => x["is_mo"] == "1" &&
                                  Math.Abs((DateTime.Now - DateTime.Parse(x["date_mo"])).Days) / 365 < 1);
                excel.GenerateModelElementsExample(list);
            }
            else if (checkedListBox1.SelectedIndex == 6)
            {
                list = list.Where(x => x["is_mo"] == "1" &&
                                  Math.Abs((DateTime.Now - DateTime.Parse(x["date_mo"])).Days) / 365 > 1);
                excel.GenerateModelElementsExample(list);
            }
            else if (checkedListBox1.SelectedIndex == 7)
            {
                list = list.Where(x => Math.Abs((DateTime.Now - DateTime.Parse(x["date_to"])).Days) / 365 < 1);
                excel.GenerateModelElementsExample(list);
            }
            else if (checkedListBox1.SelectedIndex == 8)
            {
                list = list.Where(x => Math.Abs((DateTime.Now - DateTime.Parse(x["date_to"])).Days) / 365 > 1);
                excel.GenerateModelElementsExample(list);
            }
        }
Пример #15
0
        private void buttonStatisticRM_Click(object sender, EventArgs e)
        {
            ExcelController excel = new ExcelController();
            var             list  = UpdateRM();

            if (checkBox1.Checked)
            {
                list = UpdateRM();
            }
            else
            {
                list = UpdateRM().Where(x => x["Наименование расходного материала"] == (string)comboBoxNameRM.SelectedValue);
            }

            if (checkedListBoxRm.SelectedIndex < 0)
            {
                return;
            }

            if (checkedListBoxRm.SelectedIndex == 0)
            {
                excel.GeneratePMExample(list);
            }
            else if (checkedListBoxRm.SelectedIndex == 1)
            {
                var linqResult = new List <Dictionary <string, string> >();

                var list1 = from el in TablesModel.entities.ZIPPMDocumentsOnPurchase
                            where el.date_coming_in >= dateTimePickerbeforeRM.Value && el.date_coming_in <= dateTimePickerAfterRM.Value
                            select new
                {
                    el.sp_ZIP_AND_PM_Element.zipPM_element_name,
                    el.count,
                    el.sp_ZIP_AND_PM_Element
                };
                foreach (var el in list1)
                {
                    Dictionary <string, string> dic = new Dictionary <string, string>();
                    dic.Add("Наименование расходного материала", el.zipPM_element_name);
                    dic.Add("На складе: ", el.count.ToString());
                    linqResult.Add(dic);
                }
                excel.GeneratePMExample(linqResult);
            }
            else if (checkedListBoxRm.SelectedIndex == 2)
            {
                var linqResult = new List <Dictionary <string, string> >();
                var list1      = from el in TablesModel.entities.ZIPPMMoves
                                 where el.date_move >= dateTimePickerbeforeRM.Value && el.date_move <= dateTimePickerAfterRM.Value
                                 select new
                {
                    el.sp_ZIP_AND_PM_Element.zipPM_element_name,
                    count = 1,
                    el.sp_ZIP_AND_PM_Element
                };
                foreach (var el in list1)
                {
                    Dictionary <string, string> dic = new Dictionary <string, string>();
                    dic.Add("Наименование расходного материала", el.zipPM_element_name);
                    dic.Add("На складе: ", el.count.ToString());
                    linqResult.Add(dic);
                }

                excel.GeneratePMExample(linqResult);
            }
            else if (checkedListBoxRm.SelectedIndex == 3)
            {
                var linqResult = new List <Dictionary <string, string> >();
                var list1      = from el in TablesModel.entities.ZIPPMMoves
                                 where el.date_move >= dateTimePickerbeforeRM.Value && el.date_move <= dateTimePickerAfterRM.Value
                                 select new
                {
                    el.sp_ZIP_AND_PM_Element.zipPM_element_name,
                    count = 1,
                    el.sp_ZIP_AND_PM_Element
                };
                foreach (var el in list1)
                {
                    Dictionary <string, string> dic = new Dictionary <string, string>();
                    dic.Add("Наименование расходного материала", el.zipPM_element_name);
                    dic.Add("На складе: ", el.count.ToString());
                    linqResult.Add(dic);
                }

                excel.GeneratePMExample(linqResult);
            }

            //new ExcelController().GeneratePMExample(null);
        }
 public void Setup()
 {
     _excelController = new ExcelController();
 }