public override global::System.Data.DataSet Clone()
        {
            OSMatWHCheckDetailByCart cln = ((OSMatWHCheckDetailByCart)(base.Clone()));

            cln.InitVars();
            cln.SchemaSerializationMode = this.SchemaSerializationMode;
            return(cln);
        }
        public static global::System.Xml.Schema.XmlSchemaComplexType GetTypedDataSetSchema(global::System.Xml.Schema.XmlSchemaSet xs)
        {
            OSMatWHCheckDetailByCart ds = new OSMatWHCheckDetailByCart();

            global::System.Xml.Schema.XmlSchemaComplexType type     = new global::System.Xml.Schema.XmlSchemaComplexType();
            global::System.Xml.Schema.XmlSchemaSequence    sequence = new global::System.Xml.Schema.XmlSchemaSequence();
            global::System.Xml.Schema.XmlSchemaAny         any      = new global::System.Xml.Schema.XmlSchemaAny();
            any.Namespace = ds.Namespace;
            sequence.Items.Add(any);
            type.Particle = sequence;
            global::System.Xml.Schema.XmlSchema dsSchema = ds.GetSchemaSerializable();
            if (xs.Contains(dsSchema.TargetNamespace))
            {
                global::System.IO.MemoryStream s1 = new global::System.IO.MemoryStream();
                global::System.IO.MemoryStream s2 = new global::System.IO.MemoryStream();
                try {
                    global::System.Xml.Schema.XmlSchema schema = null;
                    dsSchema.Write(s1);
                    for (global::System.Collections.IEnumerator schemas = xs.Schemas(dsSchema.TargetNamespace).GetEnumerator(); schemas.MoveNext();)
                    {
                        schema = ((global::System.Xml.Schema.XmlSchema)(schemas.Current));
                        s2.SetLength(0);
                        schema.Write(s2);
                        if ((s1.Length == s2.Length))
                        {
                            s1.Position = 0;
                            s2.Position = 0;
                            for (; ((s1.Position != s1.Length) &&
                                    (s1.ReadByte() == s2.ReadByte()));)
                            {
                                ;
                            }
                            if ((s1.Position == s1.Length))
                            {
                                return(type);
                            }
                        }
                    }
                }
                finally {
                    if ((s1 != null))
                    {
                        s1.Close();
                    }
                    if ((s2 != null))
                    {
                        s2.Close();
                    }
                }
            }
            xs.Add(dsSchema);
            return(type);
        }
