Пример #1
0
        protected override bool LoadRecordCore()
        {
            //ORM
            this.ormCompPhoto = Data.QFComponentDetailPhoto.Load((int)this.PrimaryKey);

            // Load by table instead of view. Using views for editing sucks...
            this.ormMovementsNA = Data.TComponentMovement.LoadBy("Component =@param0 and MovementCode =@param1", (int)this.PrimaryKey, "NA");
            // Load by table instead of view. Using views for editing sucks...
            this.ormMovementsVY = Data.TComponentMovement.LoadBy("Component =@param0 and MovementCode =@param1", (int)this.PrimaryKey, "VY");

            //historie zmen
            SqlDataAdapter hZmen = SmartISLib.Data.GetDataAdapter("select * from QHistorie where componentID =@compID ORDER BY UpdateDate");
            hZmen.SelectCommand.Parameters.AddWithValue("compID", (int)this.PrimaryKey);
            hZmenDTAB = new DataTable();
            hZmen.Fill(hZmenDTAB);
            //prikazy k vyskladneni
            SqlDataAdapter pKvyskladneni = SmartISLib.Data.GetDataAdapter("select * from QFComponentDetailVyskladneni where ComponentID =@ID");
            pKvyskladneni.SelectCommand.Parameters.AddWithValue("ID", (int)this.PrimaryKey);
            kVyskladneniDTAB = new DataTable();
            pKvyskladneni.Fill(kVyskladneniDTAB);
            //Hlavni komponent pro
            SqlDataAdapter komp = SmartISLib.Data.GetDataAdapter("select * from QFComponentDetailMainComp where component =@ID");
            komp.SelectCommand.Parameters.AddWithValue("ID", (int)this.PrimaryKey);
            kompDTAB = new DataTable();
            komp.Fill(kompDTAB);

            // Revize casu
            SqlDataAdapter revizeC = SmartISLib.Data.GetDataAdapter("SELECT * FROM QFComponentDetailRevision WHERE Component =@PK");
            revizeC.SelectCommand.Parameters.AddWithValue("PK", ormCompPhoto.ComponentID);
            revizeCasuDTAB = new DataTable();
            revizeC.Fill(revizeCasuDTAB);

            // drop down zpusob naskladneni
            SqlDataAdapter zpusobDrdown = SmartISLib.Data.GetDataAdapter("SELECT MovementTypeName FROM TMovementTypes WHERE MovementCode = 'NA'");
            zpusobNaskladneniDrDownDTAB = new DataTable();
            zpusobDrdown.Fill(zpusobNaskladneniDrDownDTAB);

            // drop down zpusob odepsani
            SqlDataAdapter dalsiDRDownAdapter = SmartISLib.Data.GetDataAdapter("SELECT MovementTypeName FROM TMovementTypes WHERE MovementCode = 'VY'");
            zpusobOdepsaniDrDownDTAB = new DataTable();
            dalsiDRDownAdapter.Fill(zpusobOdepsaniDrDownDTAB);

            // drop down typ fotky
            SqlDataAdapter fotoAdapt = SmartISLib.Data.GetDataAdapter("select distinct Image from QFComponentDetailRevisionDetail");
            this.typFotkyDTAB = new DataTable();
            fotoAdapt.Fill(typFotkyDTAB);

            return true;
        }
