コード例 #1
0
 private void Fetch(Csla.Data.SafeDataReader data)
 {
     using (BypassPropertyChecks)
     {
         LineItemId = data.GetInt32("LineItemId");
         PersonId   = data.GetInt32("PersonId");
     }
 }
コード例 #2
0
ファイル: PrintSetting.cs プロジェクト: wg3281/JZFJ
 private void Child_Fetch(Csla.Data.SafeDataReader dataReader)
 {
     using (BypassPropertyChecks)
     {
         Id         = dataReader.GetString("Id");
         PrintLable = dataReader.GetString("PrintLable");
         PrintText  = dataReader.GetString("PrintText");
         X          = dataReader.GetInt32("x");
         Y          = dataReader.GetInt32("y");
         Font       = dataReader.GetString("Font");
         FontSize   = dataReader.GetFloat("FontSize");
     }
 }
コード例 #3
0
 private void Fetch(Csla.Data.SafeDataReader data)
 {
     Id   = data.GetInt32("Id");
     Name = string.Format("{0} {1}",
                          data.GetString("FirstName"),
                          data.GetString("LastName"));
 }
コード例 #4
0
ファイル: SafeDataReaderTests.cs プロジェクト: viethien/csla
        public void TestSafeDataReader()
        {
            List <string> list = new List <string>();

            SqlConnection cn = new SqlConnection(CONNECTION_STRING);

            cn.Open();

            using (SqlCommand cm = cn.CreateCommand())
            {
                cm.CommandText = "SELECT Name, Date, Age FROM Table1";

                using (Csla.Data.SafeDataReader dr = new Csla.Data.SafeDataReader(cm.ExecuteReader()))
                {
                    while (dr.Read()) //returns two results
                    {
                        string output = dr.GetString("Name") + ", age " + dr.GetInt32("Age") + ", added on " + dr.GetSmartDate("Date");
                        Assert.AreEqual("varchar", dr.GetDataTypeName("Name"));
                        Assert.AreEqual(false, dr.IsClosed);

                        list.Add(output);
                        Console.WriteLine(output);
                    }
                    dr.Close();
                    Assert.AreEqual(true, dr.IsClosed);
                }
                cn.Close();
            }

            Assert.AreEqual("Bill, age 56, added on 12/23/2004", list[0]);
            Assert.AreEqual("Jim, age 33, added on 1/14/2003", list[1]);
        }
コード例 #5
0
ファイル: TestTemplate.cs プロジェクト: tryCatchOrg/WWCRM
        private void Fetch(Csla.Data.SafeDataReader dr)
        {
            IdTest   = dr.GetInt32("");     //  inside "" is from sp column returned
            TestName = dr.GetString("");

            //Mark this data as persisted in the data store
            MarkOld();
        }
コード例 #6
0
 private void Fetch(Csla.Data.SafeDataReader data)
 {
     using (BypassPropertyChecks)
     {
         Id   = data.GetInt32("Id");
         Name = data.GetString("Name");
     }
 }
コード例 #7
0
 private void Fetch(Csla.Data.SafeDataReader data)
 {
     using (BypassPropertyChecks)
     {
         Id = data.GetInt32("Id");
         if (!data.IsDBNull("ShipDate"))
         {
             ShipDate = data.GetDateTime("ShipDate");
         }
         Persons = DataPortal.FetchChild <OrderLinePersons>(Id);
     }
 }
