コード例 #1
0
ファイル: MainForm.cs プロジェクト: artmachinez/bc
        private void OpenFile(object sender, EventArgs e)
        {
            OpenFileDialog openFileDialog = CFileDialogFactory.createOpenFileDialog();

            if (openFileDialog.ShowDialog(this) == DialogResult.OK)
            {
                // Get variables needed for canvastabpage
                string fileURL = openFileDialog.FileName;

                CProjectInfo info = CFileHelper.getProject(fileURL);

                if (info == null)
                {
                    MessageBox.Show("Unable to open project", "Error in opening file");
                    return;
                }

                CanvasTabPage tabPage = CCanvasTabPageFactory.createPage(CFileHelper.getProject(fileURL), fileURL);

                // And add it to tabControl
                pageContainerControl.TabPages.Add(tabPage);
                pageContainerControl.SelectedTab = tabPage;

                // Manually cast selectindexchanged, since it doesnt fire when the first tab
                // is opened
                this.pageContainerControl_SelectedIndexChanged(null, null);

                CFormController.Instance.mainForm.setStatus("Project Opened");

                this.showToolBox();
            }
        }
コード例 #2
0
ファイル: MainForm.cs プロジェクト: artmachinez/bc
        private void ShowNewForm(object sender, EventArgs e)
        {
            SaveFileDialog saveFileDialog = CFileDialogFactory.createNewFileDialog();

            if (saveFileDialog.ShowDialog(this) == DialogResult.OK)
            {
                // Get variables needed for canvastabpage
                string fileURL = saveFileDialog.FileName;

                // New form - new info
                CProjectInfo projectInfo = new CProjectInfo();
                projectInfo.languageID = ((CLanguageInfo)CFormController.Instance.languageBox.SelectedItem).Value;

                // Create tabpage from them
                CanvasTabPage tabPage = CCanvasTabPageFactory.createNewPage(projectInfo, fileURL);

                // And add it to tabControl
                pageContainerControl.TabPages.Add(tabPage);
                pageContainerControl.SelectedTab = tabPage;

                // Manually cast selectindexchanged, since it doesnt fire when the first tab
                // is opened
                this.pageContainerControl_SelectedIndexChanged(null, null);

                // Save it also
                CFileHelper.saveProject(tabPage.projectInfo, tabPage.url);

                CFormController.Instance.mainForm.setStatus("Project Created");

                showToolBox();
            }
        }
コード例 #3
0
        /// <summary>
        /// Saves serialized ProjectInfo to file
        /// </summary>
        /// <param name="projectInfo">ProjectInfo to get serialized</param>
        /// <param name="url">Url of file to save to</param>
        /// <returns>Boolean of success</returns>
        public static bool saveProject(CProjectInfo projectInfo, String url)
        {
            // Init serializer
            DataContractSerializer serializer = new DataContractSerializer(typeof(CProjectInfo));
            StreamWriter           sw         = null;

            try
            {
                // Init stream to file
                sw = new StreamWriter(url);

                // Serialize projectInfo to file
                serializer.WriteObject(sw.BaseStream, projectInfo);
            }
            catch (IOException)
            {
                return(false);
            }
            finally
            {
                // Whatever happened, try to close the file
                if (sw != null)
                {
                    sw.Close();
                }
            }
            return(true);
        }
コード例 #4
0
        public static void DeletePLH(CProjectInfo ProjectInfo)
        {
            Cnpgsql delete = new Cnpgsql();

            NpgsqlCommand[] deleteCommands = new NpgsqlCommand[2];


            NpgsqlCommand deleteCommander = new NpgsqlCommand();

            string sql;

            sql = $"delete from plh01t00    " +
                  $" where project_cd =  :p_project_cd   ";

            deleteCommander.CommandText = sql;
            deleteCommander.Parameters.AddWithValue("p_project_cd", ProjectInfo.ProjectCD);

            deleteCommands[0] = deleteCommander;


            //////////////////////////////////////
            NpgsqlCommand deleteCommander2 = new NpgsqlCommand();


            sql = "";
            sql = $"delete from plh01m00    " +
                  $" where project_cd =  :p_project_cd   ";

            deleteCommander2.CommandText = sql;
            deleteCommander2.Parameters.AddWithValue("p_project_cd", ProjectInfo.ProjectCD);

            deleteCommands[1] = deleteCommander2;

            delete.delete(deleteCommands);
        }