Ejemplo n.º 3
0
        private void LoadData()
        {
            DataTable dtBySize = new OSMatWHCheckDetailBySize().Tables["OSMatWHCheckDetailBySizeTable"];
            DataTable dtByCart = new OSMatWHCheckDetailByCart().Tables["OSMatCheckDetailByCartTable"];

            txtPO.Text        = String.Format("PO      : {0}", orderInformation.ProductNo);
            txtArticleNo.Text = String.Format("Article : {0}", orderInformation.ArticleNo);
            txtShoeName.Text  = String.Format("Shoe Name: {0}", orderInformation.ShoeName);

            txtWorker.Text   = String.Format("Worker   : {0}", String.Join(", ", osMatCheckingList.Select(s => s.WorkerId).Distinct().ToList()));
            txtSupplier.Text = string.Format("Supplier : {0}", supplierClicked.Name);
            txtOSCode.Text   = string.Format("O/SCode: {0}", orderInformation.OutsoleCode);

            txtQty.Text    = String.Format("Quantity OK      : {0}", osMatCheckingList.Sum(s => s.Quantity));
            txtReject.Text = String.Format("Quantity Reject : {0}", osMatCheckingList.Sum(s => s.Reject));
            txtReturn.Text = String.Format("Quantity Return: {0}", osMatCheckingList.Sum(s => s.ReturnReject));

            var regex = new Regex(@"[a-z]|[A-Z]");

            stkMain.Children.Clear();
            // By Size
            if (reportBySize == true)
            {
                var dateCheckList = osMatCheckingList.Select(s => s.CheckingDate).Distinct().ToList();
                if (dateCheckList.Count() > 0)
                {
                    dateCheckList = dateCheckList.OrderBy(o => o).ToList();
                }
                foreach (var dateCheck in dateCheckList)
                {
                    var        osMatCheckByDate = osMatCheckingList.Where(w => w.CheckingDate == dateCheck).ToList();
                    var        sizeNoList       = osMatCheckByDate.Select(s => s.SizeNo).Distinct().ToList();
                    StackPanel stkDate          = new StackPanel();
                    stkDate.Orientation = Orientation.Horizontal;
                    stkDate.Margin      = new Thickness(0, 0, 0, 15);
                    foreach (var sizeNo in sizeNoList)
                    {
                        string sizeNoString = regex.IsMatch(sizeNo) == true?regex.Replace(sizeNo, "") : sizeNo;

                        double sizeNoDouble = 0;
                        double.TryParse(sizeNoString, out sizeNoDouble);

                        var osMatCheckBySize = osMatCheckByDate.Where(w => w.SizeNo == sizeNo).ToList();

                        DataRow dr = dtBySize.NewRow();
                        dr["Date"]         = String.Format("{0:dd/MM/yyyy}", dateCheck);
                        dr["SizeNo"]       = sizeNo;
                        dr["SizeNoDouble"] = sizeNoDouble;

                        List <String> displayDataList = new List <String>();
                        var           qtyCheckOKList  = osMatCheckBySize.Where(w => w.ErrorId == 0).ToList();
                        if (qtyCheckOKList.Count() > 0)
                        {
                            var cartList = qtyCheckOKList.Select(s => s.WorkingCard).Distinct().ToList();
                            if (cartList.Count() > 1)
                            {
                                displayDataList.Add(String.Format("Qty OK: {0}", qtyCheckOKList.Sum(s => s.Quantity)));
                            }
                            foreach (var cartNo in cartList)
                            {
                                var osMatCheckByCart = osMatCheckBySize.Where(w => w.WorkingCard == cartNo).Sum(s => s.Quantity);
                                displayDataList.Add(String.Format("Carton: Qty\n{0}: {1}", cartNo, osMatCheckByCart));
                            }
                        }

                        var rejectList = osMatCheckBySize.Where(w => w.ErrorId > 0).ToList();
                        var errorList  = rejectList.Select(s => s.ErrorId).Distinct().ToList();
                        if (errorList.Count() > 0)
                        {
                            if (errorList.Count() > 1)
                            {
                                displayDataList.Add(String.Format("\nReject: {0}", rejectList.Sum(s => s.Reject)));
                            }
                            foreach (var errorId in errorList)
                            {
                                var rejectByErrorList = rejectList.Where(w => w.ErrorId == errorId).ToList();
                                var errorName         = errorSourceList.FirstOrDefault(f => f.ErrorID == errorId).ErrorName;
                                displayDataList.Add(String.Format("{0}: {1}", errorName, rejectByErrorList.Sum(s => s.Reject)));
                            }
                        }

                        var returnList = osMatCheckBySize.Where(w => w.ErrorId == -1).ToList();
                        if (returnList.Count() > 0)
                        {
                            displayDataList.Add(String.Format("Return: {0}", returnList.Sum(s => s.ReturnReject)));
                        }

                        dr["DisplayValue"] = String.Join(String.Format("{0}", displayDataList.Count() > 1 ? "\n" : ""), displayDataList);
                        dtBySize.Rows.Add(dr);

                        GroupBox grbSize  = new GroupBox();
                        var      template = FindResource("GroupBoxTemplate") as ControlTemplate;
                        grbSize.Template = template;
                        grbSize.Margin   = new Thickness(0, 0, 10, 0);
                        var brTitle = new Border();
                        brTitle.Background = Brushes.Orange;
                        brTitle.Padding    = new Thickness(10, 2, 10, 2);
                        var tblSize = new TextBlock();
                        tblSize.Text   = String.Format("Size: {0}", sizeNo);
                        brTitle.Child  = tblSize;
                        grbSize.Header = brTitle;

                        var stkContent = new StackPanel();
                        stkContent.Orientation = Orientation.Vertical;
                        var tblContent = new TextBlock();
                        tblContent.Text = String.Join("\n", displayDataList);

                        var tblDate = new TextBlock();
                        tblDate.Foreground = Brushes.OrangeRed;
                        tblDate.Text       = String.Format("Date: {0:MM/dd/yyyy}", dateCheck);

                        stkContent.Children.Add(tblContent);
                        stkContent.Children.Add(tblDate);

                        grbSize.Content = stkContent;

                        stkDate.Children.Add(grbSize);
                    }

                    stkMain.Children.Add(stkDate);
                }

                ReportDataSource rdsBySize = new ReportDataSource();
                rdsBySize.Name  = "OSMatWHCheckDetailBySizeDetail";
                rdsBySize.Value = dtBySize;

                reportViewer.LocalReport.ReportPath = @"Reports\OSMatWHCheckDetailBySizeReport.rdlc";
                reportViewer.LocalReport.DataSources.Clear();
                reportViewer.LocalReport.DataSources.Add(rdsBySize);
                reportViewer.RefreshReport();
            }

            // By Cart
            else
            {
                var dateCheckList = osMatCheckingList.Select(s => s.CheckingDate).Distinct().ToList();
                if (dateCheckList.Count() > 0)
                {
                    dateCheckList = dateCheckList.OrderBy(o => o).ToList();
                }
                foreach (var dateCheck in dateCheckList)
                {
                    var        osMatCheckByDate = osMatCheckingList.Where(w => w.CheckingDate == dateCheck).ToList();
                    var        cartList         = osMatCheckByDate.Where(w => w.WorkingCard > 0).Select(s => s.WorkingCard).Distinct().ToList();
                    StackPanel stkDate          = new StackPanel();
                    stkDate.Orientation = Orientation.Horizontal;
                    stkDate.Margin      = new Thickness(0, 0, 0, 15);
                    if (cartList.Count() > 0)
                    {
                        cartList = cartList.OrderBy(o => o).ToList();
                    }
                    foreach (var cartNo in cartList)
                    {
                        DataRow dr = dtByCart.NewRow();
                        dr["Date"] = String.Format("{0:dd/MM/yyyy}", dateCheck);
                        dr["Cart"] = cartNo;

                        var           osMatByCart     = osMatCheckByDate.Where(w => w.WorkingCard == cartNo).ToList();
                        var           sizeNoList      = osMatByCart.Select(s => s.SizeNo).Distinct().ToList();
                        List <String> displayDataList = new List <String>();
                        if (sizeNoList.Count() > 1)
                        {
                            displayDataList.Add(String.Format("Total: {0}\n", osMatByCart.Sum(s => s.Quantity)));
                        }
                        displayDataList.Add("SizeNo: Qty");
                        foreach (var sizeNo in sizeNoList)
                        {
                            var osMatBySize = osMatByCart.Where(w => w.SizeNo == sizeNo).ToList();
                            displayDataList.Add(String.Format("{0}#: {1}", sizeNo, osMatBySize.Sum(s => s.Quantity)));
                        }

                        dr["DisplayValue"] = String.Join("\n", displayDataList);
                        dtByCart.Rows.Add(dr);

                        GroupBox grbCarton = new GroupBox();
                        var      template  = FindResource("GroupBoxTemplate") as ControlTemplate;
                        grbCarton.Template = template;
                        grbCarton.Margin   = new Thickness(0, 0, 10, 0);
                        var brTitle = new Border();
                        brTitle.Background = Brushes.DeepSkyBlue;
                        brTitle.Padding    = new Thickness(10, 2, 10, 2);
                        var tblCartonNo = new TextBlock();
                        tblCartonNo.Text = String.Format("Carton: {0}", cartNo);
                        brTitle.Child    = tblCartonNo;
                        grbCarton.Header = brTitle;

                        var stkContent = new StackPanel();
                        stkContent.Orientation = Orientation.Vertical;
                        var tblContent = new TextBlock();
                        tblContent.Text = String.Join("\n", displayDataList);

                        var tblDate = new TextBlock();
                        tblDate.Foreground = Brushes.OrangeRed;
                        tblDate.Text       = String.Format("Date: {0:MM/dd/yyyy}", dateCheck);

                        stkContent.Children.Add(tblContent);
                        stkContent.Children.Add(tblDate);

                        grbCarton.Content = stkContent;

                        stkDate.Children.Add(grbCarton);
                    }

                    stkMain.Children.Add(stkDate);

                    ReportDataSource rdsByCart = new ReportDataSource();
                    rdsByCart.Name  = "OSMatWHCheckByCartDetail";
                    rdsByCart.Value = dtByCart;

                    reportViewer.LocalReport.ReportPath = @"Reports\OSMatWHCheckDetailByCartReport.rdlc";
                    reportViewer.LocalReport.DataSources.Clear();
                    reportViewer.LocalReport.DataSources.Add(rdsByCart);
                    reportViewer.RefreshReport();
                }
            }
        }
            public static global::System.Xml.Schema.XmlSchemaComplexType GetTypedTableSchema(global::System.Xml.Schema.XmlSchemaSet xs)
            {
                global::System.Xml.Schema.XmlSchemaComplexType type     = new global::System.Xml.Schema.XmlSchemaComplexType();
                global::System.Xml.Schema.XmlSchemaSequence    sequence = new global::System.Xml.Schema.XmlSchemaSequence();
                OSMatWHCheckDetailByCart ds = new OSMatWHCheckDetailByCart();

                global::System.Xml.Schema.XmlSchemaAny any1 = new global::System.Xml.Schema.XmlSchemaAny();
                any1.Namespace       = "http://www.w3.org/2001/XMLSchema";
                any1.MinOccurs       = new decimal(0);
                any1.MaxOccurs       = decimal.MaxValue;
                any1.ProcessContents = global::System.Xml.Schema.XmlSchemaContentProcessing.Lax;
                sequence.Items.Add(any1);
                global::System.Xml.Schema.XmlSchemaAny any2 = new global::System.Xml.Schema.XmlSchemaAny();
                any2.Namespace       = "urn:schemas-microsoft-com:xml-diffgram-v1";
                any2.MinOccurs       = new decimal(1);
                any2.ProcessContents = global::System.Xml.Schema.XmlSchemaContentProcessing.Lax;
                sequence.Items.Add(any2);
                global::System.Xml.Schema.XmlSchemaAttribute attribute1 = new global::System.Xml.Schema.XmlSchemaAttribute();
                attribute1.Name       = "namespace";
                attribute1.FixedValue = ds.Namespace;
                type.Attributes.Add(attribute1);
                global::System.Xml.Schema.XmlSchemaAttribute attribute2 = new global::System.Xml.Schema.XmlSchemaAttribute();
                attribute2.Name       = "tableTypeName";
                attribute2.FixedValue = "OSMatCheckDetailByCartTableDataTable";
                type.Attributes.Add(attribute2);
                type.Particle = sequence;
                global::System.Xml.Schema.XmlSchema dsSchema = ds.GetSchemaSerializable();
                if (xs.Contains(dsSchema.TargetNamespace))
                {
                    global::System.IO.MemoryStream s1 = new global::System.IO.MemoryStream();
                    global::System.IO.MemoryStream s2 = new global::System.IO.MemoryStream();
                    try {
                        global::System.Xml.Schema.XmlSchema schema = null;
                        dsSchema.Write(s1);
                        for (global::System.Collections.IEnumerator schemas = xs.Schemas(dsSchema.TargetNamespace).GetEnumerator(); schemas.MoveNext();)
                        {
                            schema = ((global::System.Xml.Schema.XmlSchema)(schemas.Current));
                            s2.SetLength(0);
                            schema.Write(s2);
                            if ((s1.Length == s2.Length))
                            {
                                s1.Position = 0;
                                s2.Position = 0;
                                for (; ((s1.Position != s1.Length) &&
                                        (s1.ReadByte() == s2.ReadByte()));)
                                {
                                    ;
                                }
                                if ((s1.Position == s1.Length))
                                {
                                    return(type);
                                }
                            }
                        }
                    }
                    finally {
                        if ((s1 != null))
                        {
                            s1.Close();
                        }
                        if ((s2 != null))
                        {
                            s2.Close();
                        }
                    }
                }
                xs.Add(dsSchema);
                return(type);
            }