コード例 #8
0
        public void GetDataTypes()
        {
            // TODO: Connection strings were lost, and I don't know how to set them correctly
            SqlConnection cn = new SqlConnection(CONNECTION_STRING);
            SqlCommand    cm = cn.CreateCommand();

            cm.CommandText =
                "SELECT BITFIELD, CHARFIELD, DATETIMEFIELD, UNIQUEIDENTIFIERFIELD, SMALLINTFIELD, INTFIELD, BIGINTFIELD, TEXT FROM MultiDataTypes";
            bool bitfield;
            char charfield;

            Csla.SmartDate datetimefield;
            Guid           uniqueidentifierfield;

            System.Int16  smallintfield;
            System.Int32  intfield;
            System.Int64  bigintfield;
            System.String text;

            cn.Open();
            using (cm)
            {
                using (Csla.Data.SafeDataReader dr = new Csla.Data.SafeDataReader(cm.ExecuteReader()))
                {
                    dr.Read();
                    bitfield = dr.GetBoolean("BITFIELD");
                    //this causes an error in vb version (char array initialized to nothing in vb version
                    //and it's initialized with new Char[1] in c# version)
                    charfield             = dr.GetChar("CHARFIELD");
                    datetimefield         = dr.GetSmartDate("DATETIMEFIELD");
                    uniqueidentifierfield = dr.GetGuid("UNIQUEIDENTIFIERFIELD");
                    smallintfield         = dr.GetInt16("SMALLINTFIELD");
                    intfield    = dr.GetInt32("INTFIELD");
                    bigintfield = dr.GetInt64("BIGINTFIELD");
                    text        = dr.GetString("TEXT");
                    dr.Close();
                }
            }
            cn.Close();

            Assert.AreEqual(false, bitfield);
            Assert.AreEqual('z', charfield);
            Assert.AreEqual("12/13/2005", datetimefield.ToString());
            Assert.AreEqual("c0f92820-61b5-11da-8cd6-0800200c9a66", uniqueidentifierfield.ToString());
            Assert.AreEqual(32767, smallintfield);
            Assert.AreEqual(2147483647, intfield);
            Assert.AreEqual(92233720368547111, bigintfield);
            Assert.AreEqual("a bunch of text...a bunch of text...a bunch of text...a bunch of text...", text);
        }
コード例 #9
0
ファイル: PrintRow.cs プロジェクト: wg3281/JZFJ
        /// <summary>
        /// 根据行字体的大小动态获取每行的位置
        /// </summary>
        public static PrintRows GetPrintRows()
        {
            PrintRows printRows = new PrintRows();

            using (var cn = new MySqlConnection(AppUtility.AppUtil._LocalConnectionString))
            {
                cn.Open();
                using (var cm = cn.CreateCommand())
                {
                    StringBuilder SQL = new StringBuilder();
                    SQL.Append("SELECT c.y+1 row,SUM(c.maxfontsize) y ");
                    SQL.Append("FROM ( ");
                    SQL.Append("    (SELECT 0 y,0 maxfontsize ");
                    SQL.Append("    ) ");
                    SQL.Append("UNION ALL ");
                    SQL.Append("    (SELECT a.y,b.maxfontsize ");
                    SQL.Append("        FROM ");
                    SQL.Append("            (SELECT y,MAX(fontsize) maxfontsize ");
                    SQL.Append("                FROM t_printsetting ");
                    SQL.Append("                GROUP BY y ");
                    SQL.Append("                ORDER BY y ");
                    SQL.Append("            )a ");
                    SQL.Append("        JOIN ");
                    SQL.Append("            (SELECT y,MAX(fontsize) + 8 maxfontsize ");
                    SQL.Append("                FROM t_printsetting ");
                    SQL.Append("                GROUP BY y ");
                    SQL.Append("                ORDER BY y ");
                    SQL.Append("            )b ON a.y >= b.y "); //将小于当前行的每行高度关联出来
                    SQL.Append("    )) c ");
                    SQL.Append("GROUP BY c.y");                  //合计当前行以上的所有高度得到当前行的相对位置
                    cm.CommandText = SQL.ToString();
                    using (var dr = new Csla.Data.SafeDataReader(cm.ExecuteReader()))
                    {
                        while (dr.Read())
                        {
                            printRows.Add(dr.GetInt32("row"), dr.GetFloat("y"));
                        }
                    }
                }
            }
            return(printRows);
        }
コード例 #10
0
ファイル: CompaniesList.cs プロジェクト: RobRobertsCE/MVVM
 private void DataPortal_Fetch()
 {
     RaiseListChangedEvents = false;
     IsReadOnly             = false;
     using (SqlConnection connection = new SqlConnection(DataConnection.ConnectionString))
     {
         connection.Open();
         using (SqlCommand command = new SqlCommand("GetCompanies", connection))
         {
             command.CommandType = System.Data.CommandType.StoredProcedure;
             using (Csla.Data.SafeDataReader reader = new Csla.Data.SafeDataReader(command.ExecuteReader()))
             {
                 while (reader.Read())
                 {
                     Add(new NameValueListBase <int, string> .NameValuePair(reader.GetInt32("CompanyId"), reader.GetString("CompanyName")));
                 }
             }
         }
         connection.Close();
     }
     IsReadOnly             = true;
     RaiseListChangedEvents = true;
 }
