コード例 #1
0
ファイル: BoatView.cs プロジェクト: fh222dt/OOAD
        public int BoatMenu(model.Boat a_boat)
        {
            Console.Clear();
            Console.WriteLine("");
            Console.WriteLine("-----Boat specifics-----");
            Console.WriteLine("Type: {0}", a_boat.GetType());
            Console.WriteLine("Length: {0}", a_boat.GetLength());

            Console.WriteLine("");
            Console.WriteLine("---------------");
            Console.WriteLine("");
            Console.WriteLine("(D) to Delete boat (U) to Update boat");
            ConsoleKeyInfo input = Console.ReadKey();
            if (input.Key == ConsoleKey.D)
            {
                return 1;
            }

            else if (input.Key == ConsoleKey.U)
            {
                return 2;
            }

            else return 0;          //returnera nåt annat
        }
コード例 #2
0
 public BasicViewModel(model entity)
 {
     this.id          = entity.Id;
     this.title       = entity.title;
     this.detail      = entity.detail;
     this.price       = entity.price;
     this.date        = entity.date;
     this.customer_id = entity.customer_id;
     this.category_Id = entity.category_Id;
     this.resources   = entity.resources;
     this.articleType = entity.GetType().BaseType.Name;
 }
コード例 #3
0
ファイル: BoatView.cs プロジェクト: fh222dt/OOAD
        public model.Boat DeleteBoat(model.Boat a_selectedBoat, model.Member a_selectedMember)
        {
            Console.Clear();
            Console.WriteLine("");
            Console.WriteLine("-----Delete boat from registry-----");
            Console.WriteLine("Do you want to DELETE the following boat?");
            Console.WriteLine("Owner:{0} {1}", a_selectedMember.GetFirstName(), a_selectedMember.GetLastName());
            Console.WriteLine("Type: {0}", a_selectedBoat.GetType());
            Console.WriteLine("Length: {0}", a_selectedBoat.GetLength());
            Console.WriteLine("");
            Console.WriteLine("Please press (Y) Yes or (N) No");

            ConsoleKeyInfo input = Console.ReadKey();
            if (input.Key == ConsoleKey.Y)
            {
                return a_selectedBoat;
            }

            else
            {
                return null;
            }
        }
コード例 #4
0
ファイル: BoatView.cs プロジェクト: fh222dt/OOAD
        public model.Boat UpdateBoat(model.Boat a_selectedBoat)
        {
            int boatType;
            double length;

            Console.Clear();
            Console.WriteLine("");
            Console.WriteLine("-----Update boat information-----");
            Console.WriteLine("");
            Console.WriteLine("Type: {0}", a_selectedBoat.GetType());
            Console.WriteLine("Length: {0}", a_selectedBoat.GetLength());
            Console.WriteLine("**********");
            Console.WriteLine("Please change the information by entering below:");
            Console.WriteLine("");
            Console.WriteLine("Boat type: ");
            Console.WriteLine("Please enter (1)Sailboat, (2)Motorsailer, (3)Motorboat, (4)Canoe, (5)Other ");
            boatType = Int32.Parse(Console.ReadLine());
            Console.WriteLine("Length in foot: ");
            length = double.Parse(Console.ReadLine());
            Console.WriteLine("");
            Console.WriteLine("Boat information updated!");

            model.Boat.BoatType type = (model.Boat.BoatType)boatType;

            return new model.Boat(type, length);
        }
