Exemple #1
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            string errorMsg = string.Empty;

            if (string.IsNullOrEmpty(tbPaperName.Text) || string.IsNullOrEmpty(tbCitaton.Text) || string.IsNullOrEmpty(tbRef.Text))
            {
                MessageBox.Show("Please enter Common details for Paper");
            }
            else
            {
                int nextPid = MasterDataAccess.GetNextPID(conn) + 1;
                CommonDataSaveModel cmdModel = new CommonDataSaveModel();
                cmdModel.PId = nextPid;
                if (!string.IsNullOrEmpty(tbPaperName.Text))
                {
                    cmdModel.PName = tbPaperName.Text;
                }
                if (!string.IsNullOrEmpty(tbCitaton.Text))
                {
                    cmdModel.PCitation = tbCitaton.Text;
                }
                if (!string.IsNullOrEmpty(tbRef.Text))
                {
                    cmdModel.PRef = tbRef.Text;
                }

                TrainingDataModel tdModel = new TrainingDataModel();
                tdModel.PId = nextPid;
                if (!string.IsNullOrEmpty(cmbAArea.SelectedItem.ToString()))
                {
                    tdModel.AaID = MasterDataAccess.GetIDForAValue("applicationarea", "aaName", "aaID", cmbAArea.SelectedItem.ToString(), conn);
                }

                if (!string.IsNullOrEmpty(cmbBcType.SelectedItem.ToString()))
                {
                    tdModel.BcnID = MasterDataAccess.GetIDForAValue("BCNetworks", "bcnName", "bcnID", cmbBcType.SelectedItem.ToString(), conn);
                }

                if (!string.IsNullOrEmpty(cmbNwPart.SelectedItem.ToString()))
                {
                    tdModel.BcnpID = MasterDataAccess.GetIDForAValue("BCNWParticipation", "bcnpName", "bcnpID", cmbNwPart.SelectedItem.ToString(), conn);
                }

                if (!string.IsNullOrEmpty(cmbConsensus.SelectedItem.ToString()))
                {
                    tdModel.BccID = MasterDataAccess.GetIDForAValue("BCConsensus", "bccName", "BccID", cmbConsensus.SelectedItem.ToString(), conn);
                }

                if (!string.IsNullOrEmpty(cmbScalability.SelectedItem.ToString()))
                {
                    tdModel.BcsID = MasterDataAccess.GetIDForAValue("BCScalability", "bcsName", "BcsID", cmbScalability.SelectedItem.ToString(), conn);
                }

                if (!string.IsNullOrEmpty(cmbLatency.SelectedItem.ToString()))
                {
                    tdModel.BclID = MasterDataAccess.GetIDForAValue("BCLatency", "bclName", "BclID", cmbLatency.SelectedItem.ToString(), conn);
                }

                if (!string.IsNullOrEmpty(cmbPerf.SelectedItem.ToString()))
                {
                    tdModel.BcprID = MasterDataAccess.GetIDForAValue("BCPerformance", "bcprName", "BcprID", cmbPerf.SelectedItem.ToString(), conn);
                }

                if (!string.IsNullOrEmpty(cmbDataAccess.SelectedItem.ToString()))
                {
                    tdModel.BcdaID = MasterDataAccess.GetIDForAValue("BCDataAccess", "bcdaName", "BcdaID", cmbDataAccess.SelectedItem.ToString(), conn);
                }

                if (!string.IsNullOrEmpty(cmbDap.SelectedItem.ToString()))
                {
                    tdModel.BcdapID = MasterDataAccess.GetIDForAValue("BCDataAccessPolicy", "bcdapName", "BcdapID", cmbDap.SelectedItem.ToString(), conn);
                }

                if (!string.IsNullOrEmpty(cmbDataFormat.SelectedItem.ToString()))
                {
                    tdModel.bcdfID = MasterDataAccess.GetIDForAValue("BCDataFormat", "bcdfName", "bcdfID", cmbDataFormat.SelectedItem.ToString(), conn);
                }

                if (!string.IsNullOrEmpty(cmbAs.SelectedItem.ToString()))
                {
                    tdModel.AsID = MasterDataAccess.GetIDForAValue("ArchitectureStyle", "asName", "AsID", cmbAs.SelectedItem.ToString(), conn);
                }

                if (!string.IsNullOrEmpty(cmbAsNFR.SelectedItem.ToString()))
                {
                    tdModel.NfrasID = MasterDataAccess.GetIDForAValue("NFRsInArchitecture", "nfrasName", "NfrasID", cmbAsNFR.SelectedItem.ToString(), conn);
                }

                if (!string.IsNullOrEmpty(cmbDS.SelectedItem.ToString()))
                {
                    tdModel.DsID = MasterDataAccess.GetIDForAValue("DataStorageSystems", "dsName", "DsID", cmbDS.SelectedItem.ToString(), conn);
                }

                if (!string.IsNullOrEmpty(cmbBcPlat.SelectedItem.ToString()))
                {
                    tdModel.BpID = MasterDataAccess.GetIDForAValue("BlockchainPlatforms", "bpName", "BpID", cmbBcPlat.SelectedItem.ToString(), conn);
                }

                if (!string.IsNullOrEmpty(cmbarFeatures.SelectedItem.ToString()))
                {
                    tdModel.RsID = MasterDataAccess.GetIDForAValue("resultsobtained", "rsName", "rsID", cmbarFeatures.SelectedItem.ToString(), conn);
                }

                if (!MasterDataAccess.SaveCommonDetails(cmdModel, tdModel, conn, ref errorMsg))
                {
                    MessageBox.Show(string.Format("PRoblem in saving taraining data. The Reason is {0}", errorMsg));
                }
                else
                {
                    MessageBox.Show("Data Inserted sucessfully");
                }
                this.Close();
            }
        }