Пример #2
0
        /// <summary>
        /// Naimportuje data z excelu do databaze.
        /// Excelovsky soubor musi obsahovat objekt s nazvem Masterlist!
        /// </summary>
        /// <param name="file">cela cesta k souboru</param>
        /// <returns>True, pokud nacetl, jinak false. V pripade chyby vypise chybovou zpravu uzivateli.</returns>
        private bool importExcel(string file)
        {
            try
            {
                SmartISLib.Session.BeginTransaction();
                //SmartISLib.Session.BeginTransaction();
                string connectionExcel = string.Format("Provider=Microsoft.Jet.OLEDB.4.0;Data Source={0};Extended Properties='Excel 8.0;HDR=Yes;'", file);
                using (OleDbConnection connection = new OleDbConnection(connectionExcel))
                {
                    connection.Open();
                    OleDbCommand command = new OleDbCommand("select * from [Masterlist$]", connection);

                    using (OleDbDataReader dr = command.ExecuteReader())
                    {
                        //vymaze data
                        SmartISLib.Data.Execute(" DELETE FROM TMasterListTmp");
                        tMaster = new SmartISLib.ORM.DbTable<Data.TMasterListTmp>();
                        while (dr.Read())
                        {
                            Data.TMasterListTmp tmp = Data.TMasterListTmp.Create();
                            foreach (string key in mapping.Keys)
                            {
                                tmp[mapping[key]] = dr[key];
                            }
                            tMaster.Add(tmp);
                        }
                        dr.Close();
                    }
                    connection.Close();
                }
                tMaster.Save();

                // procedura z db...
                Data.Procedures.SPComponentImport2();

                SmartISLib.Session.CommitTransaction();
            }
            catch (Exception ex)
            {
                SmartISLib.Session.RollbackTransaction();
                SmartISLib.Messages.Error(ex.Message);
                return false;
            }

            return true;
        }
Пример #3
0
        protected override void BindData()
        {
            base.NewRecordAvailable = false;

            int zemeIndex = -1, personIndex = -1;
            //  Zeme/////////////////////////////
            this.comboBoxZeme.DataSource = this.ormTZeme;
            this.comboBoxZeme.DisplayMember = "Zeme";
            string zem = Convert.ToString(myDtab.Rows[0]["ZemeStr"]);
            for (int i = 0; i < ormTZeme.Count; i++)
            {
                if (ormTZeme[i].Zeme == zem)
                {
                    zemeIndex = i;
                    break;
                }
            }
            if(zemeIndex > 0)
                this.comboBoxZeme.SelectedIndex = zemeIndex;

            // person/////////////////////////////
            this.comboBoxVytvorilKdo.DataSource = this.ormTPersonResponsiblePhoto;
            this.comboBoxVytvorilKdo.DisplayMember = "ResponsiblePhotoSurname";
            string personS = Convert.ToString(myDtab.Rows[0]["CreatedByStr"]);
            for (int i = 0; i < ormTPersonResponsiblePhoto.Count; i++)
            {
                if (ormTPersonResponsiblePhoto[i].ResponsiblePhotoSurname == personS)
                {
                    personIndex = i;
                    break;
                }
            }
            if (personIndex > 0)
                this.comboBoxVytvorilKdo.SelectedIndex = personIndex;

            //BindComboBox(this.comboBoxVytvorilKdo, "SELECT IDPDMStatusPhoto, PDMStatusPhoto FROM TPDMStatusPhoto", "IDPDMStatusPhoto", "PDMStatusPhoto", ormTPersonResponsiblePhoto, "PDMStatusPhotoID");

            this.ColumnComponent.DataSource = this.componentDTAB;
            this.ColumnComponent.ValueMember = "ComponentID";
            this.ColumnComponent.DisplayMember = "Code"; // Displayed value
            this.ColumnComponent.DataPropertyName = this.ColumnComponent.ValueMember; // has to be set this way.. Even thought it worked in in other modules other way...

            // GRID
            this.dataGridViewPrikazyKVyskladneni.DataSource = this.ormPrikazVysklad;

            // TExtboxes//////////////////////////////
            this.textBoxCisloSetu.Text = Convert.ToString(myDtab.Rows[0]["cisloSetu"]);
            this.dateTimePickerDatum.Value = Convert.ToDateTime(myDtab.Rows[0]["Created"]);
            this.textBoxCelkovaHmotnost.Text = Convert.ToString(myDtab.Rows[0]["SumTotalWeight"]);
            this.ormTParameters = Data.TParameters.LoadAll();
            this.textBoxKoef.Text = this.ormTParameters[0].HmotnostKoef.ToString();

            this.vytvorilKdoChanged = false;
            this.zemeChanged = false;
            this.dateChanged = false;
        }