コード例 #11
0
ファイル: SafeDataReaderTests.cs プロジェクト: BiYiTuan/csla
        public void TestSafeDataReader()
        {
            List<string> list = new List<string>();

            SqlConnection cn = new SqlConnection(CONNECTION_STRING);
            cn.Open();

            using (SqlCommand cm = cn.CreateCommand())
            {
                cm.CommandText = "SELECT Name, Date, Age FROM Table1";

                using (Csla.Data.SafeDataReader dr = new Csla.Data.SafeDataReader(cm.ExecuteReader()))
                {
                    while (dr.Read()) //returns two results
                    {
                        string output = dr.GetString("Name") + ", age " + dr.GetInt32("Age") + ", added on " + dr.GetSmartDate("Date");
                        Assert.AreEqual("varchar", dr.GetDataTypeName("Name"));
                        Assert.AreEqual(false, dr.IsClosed);

                        list.Add(output);
                        Console.WriteLine(output);
                    }
                    dr.Close();
                    Assert.AreEqual(true, dr.IsClosed);
                }
                cn.Close();
            }

            Assert.AreEqual("Bill, age 56, added on 12/23/2004", list[0]);
            Assert.AreEqual("Jim, age 33, added on 1/14/2003", list[1]);
        }
コード例 #12
0
ファイル: SafeDataReaderTests.cs プロジェクト: BiYiTuan/csla
        public void GetDataTypes()
        {
            SqlConnection cn = new SqlConnection(CONNECTION_STRING);
            SqlCommand cm = cn.CreateCommand();
            cm.CommandText = 
                "SELECT BITFIELD, CHARFIELD, DATETIMEFIELD, UNIQUEIDENTIFIERFIELD, SMALLINTFIELD, INTFIELD, BIGINTFIELD, TEXT FROM MultiDataTypes";
            bool bitfield;
            char charfield;
            Csla.SmartDate datetimefield;
            Guid uniqueidentifierfield;
            System.Int16 smallintfield;
            System.Int32 intfield;
            System.Int64 bigintfield;
            System.String text;

            cn.Open();
            using (cm)
            {
                using (Csla.Data.SafeDataReader dr = new Csla.Data.SafeDataReader(cm.ExecuteReader()))
                {
                    dr.Read();
                    bitfield = dr.GetBoolean("BITFIELD");
                    //this causes an error in vb version (char array initialized to nothing in vb version
                    //and it's initialized with new Char[1] in c# version)
                    charfield = dr.GetChar("CHARFIELD");
                    datetimefield = dr.GetSmartDate("DATETIMEFIELD");
                    uniqueidentifierfield = dr.GetGuid("UNIQUEIDENTIFIERFIELD");
                    smallintfield = dr.GetInt16("SMALLINTFIELD");
                    intfield = dr.GetInt32("INTFIELD");
                    bigintfield = dr.GetInt64("BIGINTFIELD");
                    text = dr.GetString("TEXT");
                    dr.Close();
                }
            }
            cn.Close();

            Assert.AreEqual(false, bitfield);
            Assert.AreEqual('z', charfield);
            Assert.AreEqual("12/13/2005", datetimefield.ToString());
            Assert.AreEqual("c0f92820-61b5-11da-8cd6-0800200c9a66", uniqueidentifierfield.ToString());
            Assert.AreEqual(32767, smallintfield);
            Assert.AreEqual(2147483647, intfield);
            Assert.AreEqual(92233720368547111, bigintfield);
            Assert.AreEqual("a bunch of text...a bunch of text...a bunch of text...a bunch of text...", text);
        }