コード例 #5
0
ファイル: XtraBaseForm.cs プロジェクト: cjooni/ReadPLH
        public XtraBaseForm()
        {
            InitializeComponent();

            m_UserInfo    = new CUserInfo();
            m_ProjectInfo = new CProjectInfo();
        }
コード例 #6
0
        public void TestProjectAdd1()
        {
            // TODO: Add your test.
            CProjectInfo tp = new CProjectInfo();

            tp.ProjectName = "测试添加,不包含projectID";
            CProjectInfoBLL.AddProjectInfo(tp);
        }
コード例 #7
0
        /// <summary>
        /// Creates new page with new project. Project info must be passed
        /// </summary>
        /// <param name="projectInfo"></param>
        /// <param name="url">Url of file (which project will be saved in)</param>
        /// <returns></returns>
        internal static CanvasTabPage createPage(CProjectInfo projectInfo, String url)
        {
            CanvasTabPage tabPage = new CanvasTabPage();

            tabPage.projectInfo          = projectInfo;
            tabPage.activeProjectContent = projectInfo.projectXml;
            tabPage.Text = System.IO.Path.GetFileName(url);
            tabPage.url  = url;
            return(tabPage);
        }
コード例 #8
0
        /// <summary>
        /// Creates new page with new project. Project info must be passed
        /// </summary>
        /// <param name="projectInfo"></param>
        /// <param name="url">Url of file (which project will be saved in)</param>
        /// <returns></returns>
        internal static CanvasTabPage createNewPage(CProjectInfo projectInfo, String url)
        {
            CanvasTabPage tabPage = new CanvasTabPage();

            tabPage.projectInfo          = projectInfo;
            tabPage.activeProjectContent = ProjectResources.new_file.ToString();
            tabPage.Text = System.IO.Path.GetFileName(url);
            tabPage.url  = url;
            return(tabPage);
        }
コード例 #9
0
        void ListBox1SelectedIndexChanged(object sender, EventArgs e)
        {
            if (((ListBox)sender).SelectedItem == null)
            {
                return;
            }
            Debug.WriteLine("当前选择:" + ((ListItem)((ListBox)sender).SelectedItem).Value);
            CProjectInfo tp = CProjectInfoBLL.GetProjectInfo(Convert.ToInt32(((ListItem)((ListBox)sender).SelectedItem).Value));

            textBoxProjectID.Text   = tp.ProjectID.ToString();
            textBoxProjectName.Text = tp.ProjectName;
            textBoxBuildArea.Text   = tp.BuildArea.ToString();
            textBoxContractor.Text  = tp.Contractor;
            textBoxMomo.Text        = tp.Memo;
        }
コード例 #10
0
        //获取指定ProjectID的对象
        public static CProjectInfo GetProjectInfo(int i_ProjectID)
        {
            ISession     session = NHibernateHelper.OpenSession();
            CProjectInfo tClass  = new CProjectInfo();

            try
            {
                tClass = session.Get <CProjectInfo>(i_ProjectID);
            }
            catch (Exception e)
            {
                Debug.Assert(false, e.Message);
            }
            session.Close();
            return(tClass);
        }
