Ejemplo n.º 1
0
 private void Fetch(Csla.Data.SafeDataReader data)
 {
     Id   = data.GetInt32("Id");
     Name = string.Format("{0} {1}",
                          data.GetString("FirstName"),
                          data.GetString("LastName"));
 }
Ejemplo n.º 2
0
        public static TaskBatchList GetTaskBatchs(string orderdate, bool isaddnull)
        {
            TaskBatchList taskBatchList = new TaskBatchList();

            if (isaddnull)
            {
                taskBatchList.Add(new TaskBatch());
            }
            using (var cn = new MySqlConnection(AppUtility.AppUtil._LocalConnectionString))
            {
                cn.Open();
                using (var cm = cn.CreateCommand())
                {
                    cm.CommandText = "SELECT DISTINCT(sortingtaskno) FROM t_sorting_line_task_history tsp WHERE  tsp.orderDate = '" + orderdate + "'";

                    using (var dr = new Csla.Data.SafeDataReader(cm.ExecuteReader()))
                    {
                        while (dr.Read())
                        {
                            TaskBatch taskBatch = new TaskBatch();
                            taskBatch.ID   = dr.GetString("sortingtaskno");
                            taskBatch.Name = dr.GetString("sortingtaskno");
                            taskBatchList.Add(taskBatch);
                        }
                    }
                }
            }
            return(taskBatchList);
        }
Ejemplo n.º 3
0
        public static SortingLineList GetSortingLines(bool isaddnull)
        {
            SortingLineList sortingLineList = new SortingLineList();

            if (isaddnull)
            {
                sortingLineList.Add(new SortingLine());
            }
            using (var cn = new DB2Connection(AppUtility.AppUtil._FjInfoConnectionString))
            {
                cn.Open();
                using (var cm = cn.CreateCommand())
                {
                    cm.CommandText = "select * from T_SORTINGLINE order by Linecode";

                    using (var dr = new Csla.Data.SafeDataReader(cm.ExecuteReader()))
                    {
                        while (dr.Read())
                        {
                            SortingLine sortingLine = new SortingLine();
                            sortingLine.ID   = dr.GetString("LineCode");
                            sortingLine.Name = dr.GetString("LineName");
                            sortingLine.Type = dr.GetString("LineType");
                            sortingLineList.Add(sortingLine);
                        }
                    }
                }
            }
            return(sortingLineList);
        }
Ejemplo n.º 4
0
        public static TaskInfoList GetServerTaskBatchs(string orderdate, bool isaddnull)
        {
            TaskInfoList taskBatchList = new TaskInfoList();

            if (isaddnull)
            {
                taskBatchList.Add(new TaskInfo());
            }
            using (var cn = new DB2Connection(AppUtility.AppUtil._FjInfoConnectionString))
            {
                cn.Open();
                using (var cm = cn.CreateCommand())
                {
                    cm.CommandText = "select * from tsp_plan tsp join t_sortingline s on tsp.sortinglines = s.id WHERE  tsp.orderDate = '" + orderdate + "'";

                    using (var dr = new Csla.Data.SafeDataReader(cm.ExecuteReader()))
                    {
                        while (dr.Read())
                        {
                            TaskInfo taskInfo = new TaskInfo();
                            taskInfo.TaskNo   = dr.GetString("taskno");
                            taskInfo.LineName = dr.GetString("linename");
                            taskInfo.LineCode = dr.GetString("linecode");
                            taskInfo.LineType = dr.GetString("linetype");
                            taskBatchList.Add(taskInfo);
                        }
                    }
                }
            }
            return(taskBatchList);
        }
Ejemplo n.º 5
0
 private void Child_Fetch(Csla.Data.SafeDataReader dataReader)
 {
     using (BypassPropertyChecks)
     {
         Id          = dataReader.GetString("ID");
         Name        = dataReader.GetString("Name");
         Value       = dataReader.GetString("Value");
         Description = dataReader.GetString("Description");
     }
 }
Ejemplo n.º 6
0
        private void Fetch(Csla.Data.SafeDataReader dr)
        {
            //IdTest = dr.GetInt32("");       //  inside "" is from sp column returned
            Username    = dr.GetString("Username");
            Password    = dr.GetString("Password");
            Fullname    = dr.GetString("Fullname");
            GroupRights = dr.GetString("GroupRights");

            //Mark this data as persisted in the data store
            MarkOld();

            UserProfile.SetProperties(Username, Password, Fullname, GroupRights);
        }
Ejemplo n.º 7
0
 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");
     }
 }
Ejemplo n.º 8
0
        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]);
        }
Ejemplo n.º 9
0
        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();
        }
Ejemplo n.º 10
0
 private void Fetch(Csla.Data.SafeDataReader data)
 {
     using (BypassPropertyChecks)
     {
         Id   = data.GetInt32("Id");
         Name = data.GetString("Name");
     }
 }
Ejemplo n.º 11
0
        private void Fetch(Csla.Data.SafeDataReader dr)
        {
            //IdTest = dr.GetInt32("");       //  inside "" is from sp column returned
            Fullname = dr.GetString("Fullname");

            //Mark this data as persisted in the data store
            MarkOld();

            UserProfile.SetProperties("", "", Fullname, "");
        }
Ejemplo n.º 12
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);
        }
Ejemplo n.º 13
0
        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]);
        }
Ejemplo n.º 14
0
        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);
        }
Ejemplo n.º 15
0
        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);
                        }
                    }
                }
            }
        }
Ejemplo n.º 16
0
 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;
 }