コード例 #5
0
ファイル: Jinxiu.cs プロジェクト: mhy123152/MyVSTO
        public void jinxiu()
        {
            try
            {
                Excel.Range ranges = thisWorkSheet.UsedRange;

                string PathHeader = $@"{workPath}result\";
                WriteLine(PathHeader);

                if (!Directory.Exists(PathHeader))
                {
                    Directory.CreateDirectory(PathHeader);
                }

                List <model> list = new List <model>();

                for (int i = 3; i <= ranges.Rows.Count; i++)
                {
                    model m = new model();

                    for (int j = 1; j <= KeyNum; j++)
                    {
                        _PropertyInfo p = m.GetType().GetProperty(ranges.Cells[2, j].Text);
                        p.SetValue(m, ranges.Cells[i, j].Text, null);
                    }

                    list.Add(m);
                }


                //根据Date4 经管通知时间 进行分组
                var q = from m in list
                        group m by m.Date4 into g
                        select g;

                //g 为分组之后的集合
                foreach (var g in q)
                {
                    Word.Table table1 = getTable(doc, "table1");
                    Word.Table table2 = getTable(doc, "table2");

                    //g.Key 为去重以后的经管通知时间
                    string date4 = g.Key;
                    WriteLine(date4);

                    //根据每个分组生成word
                    foreach (model m in g)
                    {
                        WriteLine($"{m.Name}: {m.Date3}");
                        if (!(m.Date3 == "" || m.Date3 == null))
                        {
                            //1.进修结束

                            table1.Rows.Add();
                            table1.Rows[table1.Rows.Count - 1].Cells[1].Range.Text = m.Name;
                            table1.Rows[table1.Rows.Count - 1].Cells[2].Range.Text = m.Class;
                            table1.Rows[table1.Rows.Count - 1].Cells[3].Range.Text = m.Place;
                            table1.Rows[table1.Rows.Count - 1].Cells[4].Range.Text = m.Date1;
                            table1.Rows[table1.Rows.Count - 1].Cells[5].Range.Text = m.Date3;
                        }
                        else
                        {
                            //2.外出进修

                            table2.Rows.Add();
                            table2.Rows[table2.Rows.Count - 1].Cells[1].Range.Text = m.Name;
                            table2.Rows[table2.Rows.Count - 1].Cells[2].Range.Text = m.Class;
                            table2.Rows[table2.Rows.Count - 1].Cells[3].Range.Text = m.Place;
                            table2.Rows[table2.Rows.Count - 1].Cells[4].Range.Text = m.Date1;
                        }
                    }

                    doc.Variables.Add("mydate", date4);

                    doc.Fields.Update();

                    doc.SaveAs2($@"{PathHeader}{date4.Substring(0, 8)} 经管补充说明(进修).docx", FileFormat: Word.WdSaveFormat.wdFormatXMLDocument, LockComments: false, CompatibilityMode: 15);

                    //SaveAs以后,doc就成为了另存为的对象,因此需要关闭
                    doc.Close();

                    //然后重新打开模板文件
                    doc = wordApp.Documents.Open(workPath + templateFileName);

                    //
                    //查看打开的word文档
                    //
                    //foreach(Word.Document d in wordApp.Documents)
                    //{
                    //    WriteLine($"Word.Documents : {d.Name}");
                    //}
                }
            }
            catch (Exception e)
            {
                WriteLine(e.Message);
            }
            finally
            {
                doc.Close(Word.WdSaveOptions.wdDoNotSaveChanges);
                thisWorkBook.Close(false);
                wordApp.Quit(false);
                excelApp.Quit();
                doc          = null;
                thisWorkBook = null;
                GC.Collect();
            }
        }
コード例 #6
0
ファイル: Terser.cs プロジェクト: snosrap/nhapi
 private static int numStandardComponents(model.Type t)
 {
     int n = 0;
     if (typeof(Varies).IsAssignableFrom(t.GetType()))
     {
         n = numStandardComponents(((Varies) t).Data);
     }
     else if (typeof(Composite).IsAssignableFrom(t.GetType()))
     {
         n = ((Composite) t).Components.Length;
     }
     else
     {
         n = 1;
     }
     return n;
 }
コード例 #7
0
ファイル: Terser.cs プロジェクト: snosrap/nhapi
 /// <summary> Attempts to extract a Primitive from the given type. If it's a composite, 
 /// drills down through first components until a primitive is reached. 
 /// </summary>
 private static Primitive getPrimitive(model.Type type)
 {
     Primitive p = null;
     if (typeof(Varies).IsAssignableFrom(type.GetType()))
     {
         p = getPrimitive(((Varies) type).Data);
     }
     else if (typeof(Composite).IsAssignableFrom(type.GetType()))
     {
         try
         {
             p = getPrimitive(((Composite) type).getComponent(0));
         }
         catch (HL7Exception)
         {
             throw new System.ApplicationException("Internal error: HL7Exception thrown on Composite.getComponent(0).");
         }
     }
     else if (type is Primitive)
     {
         p = (Primitive) type;
     }
     return p;
 }