コード例 #13
0
ファイル: SendBoxList.cs プロジェクト: wg3281/JZFJ
        public static void GetSendBoxList(List <string> indexList, ref List <BusinessLogic.Print.PrintInfo> PSInfos)
        {
            string indexs = "0";


            foreach (string s in indexList)
            {
                indexs += "," + s;
            }
            using (var cn = new MySqlConnection(AppUtility.AppUtil._LocalConnectionString))
            {
                cn.Open();
                using (var cm = cn.CreateCommand())
                {
                    StringBuilder SQL = new StringBuilder();
                    SQL.Append("SELECT * ");
                    SQL.Append("FROM (  SELECT   s.CUSTCODE,   s.shortname,   s.LINENAME,   cl.address,   b.*,   sumqty.totqty ");
                    SQL.Append("         ");
                    SQL.Append("        FROM   t_sorting_line_task s ");
                    SQL.Append("        JOIN t_box b ON s.CUSTCODE = b.CUSTOMERNO ");
                    SQL.Append("        JOIN ");
                    SQL.Append("            (SELECT s.ID,SUM(sd.QTY) totqty ");
                    SQL.Append("                FROM t_sorting_line_task s ");
                    SQL.Append("                JOIN t_sorting_line_detail_task sd ON s.ID = sd.TASKID ");
                    SQL.Append("                GROUP BY s.ID) sumqty              ON s.ID = sumqty.ID ");
                    SQL.Append("        JOIN t_client cl                           ON s.CUSTCODE = cl.CUSTOMERNO ");
                    SQL.Append("        ORDER BY   b.INDEXNO,   b.BOXSEQ ) a ");
                    SQL.Append("LEFT JOIN ");
                    SQL.Append("    ( SELECT  CUSTOMERNO,  SUM(BOXQTY) abnboxqty ");
                    SQL.Append("        FROM  t_box ");
                    SQL.Append("        WHERE  LINECODE = '1002' ");
                    SQL.Append("        GROUP BY  CUSTOMERNO ) abn ON a.CUSTCODE = abn.CUSTOMERNO ");
                    SQL.Append("JOIN ");
                    SQL.Append("    ( SELECT  @ROW :=@ROW + 1 boxindex,  a.* ");
                    SQL.Append("        FROM  (   SELECT    s.indexno,    b.boxseq ");
                    SQL.Append("                FROM    t_sorting_line_task s ");
                    SQL.Append("                JOIN t_box b                                                              ON s.CUSTCODE = b.CUSTOMERNO ");
                    SQL.Append("                ORDER BY    s.indexno,    b.boxseq  ) a,  (SELECT @ROW := 0) b ) boxindex ON a.indexno = boxindex.indexno AND a.boxseq = boxindex.boxseq ");
                    SQL.Append("JOIN ");
                    SQL.Append("    (SELECT COUNT(1) cucount ");
                    SQL.Append("        FROM t_sorting_line_task) cu ");
                    SQL.Append("WHERE a.indexno IN (" + indexs + ") ");
                    SQL.Append("ORDER BY a.INDEXNO, a.boxseq");



                    cm.CommandText = SQL.ToString();

                    using (var dr = new Csla.Data.SafeDataReader(cm.ExecuteReader()))
                    {
                        PrintInfo PSInfo;
                        while (dr.Read())
                        {
                            PSInfo = new PrintInfo();
                            PSInfo.CustomerName = dr.GetString("shortname");
                            PSInfo.CustomerCode = dr.GetString("CUSTCODE");
                            PSInfo.IndexNo      = dr.GetInt32("INDEXNO").ToString();
                            PSInfo.SortingDate  = "(" + dr.GetString("ORDERDATE") + ")";
                            PSInfo.BoxNo        = dr.GetInt32("BOXSEQ") + "/";
                            PSInfo.BoxCount     = dr.GetInt32("BOXCOUNT").ToString();
                            PSInfo.CurrentNum   = dr.GetInt32("BOXQTY") + "/" +
                                                  dr.GetInt32("TOTQTY");
                            //PSInfo.TaskNumber = sortingLineTask.SortingLineTaskDetails.GetTotQty().ToString();
                            PSInfo.DelivyLine  = dr.GetString("LINENAME");
                            PSInfo.CustomerSqe = "(" + PSInfo.IndexNo + "/" + dr.GetInt32("cucount") + ")户";
                            //PSInfo.CustomerTotSeq = outPort["MAXCOUNTLINE"];
                            PSInfo.AbnoBoxCount = "异" + dr.GetInt32("abnboxqty");
                            PSInfo.Address      = dr.GetString("address");
                            PSInfo.BoxIndex     = dr.GetInt32("BOXINDEX");
                            PSInfos.Add(PSInfo);
                        }
                    }
                }
            }
        }