Esempio n. 1
0
        private void ImportExcelsimpleButton_Click(object sender, EventArgs e)
        {
            var model = new Model.F6001(new F6001());
            var z     = new ImportForms.F6001ImportForm(model);

            if (z.ShowDialog(this) == DialogResult.OK)
            {
                var f6001 = this.f6001BindingSource.Current as Model.F6001;
                if (f6001 == null)
                {
                    return;
                }
                foreach (var currentF6001Ligne in model.Lignes)
                {
                    if (currentF6001Ligne != null && !currentF6001Ligne.Calculable)
                    {
                        var l = f6001.Lignes.Single(x => x.CodeB == currentF6001Ligne.CodeB);
                        l.ValeurB = currentF6001Ligne.ValeurB;

                        l = f6001.Lignes.Single(x => x.CodeAmortissement == currentF6001Ligne.CodeAmortissement);
                        l.ValeurAmortissement = currentF6001Ligne.ValeurAmortissement;

                        l          = f6001.Lignes.Single(x => x.CodeN1 == currentF6001Ligne.CodeN1);
                        l.ValeurN1 = currentF6001Ligne.ValeurAmortissement;
                    }
                }
                this.f6001BindingSource.ResetCurrentItem();
            }
        }
Esempio n. 2
0
        public XtraFrmF6001(LiasseController controller)
        {
            _controller = controller;
            InitializeComponent();
            gridView1.CustomRowCellEdit += GridView1OnCustomRowCellEdit;
            _CurrentF6001 = controller.CurrentF6001();
            var Model = new Model.F6001(_CurrentF6001);

            this.DBf6001BindingSource.DataSource = _CurrentF6001;
            this.f6001BindingSource.DataSource   = new Model.F6001(_CurrentF6001);
            btEnregistrer.Click += BtEnregistrer_Click;
            btExporter.Click    += BtExporter_Click;
            //this.gridView1.OptionsView.RowAutoHeight = true;
            //colLibelle.AppearanceCell.TextOptions.WordWrap=WordWrap.Wrap;
            saveFileDialog1.FileName = controller.GetXmlFileName(this.DBf6001BindingSource.Current);
        }
        public F6001ImportForm(Model.F6001 currentF6001)
        {
            InitializeComponent();
            CurrentF6001 = currentF6001;

            _fileName = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), Application.ProductName, $"ModelImport_{currentF6001.GetType().Name}.xml");
            this.f6001BindingSource.DataSource = CurrentF6001;
            if (File.Exists(_fileName))
            {
                try
                {
                    this.excelDataSource1.LoadFromXml(XElement.Load(_fileName));
                    excelDataSource1.Fill();
                    var col1 = "Code Rubrique (Brut)";
                    var col2 = "Code Rubrique(Prov/Amort)";
                    //var col1 = "Code Rubrique (Net)";
                    var col3 = "Code Rubrique (Net N-1)";
                    //var col1 = "Libelle";
                    var col4 = "Brut";
                    var col5 = "Prov / Amort";
                    var col6 = "Net N-1";
                    //
                    this.CodeRubBrutcomboBoxEdit.Properties.Items.Clear();
                    this.CodeRubBrutcomboBoxEdit.Properties.Items.AddRange(excelDataSource1.Schema
                                                                           .Where(x => x.Type == typeof(string) && x.Selected).Select(x => x.Name).ToList());
                    this.CodeRubBrutcomboBoxEdit.EditValue = excelDataSource1.Schema
                                                             .Where(x => x.Type == typeof(string) && x.Selected).Select(x => x.Name)
                                                             .FirstOrDefault(x => x.Trim() == col1);

                    //
                    this.CodeRubProvcomboBoxEdit.Properties.Items.Clear();
                    this.CodeRubProvcomboBoxEdit.Properties.Items.AddRange(excelDataSource1.Schema
                                                                           .Where(x => x.Type == typeof(string) && x.Selected).Select(x => x.Name).ToList());
                    this.CodeRubProvcomboBoxEdit.EditValue = excelDataSource1.Schema
                                                             .Where(x => x.Type == typeof(string) && x.Selected).Select(x => x.Name)
                                                             .FirstOrDefault(x => x.Trim() == col2);

                    //
                    this.CodeRubN_1comboBoxEdit.Properties.Items.Clear();
                    this.CodeRubN_1comboBoxEdit.Properties.Items.AddRange(excelDataSource1.Schema
                                                                          .Where(x => x.Type == typeof(string) && x.Selected).Select(x => x.Name).ToList());
                    this.CodeRubN_1comboBoxEdit.EditValue = excelDataSource1.Schema
                                                            .Where(x => x.Type == typeof(string) && x.Selected).Select(x => x.Name)
                                                            .FirstOrDefault(x => x.Trim() == col3);

                    //
                    this.ValBrutcomboBoxEdit.Properties.Items.Clear();
                    this.ValBrutcomboBoxEdit.Properties.Items.AddRange(excelDataSource1.Schema
                                                                       .Where(x => Core.Helpers.Helper.IsNumericType(x.Type) && x.Selected).Select(x => x.Name)
                                                                       .ToList());
                    this.ValBrutcomboBoxEdit.EditValue = excelDataSource1.Schema
                                                         .Where(x => Core.Helpers.Helper.IsNumericType(x.Type) && x.Selected).Select(x => x.Name)
                                                         .FirstOrDefault(x => x.Trim() == col4);

                    //
                    this.ValProvcomboBoxEdit.Properties.Items.Clear();
                    this.ValProvcomboBoxEdit.Properties.Items.AddRange(excelDataSource1.Schema
                                                                       .Where(x => Core.Helpers.Helper.IsNumericType(x.Type) && x.Selected).Select(x => x.Name)
                                                                       .ToList());
                    this.ValProvcomboBoxEdit.EditValue = excelDataSource1.Schema
                                                         .Where(x => Core.Helpers.Helper.IsNumericType(x.Type) && x.Selected).Select(x => x.Name)
                                                         .FirstOrDefault(x => x.Trim() == col5);

                    //
                    this.ValN_1comboBoxEdit.Properties.Items.Clear();
                    this.ValN_1comboBoxEdit.Properties.Items.AddRange(excelDataSource1.Schema
                                                                      .Where(x => Core.Helpers.Helper.IsNumericType(x.Type) && x.Selected).Select(x => x.Name)
                                                                      .ToList());
                    this.ValN_1comboBoxEdit.EditValue = excelDataSource1.Schema
                                                        .Where(x => Core.Helpers.Helper.IsNumericType(x.Type) && x.Selected).Select(x => x.Name)
                                                        .FirstOrDefault(x => x.Trim() == col6);
                }
                catch
                {
                    // ignored
                }
            }
            this.buttonEdit1.EditValue     = excelDataSource1.FileName;
            layoutControlGroup3.Visibility = LayoutVisibility.Never;
        }