コード例 #11
0
        /// <summary>
        /// Generates complete page to specified path
        /// Project content of the page is in projectInfo.projectXml, language
        /// which to generate to is in projectInfo.languageID
        /// </summary>
        /// <param name="projectInfo">ProjectInfo instance</param>
        /// <param name="path">Path of HTML index</param>
        /// <returns>Boolean of success</returns>
        public static bool generatePage(CProjectInfo projectInfo, String path)
        {
            List <AModule> moduleList;
            String         index = CXMLParser.Instance.GetHTMLFromProjectXML(projectInfo.projectXml, out moduleList);

            // Save html file
            if (!saveFile(index, path))
            {
                return(false);
            }

            // Generate all the templates in module directory
            foreach (AModule module in moduleList)
            {
                // Get module name
                String moduleName = (String)module.GetType().GetField("name", BindingFlags.Static | BindingFlags.Public | BindingFlags.GetProperty).GetValue(null);

                // Create directory for each module
                String        newDirPath      = Path.GetDirectoryName(path) + Path.DirectorySeparatorChar + "modules" + Path.DirectorySeparatorChar + module.setup.id;
                DirectoryInfo di              = null;
                String[]      moduleResources = module.GetType().Assembly.GetManifestResourceNames();
                foreach (String resource in moduleResources)
                {
                    // There are more resources - preview one, html one,
                    // but just those in given language are needed
                    String nspace = "Modules." + moduleName + "_Templates." + projectInfo.languageID;
                    if (resource.StartsWith(nspace))
                    {
                        // Create directory only if needed
                        if (di == null)
                        {
                            di = Directory.CreateDirectory(newDirPath);
                        }

                        String name             = resource.Substring(nspace.Length + 1);
                        String renderedTemplate = module.renderTemplate(projectInfo.languageID + "." + name);

                        if (!saveFile(renderedTemplate, newDirPath + Path.DirectorySeparatorChar + name))
                        {
                            return(false);
                        }
                    }
                }
            }
            return(true);
        }
コード例 #12
0
        //添加项目信息
        public static void AddProjectInfo(CProjectInfo t_add)
        {
            //ISessionFactory sessionFactory = new Configuration().Configure().BuildSessionFactory();
            ISession     session = NHibernateHelper.sessionFactory.OpenSession();
            ITransaction tx      = session.BeginTransaction();

            try
            {
                session.Save(t_add);
                tx.Commit();
                session.Close();
            }
            catch (Exception e)
            {
                Debug.Assert(false, e.Message);
                tx.Rollback();
                session.Close();
            }
        }
コード例 #13
0
        //删除
        public static void DelProjectInfo(int iProjectID)
        {
            //ISessionFactory sessionFactory = new Configuration().Configure().BuildSessionFactory();
            ISession     session  = NHibernateHelper.OpenSession();
            ITransaction tx       = session.BeginTransaction();
            CProjectInfo toDelete = session.Get <CProjectInfo>(iProjectID);

            try
            {
                session.Delete(toDelete);
                tx.Commit();
                session.Close();
            }
            catch (Exception e)
            {
                Debug.Assert(false, e.Message);
                tx.Rollback();
                session.Close();
            }
        }
コード例 #14
0
        //修改
        public static void UpdateProjectInfo(CProjectInfo t_modify)
        {
            ISession session = NHibernateHelper.OpenSession();

            try
            {
                ITransaction tx      = session.BeginTransaction();
                CProjectInfo tResult = session.Get <CProjectInfo>(t_modify.ProjectID);
                tResult.ProjectName = t_modify.ProjectName;
                tResult.BuildArea   = t_modify.BuildArea;
                tResult.Contractor  = t_modify.Contractor;
                tResult.ProjectDays = t_modify.ProjectDays;
                tResult.Memo        = t_modify.Memo;
                tx.Commit();
            }
            catch (Exception e)
            {
                Debug.Assert(false, e.Message);
            }
            session.Close();
        }