Пример #4
0
        protected override bool LoadRecordCore()
        {
            //vazebni tabulka
            tAttSL = Data.TAttachmentSL.LoadBy("SampleList =@param0", (int)this.PrimaryKey);
            //vlastni data -> nacti vsechny radky
            tAttachment = new SmartISLib.ORM.DbTable<Data.TAttachments>();
            foreach (Data.TAttachmentSL t in tAttSL)
            {
                tAttachment.Add(Data.TAttachments.Load(t.Attachment));
            }

            velikostKrabicComboData = Data.TSampleListCis.LoadBy("SCategory =@param0", "VelikostKrabice");
            velikostKrabicComboData.Sort("Name");

            zpracovalWIComboData = Data.TPersonResponsiblePhoto.LoadBy("ResponsiblePhotoCode !=@param0", "null");
            zpracovalWIComboData.Sort("ResponsiblePhotoCode");

            kdoSchvalilWIComboData = Data.TPersonResponsiblePhoto.LoadBy("ResponsiblePhotoCode !=@param0", "null");
            zpracovalWIComboData.Sort("ResponsiblePhotoCode");

            druhBaleniComboData = Data.TSampleListCis.LoadBy("SCategory =@param0 and Name !=@param1", "DruhBaleni", "null");
            druhBaleniComboData.Sort("Name");

            zemeComboData = Data.TZeme.LoadAll();
            zemeComboData.Sort("Zeme");

            statusSetuComboData = Data.TSampleListCis.LoadBy("SCategory =@param0  and Name !=@param1", "status", "null");
            statusSetuComboData.Sort("Name");

            breatherBagComboData = Data.TSampleListCis.LoadBy("SCategory =@param0 and name !=@param1", "BreatherBag", "null");
            breatherBagComboData.Sort("Name");

            parentDTAB = SmartISLib.Data.GetDataTable("SELECT * FROM QFSampleListsTest WHERE IDSampleList = " + (int)this.PrimaryKey);

            prikazyKVyskladneniDTAB = SmartISLib.Data.GetDataTable("select * from QFPrikazVyskladneniSeznam where CisloSetu = '" + Convert.ToString(parentDTAB.Rows[0]["CisloSetu"]) + "'");

            historieZmenDTAB = SmartISLib.Data.GetDataTable("SELECT * FROM THistoryUpdates WHERE TableID = " + (int)this.PrimaryKey);

            metodaBalenHlavniiDTAB = SmartISLib.Data.GetDataTable("select * from QSLMetodaBaleniHlavni");

            metodaBaleniVedlejsiDTAB = SmartISLib.Data.GetDataTable("select * from QSLMetodaBaleniVedlejsi");

            return true;
        }
Пример #5
0
        protected override bool LoadRecordCore()
        {
            SqlDataAdapter myAdapter = SmartISLib.Data.GetDataAdapter("SELECT * FROM QFPrikazVyskladneniSeznam where IDPrikazVyskladneni =@PK");
            myAdapter.SelectCommand.Parameters.AddWithValue("PK", (int)this.PrimaryKey);
            myDtab = new DataTable();
            myAdapter.Fill(myDtab);

            this.ormPrikazVysklad = Data.QFPrikazVyskladDetail.LoadByPrikazVyskladID((int)this.PrimaryKey);

            SqlDataAdapter adapterComponent = SmartISLib.Data.GetDataAdapter("SELECT ComponentID, Code FROM TComponents WHERE Code IS NOT NULL ORDER BY Code");
            this.componentDTAB = new DataTable();
            adapterComponent.Fill(componentDTAB);

            // if surname is null, the exception occured in sort...
            this.ormTPersonResponsiblePhoto = Data.TPersonResponsiblePhoto.LoadBy("ResponsiblePhotoSurname !=@param0", "NULL");
            this.ormTPersonResponsiblePhoto.Sort("ResponsiblePhotoSurname");
            this.ormTZeme = Data.TZeme.LoadAll();
            this.ormTZeme.Sort("Zeme");

            return true;
        }