private void InsertBom()
        {
            SqlTransaction trans = AppRes.DB.BeginTrans();

            try
            {
                bomSet.RegTime = bomRec.RegTime;
                bomSet.AreaNo  = bomRec.AreaNo;
                bomSet.FName   = bomRec.FName;
                bomSet.FPath   = bomRec.FPath;
                bomSet.Insert(trans);

                foreach (ProductColumns productRec in bomRec.Products)
                {
                    productSet.BomNo = bomSet.RecNo;
                    productSet.Code  = productRec.Code;
                    productSet.Name  = productRec.Name;
                    productSet.Image = productRec.Image;
                    productSet.Insert(trans);

                    foreach (PartColumns partRec in productRec.Parts)
                    {
                        partSet.ProductNo    = productSet.RecNo;
                        partSet.Name         = partRec.Name;
                        partSet.MaterialNo   = partRec.MaterialNo;
                        partSet.MaterialName = partRec.MaterialName;
                        partSet.Insert(trans);
                    }
                }

                AppRes.DB.CommitTrans();
            }
            catch (Exception e)
            {
                AppRes.DbLog[ELogTag.Exception] = e.ToString();
                AppRes.DB.RollbackTrans();
            }
        }
Exemplo n.º 2
0
        private bool InsertPart(PartColumns col, SqlTransaction trans)
        {
            string jobNo       = "";
            string extendJobNo = "";

            cheQuery.ProfJobSet.Type       = EReportType.Chemical;
            cheQuery.ProfJobSet.JobNo      = "";
            cheQuery.ProfJobSet.AreaNo     = bomSet.AreaNo;
            cheQuery.ProfJobSet.ItemNo     = col.MaterialNo;
            cheQuery.ProfJobSet.ExtendASTM = true;
            cheQuery.ProfJobSet.Select(trans);

            int rowCount = cheQuery.ProfJobSet.RowCount;

            if (rowCount > 0)
            {
                cheQuery.ProfJobSet.Fetch(0);
                jobNo = cheQuery.ProfJobSet.JobNo;

                if (string.IsNullOrWhiteSpace(jobNo) == false)
                {
                    cheMainSet.RecNo          = jobNo;
                    cheMainSet.ReportApproval = EReportApproval.None;
                    cheMainSet.AreaNo         = EReportArea.None;
                    cheMainSet.From           = "";
                    cheMainSet.To             = "";
                    cheMainSet.MaterialNo     = "";
                    cheMainSet.Select(trans);

                    if (cheMainSet.Empty == true)
                    {
                        if (rowCount > 1)
                        {
                            // Find jobno for additional test results
                            for (int i = 1; i < cheQuery.ProfJobSet.RowCount; i++)
                            {
                                cheQuery.ProfJobSet.Fetch(i);

                                if (cheQuery.ProfJobSet.Image == null)
                                {
                                    extendJobNo = cheQuery.ProfJobSet.JobNo;
                                    break;
                                }
                            }

                            cheQuery.ProfJobSet.Fetch(0);
                        }

                        cheQuery.Insert(extendJobNo, trans);
                    }
                }
            }

            partSet.ProductNo    = productSet.RecNo;
            partSet.JobNo        = jobNo;
            partSet.MaterialNo   = col.MaterialNo;
            partSet.Name         = col.Name;
            partSet.MaterialName = col.MaterialName;
            partSet.Insert(trans);

            return((string.IsNullOrWhiteSpace(jobNo) == false) ? true : false);
        }