コード例 #15
0
        //添加新项目
        void ButtonAddClick(object sender, EventArgs e)
        {
            int i_LastProjectID;

            i_LastProjectID = CProjectInfoBLL.GetMaxProjectID();
            Debug.WriteLine("最大ProjectID=" + i_LastProjectID.ToString());
            //检测输入合理性
            if (CheckFillOK())
            {
                CProjectInfo tp = new CProjectInfo();
                tp.ProjectID   = i_LastProjectID + 1;
                tp.ProjectName = textBoxProjectName.Text.Trim();
                if (textBoxBuildArea.Text != "")
                {
                    tp.BuildArea = Convert.ToInt32(textBoxBuildArea.Text);
                }
                else
                {
                    tp.BuildArea = 0;
                }
                tp.Contractor = textBoxContractor.Text.Trim();
                if (textBoxProjectDays.Text != "")
                {
                    tp.ProjectDays = Convert.ToInt32(textBoxProjectDays.Text);
                }
                else
                {
                    tp.ProjectDays = 0;
                }
                tp.Memo = textBoxMomo.Text.Trim();

                //添加到数据库中
                CProjectInfoBLL.AddProjectInfo(tp);
                //刷新listbox
                FillListBox1();
                listBox1.Refresh();
//				listBox1.Invalidate();
//				listBox1.Update();
            }
        }
コード例 #16
0
        //修改
        void ButtonModifyClick(object sender, EventArgs e)
        {
            if (listBox1.SelectedItem == null)
            {
                return;
            }
            if (CheckFillOK())
            {
                CProjectInfo tp = new CProjectInfo();
                tp.ProjectID   = Convert.ToInt32(((ListItem)listBox1.SelectedItem).Value);
                tp.ProjectName = textBoxProjectName.Text;
                if (textBoxBuildArea.Text == "")
                {
                    tp.BuildArea = 0;
                }
                else
                {
                    tp.BuildArea = Convert.ToInt32(textBoxBuildArea.Text);
                }
                tp.Contractor = textBoxContractor.Text;
                if (textBoxProjectDays.Text == "")
                {
                    tp.ProjectDays = 0;
                }
                else
                {
                    tp.ProjectDays = Convert.ToInt32(textBoxProjectDays.Text);
                }
                tp.Memo = textBoxMomo.Text;

                CProjectInfoBLL.UpdateProjectInfo(tp);

                //刷新listbox
                FillListBox1();
            }
        }
コード例 #17
0
ファイル: XtraPLH.cs プロジェクト: cjooni/ReadPLH
        public XtraPLH(CProjectInfo paramProjectInfo)
        {
            InitializeComponent();

            ProjectInfo = paramProjectInfo;
        }