コード例 #8
0
ファイル: Terser.cs プロジェクト: snosrap/nhapi
        /// <summary> Returns the component (or sub-component, as the case may be) at the given
        /// index.  If it does not exist, it is added as an "extra component".  
        /// If comp > 1 is requested from a Varies with GenericPrimitive data, the 
        /// data is set to GenericComposite (this avoids the creation of a chain of 
        /// ExtraComponents on GenericPrimitives).  
        /// Components are numbered from 1.  
        /// </summary>
        private static ca.uhn.hl7v2.model.Type getComponent(model.Type type, int comp)
        {
            model.Type ret = null;
            if (typeof(Varies).IsAssignableFrom(type.GetType()))
            {
                Varies v = (Varies) type;

                try
                {
                    if (comp > 1 && typeof(GenericPrimitive).IsAssignableFrom(v.Data.GetType()))
                        v.Data = new GenericComposite(v.Message);
                }
                catch (DataTypeException de)
                {
                    //UPGRADE_TODO: The equivalent in .NET for method 'java.lang.Throwable.getMessage' may return a different value. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1043'"
                    System.String message = "Unexpected exception copying data to generic composite: " + de.Message;
                    log.error(message, de);
                    throw new System.ApplicationException(message);
                }

                ret = getComponent(v.Data, comp);
            }
            else
            {
                if (typeof(Primitive).IsAssignableFrom(type.GetType()) && comp == 1)
                {
                    ret = type;
                }
                else if (typeof(GenericComposite).IsAssignableFrom(type.GetType()) || (typeof(Composite).IsAssignableFrom(type.GetType()) && comp <= numStandardComponents(type)))
                {
                    //note that GenericComposite can return components > number of standard components

                    try
                    {
                        ret = ((Composite) type).getComponent(comp - 1);
                    }
                    catch (System.Exception e)
                    {
                        //TODO:  This may not be the write exception type:  Error() was originally thrown, but was not in project.
                        throw new ApplicationException("Internal error: HL7Exception thrown on getComponent(x) where x < # standard components.", e);
                    }
                }
                else
                {
                    ret = type.ExtraComponents.getComponent(comp - numStandardComponents(type) - 1);
                }
            }
            return ret;
        }
コード例 #9
0
ファイル: Terser.cs プロジェクト: snosrap/nhapi
 /// <summary> Returns the number of components in the given field, i.e. the
 /// number of standard components (e.g. 6 for CE) plus any extra components that
 /// have been added at runtime.  This may vary by repetition, as different reps
 /// may have different extra components.
 /// </summary>
 /*public static int numComponents(Type field) throws HL7Exception {
 return numComponents(seg.getField(field, rep));
 }*/
 /// <summary> Returns the number of sub-components in the specified component, i.e. 
 /// the number of standard sub-components (e.g. 6 for CE) plus any extra components that
 /// that have been added at runtime.
 /// </summary>
 /// <param name="component">numbered from 1 
 /// </param>
 public static int numSubComponents(model.Type type, int component)
 {
     int n = - 1;
     if (component == 1 && typeof(Primitive).IsAssignableFrom(type.GetType()))
     {
         //note that getComponent(primitive, 1) below returns the primitive
         //itself -- if we do numComponents on it, we'll end up with the
         //number of components in the field, not the number of subcomponents
         n = 1;
     }
     else
     {
         model.Type comp = getComponent(type, component);
         n = numComponents(comp);
     }
     return n;
     /*
     //Type t = seg.getField(field, rep);
     if (Varies.class.isAssignableFrom(type.getClass())) {
     return numSubComponents(((Varies) type).getData(), component);
     } else if (Primitive.class.isAssignableFrom(type.getClass()) && component == 1) {
     n = 1;
     } else if (Composite.class.isAssignableFrom(type.getClass()) && component <= numStandardComponents(t)) {
     n = numComponents(((Composite) type).getComponent(component - 1));
     } else { //we're being asked about subcomponents of an extra component
     n = numComponents(t.getExtraComponents().getComponent(component - numStandardComponents(t) - 1));
     }
     return n;
     */
 }
コード例 #10
0
ファイル: Terser.cs プロジェクト: snosrap/nhapi
 /// <summary> Returns the number of components in the given type, i.e. the
 /// number of standard components (e.g. 6 for CE) plus any extra components that
 /// have been added at runtime.  
 /// </summary>
 public static int numComponents(model.Type type)
 {
     if (typeof(Varies).IsAssignableFrom(type.GetType()))
     {
         return numComponents(((Varies) type).Data);
     }
     else
     {
         return numStandardComponents(type) + type.ExtraComponents.numComponents();
     }
 }