コード例 #18
0
        public static void SavePLH(CProjectInfo ProjectInfo, DataTable dt)
        {
            Cnpgsql qry = new Cnpgsql();


            NpgsqlCommand[] qryCommanders = new NpgsqlCommand[dt.Rows.Count];



            int i = 0;

            foreach (DataRow item in dt.Rows)
            {
                NpgsqlCommand qryCommander = new NpgsqlCommand();

                string sql;

                sql = $"insert into plh01t00    " +
                      $" select :p_project_cd   " +
                      $"      , :p_file_name    " +
                      $"      , :p_line_name    " +
                      $"      , :p_p_node       " +
                      $"      , :p_c_node       ";

                if (i == 0)
                {
                    //노드 구성을 해보자
                    qryCommander.CommandText = sql;
                    qryCommander.Parameters.AddWithValue("p_project_cd", ProjectInfo.ProjectCD);
                    qryCommander.Parameters.AddWithValue("p_file_name", item["FileName"]);
                    qryCommander.Parameters.AddWithValue("p_line_name", item["linename"]);
                    qryCommander.Parameters.AddWithValue("p_p_node", 0);
                    qryCommander.Parameters.AddWithValue("p_c_node", Convert.ToInt16(item["key"].ToString()));
                }
                else
                {
                    if (dt.Rows[i - 1]["linename"].ToString() == item["linename"].ToString())
                    {
                        //노드 구성을 해보자
                        qryCommander.CommandText = sql;
                        qryCommander.Parameters.AddWithValue("p_project_cd", ProjectInfo.ProjectCD);
                        qryCommander.Parameters.AddWithValue("p_file_name", item["FileName"]);
                        qryCommander.Parameters.AddWithValue("p_line_name", item["linename"]);
                        qryCommander.Parameters.AddWithValue("p_p_node", Convert.ToInt16(dt.Rows[i - 1]["key"].ToString()));
                        qryCommander.Parameters.AddWithValue("p_c_node", Convert.ToInt16(item["key"].ToString()));
                    }
                    else
                    {
                        string sss = item["linename"].ToString();
                        string aaa = dt.Rows[i - 1]["linename"].ToString();

                        //노드 구성을 해보자
                        qryCommander.CommandText = sql;
                        qryCommander.Parameters.AddWithValue("p_project_cd", ProjectInfo.ProjectCD);
                        qryCommander.Parameters.AddWithValue("p_file_name", item["FileName"]);
                        qryCommander.Parameters.AddWithValue("p_line_name", item["linename"]);
                        qryCommander.Parameters.AddWithValue("p_p_node", 0);
                        qryCommander.Parameters.AddWithValue("p_c_node", Convert.ToInt16(item["key"].ToString()));
                    }
                }


                sql = "";
                sql = $"insert into plh01m00 " +
                      $" select :p_project_cd " +
                      $"      , :p_key " +
                      $"      , :p_order_seq" +
                      $"      , :p_filename " +
                      $"      , :p_linenumber " +
                      $"      , :p_extention " +
                      $"      , :p_dist" +
                      $"      , :p_dist2" +
                      $"      , :p_gh" +
                      $"      , :p_inv" +
                      $"      , :p_linename" +
                      $"      , :p_dia" +
                      $"      , :p_br" +
                      $"      , :p_type" +
                      $"      , :p_t1" +
                      $"      , :p_slope" +
                      $"      , :p_bcut" +
                      $"      , :p_hcut" +
                      $"      , :p_manwork" +
                      $"      , :p_sand" +
                      $"      , :p_baseangle" +
                      $"      , :p_conca" +
                      $"      , :p_concb" +
                      $"      , :p_humanity" +
                      $"      , :p_concrete" +
                      $"      , :p_asphalt1" +
                      $"      , :p_asphalt2" +
                      $"      , :p_complay" +
                      $"      , :p_mixlay" +
                      $"      , :p_mixlay1" +
                      $"      , :p_mixlay2" +
                      $"      , :p_area1" +
                      $"      , :p_area2" +
                      $"      , :p_area3" +
                      $"      , :p_area4" +
                      $"      , :p_area5" +
                      $"      , :p_area6" +
                      $"      , :p_area7" +
                      $"      , :p_area8" +
                      $"      , :p_area9" +
                      $"      , :p_area10" +
                      $"      , :p_area11" +
                      $"      , :p_t2" +
                      $"      , :p_t3" +
                      $"      , :p_t4" +
                      $"      , :p_b" +
                      $"      , :p_h" +
                      $"      , :p_dir " +
                      $"      , :p_pavement_stat";

                qryCommander.CommandText = sql;

                qryCommander.Parameters.AddWithValue("p_project_cd", ProjectInfo.ProjectCD);
                qryCommander.Parameters.AddWithValue("p_key", item["key"].ToString());
                qryCommander.Parameters.AddWithValue("p_order_seq", item["order_seq"].ToString());
                qryCommander.Parameters.AddWithValue("p_filename", item["FileName"].ToString());     //string
                qryCommander.Parameters.AddWithValue("p_linenumber", item["linenumber"].ToString()); //string
                qryCommander.Parameters.AddWithValue("p_extention", item["extention"].ToString());   //plus
                qryCommander.Parameters.AddWithValue("p_dist", item["dist"].ToString());
                qryCommander.Parameters.AddWithValue("p_dist2", item["dist2"].ToString());
                qryCommander.Parameters.AddWithValue("p_gh", item["gh"].ToString());
                qryCommander.Parameters.AddWithValue("p_inv", item["inv"].ToString());
                qryCommander.Parameters.AddWithValue("p_linename", item["linename"].ToString()); //string
                qryCommander.Parameters.AddWithValue("p_dia", item["dia"].ToString());
                qryCommander.Parameters.AddWithValue("p_br", item["br"].ToString());
                qryCommander.Parameters.AddWithValue("p_type", item["type"].ToString());
                qryCommander.Parameters.AddWithValue("p_t1", item["t1"].ToString());
                qryCommander.Parameters.AddWithValue("p_slope", item["slope"].ToString());
                qryCommander.Parameters.AddWithValue("p_bcut", item["bcut"].ToString());
                qryCommander.Parameters.AddWithValue("p_hcut", item["hcut"].ToString());
                qryCommander.Parameters.AddWithValue("p_manwork", item["manwork"].ToString());
                qryCommander.Parameters.AddWithValue("p_sand", item["sand"].ToString());
                qryCommander.Parameters.AddWithValue("p_baseangle", item["baseangle"].ToString());
                qryCommander.Parameters.AddWithValue("p_conca", item["conca"].ToString());
                qryCommander.Parameters.AddWithValue("p_concb", item["concb"].ToString());
                qryCommander.Parameters.AddWithValue("p_humanity", item["humanity"].ToString());
                qryCommander.Parameters.AddWithValue("p_concrete", item["concrete"].ToString());
                qryCommander.Parameters.AddWithValue("p_asphalt1", item["asphalt1"].ToString());
                qryCommander.Parameters.AddWithValue("p_asphalt2", item["asphalt2"].ToString());
                qryCommander.Parameters.AddWithValue("p_complay", item["complay"].ToString());
                qryCommander.Parameters.AddWithValue("p_mixlay", item["mixlay"].ToString());
                qryCommander.Parameters.AddWithValue("p_mixlay1", item["mixlay1"].ToString());
                qryCommander.Parameters.AddWithValue("p_mixlay2", item["mixlay2"].ToString());
                qryCommander.Parameters.AddWithValue("p_area1", item["area1"].ToString());
                qryCommander.Parameters.AddWithValue("p_area2", item["area2"].ToString());
                qryCommander.Parameters.AddWithValue("p_area3", item["area3"].ToString());
                qryCommander.Parameters.AddWithValue("p_area4", item["area4"].ToString());
                qryCommander.Parameters.AddWithValue("p_area5", item["area5"].ToString());
                qryCommander.Parameters.AddWithValue("p_area6", item["area6"].ToString());
                qryCommander.Parameters.AddWithValue("p_area7", item["area7"].ToString());
                qryCommander.Parameters.AddWithValue("p_area8", item["area8"].ToString());
                qryCommander.Parameters.AddWithValue("p_area9", item["area9"].ToString());
                qryCommander.Parameters.AddWithValue("p_area10", item["area10"].ToString());
                qryCommander.Parameters.AddWithValue("p_area11", item["area11"].ToString());
                qryCommander.Parameters.AddWithValue("p_t2", item["t2"].ToString());
                qryCommander.Parameters.AddWithValue("p_t3", item["t3"].ToString());
                qryCommander.Parameters.AddWithValue("p_t4", item["t4"].ToString());
                qryCommander.Parameters.AddWithValue("p_b", item["b"].ToString());
                qryCommander.Parameters.AddWithValue("p_h", item["h"].ToString());
                qryCommander.Parameters.AddWithValue("p_dir", item["dir"].ToString());

                qryCommanders[i] = qryCommander;

                i++;
            }

            qry.insert(qryCommanders);
        }