コード例 #1
0
ファイル: InspectForm.cs プロジェクト: amon0424/SWLHMS
        void SearchList()
        {
            string line = null;
            string name = null;

            DateTime from = DateTime.MinValue;
            DateTime to   = DateTime.MaxValue;

            _table = DatabaseSet.GetInspectList(line, name, from, to);
            _table.Columns.Add("NG處理", typeof(string));

            string sort = bindingSource.Sort;

            bindingSource.Sort = null;

            bindingSource.DataSource = null;
            this.GroupTable          = null;
            if (this.InspectMode == InspeceMode.ByPn)
            {
                bindingSource.DataSource = this.GroupTable;
            }
            else
            {
                bindingSource.DataSource = _table;
            }
            bindingSource.Sort = sort;

            btnSend.Enabled = _table.Rows.Count > 0;
            dgv.EditMode    = DataGridViewEditMode.EditOnEnter;
        }
コード例 #2
0
ファイル: ReportDataSet.cs プロジェクト: amon0424/SWLHMS
            public static InspectListReportDataTable GetHistoryData(string lastID)
            {
                OleDbConnection conn = new OleDbConnection(Properties.Settings.Default.dbConnectionString);
                OleDbCommand    cmd  = new OleDbCommand();

                cmd.Connection = conn;

                string cmdText = "SELECT Q.日期 as 檢驗日期, 產線, P.品號, QCN, 待驗數量 as 檢驗數量, W.單號 as 工作單號,送檢次數, IIF(檢驗結果,'OK',IIF(特許,'Concession','NG')) as 檢驗狀態, 客戶 as 客戶名稱, 工時資料編號" +
                                 " FROM ((((工時 as H INNER JOIN 產品檢驗 as Q on H.編號 = Q.工時資料編號)" +
                                 " INNER JOIN 工作單 as W ON H.工作單號 = W.單號)" +
                                 " INNER JOIN 工作單品號 as WP ON H.工作單號 = WP.單號 AND H.工品編號 = WP.編號)" +
                                 " INNER JOIN 產品品號 as P ON WP.品號 = P.品號)" +
                                 " WHERE 重驗=True AND 最後送檢編號=?" +
                                 " ORDER BY 單據日期, W.單號, P.品號, WP.編號, 送檢次數";

                cmd.CommandText = cmdText;
                cmd.Parameters.Add(new OleDbParameter("最後送檢編號", lastID));

                OleDbDataAdapter adapter = new OleDbDataAdapter(cmd);

                InspectListReportDataTable table = new InspectListReportDataTable();

                adapter.Fill(table);

                //取得品質履歷
                foreach (DataRow row in table)
                {
                    //取得舊NG原因
                    string   id        = row["工時資料編號"].ToString();
                    string[] ngReasons = DatabaseSet.GetNGReason(id);
                    row["品質履歷"] = string.Join("\n", ngReasons);
                }

                return(table);
            }
コード例 #3
0
 public virtual void Edit(TEntity entityToEdit)
 {
     if (Context.Entry(entityToEdit).State == EntityState.Detached)
     {
         DatabaseSet.Attach(entityToEdit);
     }
     Context.Entry(entityToEdit).State = EntityState.Modified;
 }
コード例 #4
0
        public virtual void Delete(TEntity entityToDelete)
        {
            if (Context.Entry(entityToDelete).State == EntityState.Detached)
            {
                DatabaseSet.Attach(entityToDelete);
            }

            DatabaseSet.Remove(entityToDelete);
        }
コード例 #5
0
        void LoadNGData()
        {
            string labor = this.SelectedLaborNumber;

            if (labor != null)
            {
                this.NGTable = DatabaseSet.GetNGData(labor);
            }
        }
コード例 #6
0
        private void btnSend_Click(object sender, EventArgs e)
        {
            DatabaseSet.待驗清單DataTable table = (DatabaseSet.待驗清單DataTable)bindingSource.DataSource;

            if (MessageBox.Show("資料經送出後不可再修改,請確認後繼續", "送出確認", MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation) == DialogResult.OK)
            {
                int delete;
                int update = DatabaseSet.UpdateInspectDeleteList(table, out delete);

                MessageBox.Show("更新了 " + update + " 筆檢驗資料\n共刪除 " + delete + " 筆檢驗資料");
                SearchList();
            }
        }
コード例 #7
0
        void UpdateFinishDate()
        {
            foreach (DataRow row in _dataTable)
            {
                string worksheet;
                int    wpid;

                worksheet = (row.RowState == DataRowState.Deleted ?  row["工作單號", DataRowVersion.Original] : row["工作單號"]) as string;

                if (!string.IsNullOrEmpty(worksheet))
                {
                    wpid = (int)(row.RowState == DataRowState.Deleted ? row["工品編號", DataRowVersion.Original] : row["工品編號"]);
                    DatabaseSet.UpdateWorksheetItemFinishDate(worksheet, wpid, true);
                }
            }
        }
コード例 #8
0
        /// <summary>
        /// Initializes the box picking module if one is configured.
        /// </summary>
        /// <param name="dbSet">The set of active Mosaic databases.</param>
        /// <returns><c>true</c> if initialization was successful;<c>false</c> otherwise.</returns>
        private bool InitializeBoxSystem(DatabaseSet dbSet)
        {
            this.Trace("Initializing box system module...");

            try
            {
                List <Component> componentList = dbSet.Productive.Query <Component>(new CommandFilter("Type", ComponentType.BoxSystem.ToString()));

                foreach (Component component in componentList)
                {
                    if (component.IsActive == false)
                    {
                        continue;
                    }

                    this.Info("Initializing box system module '{0}' with ID '{1}'.", component.Description, component.ID);
                    _boxSystem = ComponentLoader.LoadInterface <IBoxSystem>(component.Assembly, component.ClassName);

                    if (_boxSystem == null)
                    {
                        this.Fatal("Box system module '{0}' with ID '{1}' in assembly '{2}' and class '{3}' could not be found.",
                                   component.Description, component.ID, component.Assembly, component.ClassName);
                        return(false);
                    }

                    if (_boxSystem.Initialize(component.ID,
                                              dbSet.Productive.Query <ConfigurationValue>(new CommandFilter("ComponentID", component.ID)),
                                              _packConveyorManager.PackConveyors,
                                              _captureHost) == false)
                    {
                        this.Error("Initializing box system module '{0}' with ID '{1}' failed.", component.Description, component.ID);
                        return(false);
                    }

                    break;
                }

                return(true);
            }
            catch (Exception ex)
            {
                this.Error("Initializing box system module failed.", ex);
            }

            return(false);
        }
コード例 #9
0
        void StoreWorksheet()
        {
            try
            {
                CheckField();

                // Check the finish date
                //bool allFinished = true;
                //DateTime maxDate = DateTime.MinValue;
                //foreach (DatabaseSet.工作單品號Row row in _worksheetPartTable)
                //{
                //    if (row.RowState == DataRowState.Deleted)
                //        continue;

                //    if (row["實際完成日"] == DBNull.Value)
                //    {
                //        allFinished = false;
                //        break;
                //    }
                //    DateTime date = row.實際完成日;
                //    if (date > maxDate)
                //        maxDate = date;
                //}

                //if (allFinished && maxDate != DateTime.MinValue)
                //    _worksheetTable[0].實際完成日 = maxDate;
                //else
                //    _worksheetTable[0]["實際完成日"] = DBNull.Value;

                // Begin update
                int count     = 工作單TableAdapter.Instance.Update(_worksheetTable);
                int partCount = 工作單品號TableAdapter.Instance.UpdateEx(_worksheetPartTable);

                //進行數量檢查
                DatabaseSet.UpdateWorksheetFinishStatus(((DatabaseSet.工作單Row)bsWorksheet.DataSource).單號);

                MessageBox.Show("更新 " + count + " 筆工作單資料\n更新 " + partCount + " 筆品號");
            }
            catch (Exception ex)
            {
                Global.ShowError(ex);
            }
        }
コード例 #10
0
        // https://www.learnentityframeworkcore.com/dbset/querying-data
        public override async Task <User> GetSingleAsync(Expression <Func <User, bool> > predicate, bool disableTracking = true, CancellationToken cancellationToken = default(CancellationToken))
        {
            User user = null;

            try
            {
                user = await DatabaseSet
                       .Include(cmp => cmp.Employee).ThenInclude(emp => emp.EmployeeAddress)
                       .Include(cmp => cmp.Employee).ThenInclude(emp => emp.Department)
                       .AsNoTracking()
                       .SingleOrDefaultAsync(predicate, cancellationToken);

                return(user);
            }
            catch (Exception)
            {
                return(user);
            }
        }
コード例 #11
0
        // https://www.learnentityframeworkcore.com/dbset/querying-data
        public override async Task <Company> GetSingleAsync(Expression <Func <Company, bool> > predicate, bool disableTracking = true, CancellationToken cancellationToken = default(CancellationToken))
        {
            Company company = null;

            try
            {
                company = await DatabaseSet
                          .Include(cmp => cmp.Employees).ThenInclude(emp => emp.EmployeeAddress)
                          .Include(cmp => cmp.Employees).ThenInclude(emp => emp.Department)
                          .Include(cmp => cmp.Employees).ThenInclude(emp => emp.User)
                          .AsNoTracking()
                          .SingleOrDefaultAsync(predicate, cancellationToken).ConfigureAwait(false);

                return(company);
            }
            catch (Exception)
            {
                return(company);
            }
        }
コード例 #12
0
ファイル: InspectForm.cs プロジェクト: amon0424/SWLHMS
        void SearchUnreinspectList()
        {
            string line = null;
            string name = null;

            _table = DatabaseSet.GetUnreinspectList(line, name);
            _table.Columns.Add("NG處理", typeof(string));

            string sort = bindingSource.Sort;

            bindingSource.Sort = null;

            this.GroupTable          = null;
            this.InspectMode         = InspeceMode.OnlyUnre;
            bindingSource.DataSource = _table;
            bindingSource.Sort       = sort;

            btnSend.Enabled = false;
            dgv.EditMode    = DataGridViewEditMode.EditProgrammatically;
        }
コード例 #13
0
        void SearchList()
        {
            string qcn        = txtQCN.Text.Trim();
            string partnubmer = txtPartNumber.Text.Trim();

            DateTime date = DateTime.MinValue;

            if (ckbDate.Checked)
            {
                date = dtpDate.Value;
            }

            DatabaseSet.待驗清單DataTable table = DatabaseSet.GetInspectCompleteList(qcn, partnubmer, date);
            table.Columns.Add("刪除", typeof(bool));
            bindingSource.DataSource = table;
            btnSend.Enabled          = table.Rows.Count > 0;

            dgv.AutoResizeColumns();
            dgv.Columns[0].Width = 40;
            dgv.Columns[1].Width = 50;
        }
コード例 #14
0
        /// <summary>
        /// Deletes all outdated legacy plc connection configurations.
        /// </summary>
        /// <param name="dbSet">The database set to use.</param>
        private void DeletePlcConnections(DatabaseSet dbSet)
        {
            this.Trace("Deleting outdated legacy plc connections...");

            try
            {
                var plcConnections = dbSet.Productive.Query <Component>(new CommandFilter("Type", "PlcConnection"));

                foreach (Component plcConnection in plcConnections)
                {
                    this.Info("Deleting outdated legacy plc connection '{0}'...", plcConnection.Description);

                    dbSet.Productive.Delete <ConfigurationValue>(new CommandFilter("ComponentID", plcConnection.ID));
                    dbSet.Productive.Delete(plcConnection);
                }
            }
            catch (Exception ex)
            {
                this.Error("Deleting outdated legacy plc connections failed.", ex);
            }
        }
コード例 #15
0
        public override async Task <Employee> GetSingleAsync(Expression <Func <Employee, bool> > predicate, bool disableTracking = true, CancellationToken cancellationToken = default(CancellationToken))
        {
            Employee employee = null;

            try
            {
                // https://www.learnentityframeworkcore.com/dbset/querying-data
                employee = await DatabaseSet
                           .Include(emp => emp.Company)
                           .Include(emp => emp.Department)
                           .Include(emp => emp.EmployeeAddress)
                           .Include(emp => emp.User)
                           .AsNoTracking()
                           .SingleOrDefaultAsync(predicate, cancellationToken).ConfigureAwait(false);

                return(employee);
            }
            catch (Exception)
            {
                return(employee);
            }
        }
コード例 #16
0
        private void btnDelHourData_Click(object sender, EventArgs e)
        {
            try
            {
                if (bsHourData.DataSource != null && dgvHourData.CurrentRow != null)
                {
                    DatabaseSet.工時Row row = (dgvHourData.CurrentRow.DataBoundItem as DataRowView).Row as DatabaseSet.工時Row;
                    int count             = 0;
                    if (MessageBox.Show("確定刪除" + row.編號 + "此筆資料?", "刪除提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == DialogResult.OK)
                    {
                        if (row["工作單號"] != DBNull.Value)
                        {
                            string worksheet = row.工作單號;
                            int    wpid      = row.工品編號;

                            /*
                             * row.Delete();
                             * int count = 工時TableAdapter.Instance.Update(row);
                             */

                            count = 工時TableAdapter.Instance.DeleteEx(row.編號);

                            DatabaseSet.UpdateWorksheetItemFinishDate(worksheet, wpid, true);
                        }
                        else
                        {
                            count = 工時TableAdapter.Instance.DeleteEx(row.編號);
                        }
                        MessageBox.Show("刪除了 " + count + " 筆資料");
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
コード例 #17
0
 public static global::System.Xml.Schema.XmlSchemaComplexType GetTypedDataSetSchema(global::System.Xml.Schema.XmlSchemaSet xs) {
     DatabaseSet ds = new DatabaseSet();
     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;
 }
コード例 #18
0
        /// <summary>
        /// Initializes the task scheduler with all configured scheduler tasks.
        /// </summary>
        /// <param name="dbSet">The set of active Mosaic databases.</param>
        /// <returns><c>true</c> if initialization was successful;<c>false</c> otherwise.</returns>
        public bool Initialize(DatabaseSet dbSet)
        {
            if (dbSet == null)
            {
                throw new ArgumentException("Invalid dbSet specified.");
            }

            this.Trace("Initializing task scheduler...");

            _taskConverterStreams.Clear();
            _taskConverterStreamConfig.Clear();

            try
            {
                List<Component> componentList = dbSet.Productive.Query<Component>(new CommandFilter("Type", ComponentType.SchedulerTask.ToString()));

                foreach (Component component in componentList)
                {
                    if (component.IsActive == false)
                    {
                        continue;
                    }

                    this.Info("Initializing scheduler task '{0}' with ID '{1}'.", component.Description, component.ID);
                    ISchedulerTask task = ComponentLoader.LoadInterface<ISchedulerTask>(component.Assembly, component.ClassName);

                    if (task == null)
                    {
                        this.Fatal("Scheduler task '{0}' with ID '{1}' in assembly '{2}' and class '{3}' could not be found.",
                                   component.Description, component.ID, component.Assembly, component.ClassName);
                        return false;
                    }

                    if (task.Initialize(component.ID,
                                        dbSet.Productive.Query<ConfigurationValue>(new CommandFilter("ComponentID", component.ID)),
                                        dbSet) == false)
                    {
                        this.Error("Initializing scheduler task '{0}' with ID '{1}' failed.", component.Description, component.ID);
                        return false;
                    }

                    List<int> converterConfiguration = new List<int>();
                    var connectedConverterList = dbSet.Productive.Query<Component>(new CommandFilter("ConnectedComponentID", component.ID));

                    foreach (var converter in connectedConverterList)
                    {
                        converterConfiguration.Add(converter.ID);
                    }

                    _taskConverterStreams.Add(task, new List<IConverterStream>());
                    _taskConverterStreamConfig.Add(task, converterConfiguration);
                }

                return true;
            }
            catch (Exception ex)
            {
                this.Error("Initializing scheduler tasks failed.", ex);
            }

            return false;
        }
コード例 #19
0
ファイル: ReportDataSet.cs プロジェクト: amon0424/SWLHMS
            public static InspectListReportDataTable GetData(DateTime from, DateTime to, string partNumber, string qcn, string worksheetFrom, string worksheetTo, bool group, string line, bool onlyNg)
            {
                OleDbConnection conn = new OleDbConnection(Properties.Settings.Default.dbConnectionString);
                OleDbCommand    cmd  = new OleDbCommand();

                cmd.Connection = conn;

                System.Collections.Generic.List <string> whereList = new System.Collections.Generic.List <string>();
                whereList.Add("檢驗 = True");

                //處理條件
                if (!string.IsNullOrEmpty(qcn))
                {
                    cmd.Parameters.Add(new OleDbParameter("QCN", qcn + "%"));
                    whereList.Add("QCN LIKE ?");
                }

                if (!string.IsNullOrEmpty(partNumber))
                {
                    cmd.Parameters.Add(new OleDbParameter("品號", partNumber + "%"));
                    whereList.Add("P.品號 LIKE ?");
                }

                if (!string.IsNullOrEmpty(worksheetFrom))
                {
                    cmd.Parameters.Add(new OleDbParameter("工作單號1", worksheetFrom));
                    whereList.Add("W.單號 >= ?");
                }

                if (!string.IsNullOrEmpty(worksheetTo))
                {
                    cmd.Parameters.Add(new OleDbParameter("工作單號2", worksheetTo));
                    whereList.Add("W.單號 <= ?");
                }

                if (from != DateTime.MinValue)
                {
                    OleDbParameter param = new OleDbParameter("日期1", OleDbType.Date);
                    param.Value = from;
                    cmd.Parameters.Add(param);
                    whereList.Add("Q.日期 >= ?");
                }

                if (to != DateTime.MaxValue)
                {
                    OleDbParameter param = new OleDbParameter("日期2", OleDbType.Date);
                    param.Value = to;
                    cmd.Parameters.Add(param);
                    whereList.Add("Q.日期 <= ?");
                }

                if (!string.IsNullOrEmpty(line))
                {
                    cmd.Parameters.Add(new OleDbParameter("產線", line));
                    whereList.Add("產線 = ?");
                }

                if (group)
                {
                    whereList.Add("最後檢驗紀錄 = True");
                }

                if (onlyNg)
                {
                    whereList.Add("檢驗結果 = False");
                }

                string cmdText = "SELECT Q.日期 as 檢驗日期, 產線, W.單號 as 工作單號, P.品號, 客戶 as 客戶名稱, WP.數量 as 總數量, 待驗數量 as 檢驗數量, 送檢次數, QCN, IIF(檢驗結果,'OK',IIF(特許,'Concession','NG')) as 檢驗狀態, 工時資料編號, 最後送檢編號, 最後檢驗紀錄, WP.編號 as 工品編號" +
                                 " FROM ((((工時 as H INNER JOIN 產品檢驗 as Q on H.編號 = Q.工時資料編號)" +
                                 " INNER JOIN 工作單 as W ON H.工作單號 = W.單號)" +
                                 " INNER JOIN 工作單品號 as WP ON H.工作單號 = WP.單號 AND H.工品編號 = WP.編號)" +
                                 " INNER JOIN 產品品號 as P ON WP.品號 = P.品號)";

                if (whereList.Count > 0)
                {
                    cmdText += " WHERE " + string.Join(" AND ", whereList.ToArray());
                }

                cmdText += " ORDER BY 單據日期, W.單號, P.品號, WP.編號, 最後送檢編號, 送檢次數";

                cmd.CommandText = cmdText;
                OleDbDataAdapter adapter = new OleDbDataAdapter(cmd);

                InspectListReportDataTable table = new InspectListReportDataTable();

                adapter.Fill(table);

                //取得品質履歷
                foreach (DataRow row in table)
                {
                    //取得舊NG原因
                    string   id        = row["工時資料編號"].ToString();
                    string[] ngReasons = DatabaseSet.GetNGReason(id);
                    row["品質履歷"] = string.Join("\n", ngReasons);
                }

                return(table);
            }
コード例 #20
0
ファイル: DatabaseSet.cs プロジェクト: amon0424/SWLHMS
        public int UpdateEx(DatabaseSet.產品品號DataTable table)
        {
            OleDbDataAdapter adapter = new OleDbDataAdapter();

            adapter.UpdateCommand = UpdateCommand;
            adapter.InsertCommand = InsertCommand;
            adapter.DeleteCommand = DeleteCommand;

            this.Connection.Open();
            OleDbTransaction trans = this.Connection.BeginTransaction();
            adapter.InsertCommand.Transaction = trans;
            adapter.UpdateCommand.Transaction = trans;
            adapter.DeleteCommand.Transaction = trans;

            try
            {
                int count = 0;
                count = adapter.Update(table);
                trans.Commit();
                return count;
            }
            catch (System.Exception ex)
            {
                trans.Rollback();
                throw ex;
            }
            finally
            {
                this.Connection.Close();
            }
        }
コード例 #21
0
ファイル: InspectForm.cs プロジェクト: amon0424/SWLHMS
        private void btnSend_Click(object sender, EventArgs e)
        {
            try
            {
                if (_table != null)
                {
                    //檢查是否填寫完整
                    DataTable table = this.InspectMode == InspeceMode.ByPn ? this.GroupTable : _table;

                    DataRow[] rows = table.Select("檢驗=True AND 檢驗結果=False");

                    StringBuilder error = new StringBuilder();

                    foreach (DataRow row in rows)
                    {
                        if (string.IsNullOrEmpty(row["NG原因"] as string))
                        {
                            error.AppendLine("項次" + row["項次"] + " 必須填寫NG原因");
                        }

                        if (string.IsNullOrEmpty(row["NG處理"] as string))
                        {
                            error.AppendLine("項次" + row["項次"] + " 必須選擇NG處理方式");
                        }

                        if (error.Length > 100)
                        {
                            error.AppendLine("...");
                            break;
                        }
                    }
                    if (error.Length != 0)
                    {
                        throw new SWLHMSException(error.ToString());
                    }

                    if (MessageBox.Show("資料經送出後不可再修改,請確認後繼續", "送出確認", MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation) == DialogResult.OK)
                    {
                        if (this.InspectMode == InspeceMode.ByPn)
                        {
                            //將GroupTable的內容回填到Table上
                            rows = table.Select("檢驗=True");
                            foreach (DataRow groupRow in rows)
                            {
                                if (!groupRow.IsNull("工作單號") && !groupRow.IsNull("工品編號"))
                                {
                                    string worksheet = groupRow["工作單號"].ToString();
                                    int    wpid      = (int)groupRow["工品編號"];

                                    DataRow[] srcRow = _table.Select("工作單號= '" + worksheet + "' AND 工品編號=" + wpid);
                                    foreach (DataRow row in srcRow)
                                    {
                                        row["檢驗"]   = true;
                                        row["檢驗結果"] = groupRow["檢驗結果"];
                                        row["特許"]   = groupRow["特許"];
                                        row["NG處理"] = groupRow["NG處理"];
                                        row["NG原因"] = groupRow["NG原因"];
                                    }
                                }
                            }
                        }
                        int ok;
                        int update = DatabaseSet.UpdateInspectList(_table, out ok);

                        MessageBox.Show("更新了 " + update + " 筆檢驗資料\n共 " + ok + " 筆檢驗OK");
                        SearchList();
                    }
                }
            }
            catch (Exception ex)
            {
                Global.ShowError(ex);
            }
        }
コード例 #22
0
ファイル: DatabaseSet.cs プロジェクト: amon0424/SWLHMS
 public int FillBy月份(DatabaseSet.假日DataTable table,int 年份, int 月份)
 {
     this.Adapter.SelectCommand = SelectByMonthCommand;
     _selectByMonthCommand.Parameters["年份"].Value = 年份;
     _selectByMonthCommand.Parameters["月份"].Value = 月份;
     table.Clear();
     return this.Adapter.Fill(table);
 }
コード例 #23
0
        /// <summary>
        /// Initializes the WCF service manager with all configured services.
        /// </summary>
        /// <param name="dbSet">The set of active Mosaic databases.</param>
        /// <param name="packConveyorManager">The currently active pack conveyor manager.</param>
        /// <param name="orchestrationManager">The currently active orchestration manager.</param>
        /// <param name="boxSystem">The currently active box system implementation.</param>
        /// <returns>
        ///   <c>true</c> if initialization was successful;<c>false</c> otherwise.
        /// </returns>
        public bool Initialize(DatabaseSet dbSet, PackConveyorManager packConveyorManager, OrchestrationManager orchestrationManager, IBoxSystem boxSystem)
        {
            if (dbSet == null)
            {
                throw new ArgumentException("Invalid dbSet specified.");
            }

            if (packConveyorManager == null)
            {
                throw new ArgumentException("Invalid packConveyorManager specified.");
            }

            if (orchestrationManager == null)
            {
                throw new ArgumentException("Invalid orchestrationManager specified.");
            }

            _serviceList.Clear();

            this.Trace("Initializing WCF service manager...");

            try
            {
                List <Component> componentList = dbSet.Productive.Query <Component>(new CommandFilter("Type", ComponentType.WcfService.ToString()));

                foreach (Component component in componentList)
                {
                    if (component.IsActive == false)
                    {
                        continue;
                    }

                    this.Info("Initializing WCF service '{0}' with ID '{1}'.", component.Description, component.ID);
                    IWcfService service = ComponentLoader.LoadInterface <IWcfService>(component.Assembly, component.ClassName);

                    if (service == null)
                    {
                        this.Fatal("WCF service '{0}' with ID '{1}' in assembly '{2}' and class '{3}' could not be found.",
                                   component.Description, component.ID, component.Assembly, component.ClassName);
                        return(false);
                    }

                    ServiceHost svcHost = service.Initialize(component.ID,
                                                             dbSet.Productive.Query <ConfigurationValue>(new CommandFilter("ComponentID", component.ID)),
                                                             dbSet,
                                                             packConveyorManager.PackConveyors,
                                                             orchestrationManager.Orchestrations,
                                                             boxSystem);

                    if (svcHost == null)
                    {
                        this.Error("Initializing WCF service '{0}' with ID '{1}' failed.", component.Description, component.ID);
                        return(false);
                    }

                    try
                    {
                        svcHost.Open();
                        _serviceList.Add(svcHost);
                    }
                    catch (Exception ex)
                    {
                        this.Error("Starting WCF service '{0}' failed.", ex, component.Description);
                    }
                }

                return(true);
            }
            catch (Exception ex)
            {
                this.Error("Initializing WCF services failed.", ex);
            }

            return(false);
        }
コード例 #24
0
        protected override void BeforeExport()
        {
            string lineFilter = string.Empty;

            if (!string.IsNullOrEmpty(_form.Line))
            {
                lineFilter = "產線 = '" + _form.Line + "'";
            }

            UnfinishedWorksheetReportSourceTableAdapter adapter = new UnfinishedWorksheetReportSourceTableAdapter();

            //取得基本報表資料
            ReportDataSet.UnfinishedWorksheetReportSourceDataTable srcTable = adapter.GetData(this.StartDate, this.EndDate,
                                                                                              this.StartDate == DateTime.MinValue && this.EndDate == DateTime.MaxValue);
            srcTable.Columns.Add("退驗數量", typeof(decimal));
            srcTable.Columns.Add("待驗數量", typeof(decimal));

            //變更公式計算
            srcTable.Columns["完成%"].Expression = "IIF(數量 = 0,0,(已生產數量+待驗數量)/數量)";
            //srcTable.Columns["生產效率"].Expression = "IIF((內部工時+外包工時) = 0,0,(已生產數量+待驗數量)*標準工時/(內部工時+外包工時))";

            //取得日期範圍
            int      minYear, minMonth, maxYear, maxMonth;
            DateTime from, to;
            object   o;

            o       = srcTable.Compute("MIN(年份)", string.Empty);
            minYear = Convert.IsDBNull(o) ? DateTime.MinValue.Year : (int)o;

            o        = srcTable.Compute("MIN(月份)", string.Empty);
            minMonth = Convert.IsDBNull(o) ? DateTime.MinValue.Month : (int)o;

            o       = srcTable.Compute("MAX(年份)", string.Empty);
            maxYear = Convert.IsDBNull(o) ? DateTime.MinValue.Year : (int)o;

            o        = srcTable.Compute("MAX(月份)", string.Empty);
            maxMonth = Convert.IsDBNull(o) ? DateTime.MinValue.Month : (int)o;

            from = new DateTime(minYear, minMonth, 1);
            to   = new DateTime(maxYear, maxMonth, 1);

            //取得每月工作時數
            Dictionary <DateTime, decimal> workHoursDic = new Dictionary <DateTime, decimal>();

            for (DateTime date = new DateTime(from.Year, from.Month, 1); date <= to; date = date.AddMonths(1))
            {
                decimal hours = Global.GetWorkingHours(date.Year, date.Month);
                workHoursDic.Add(date, hours);
            }

            //重新運算內部工資
            DateTime curRowMonth = DateTime.MinValue;

            foreach (ReportDataSet.UnfinishedWorksheetReportSourceRow row in srcTable)
            {
                if (!Convert.IsDBNull(row["年份"]))
                {
                    if (row.年份 != curRowMonth.Year || row.月份 != curRowMonth.Month)
                    {
                        curRowMonth = new DateTime(row.年份, row.月份, 1);
                    }

                    row.內部工資 = Math.Round(row.內部工資 / workHoursDic[curRowMonth], MidpointRounding.AwayFromZero);
                }
            }

            //重新Group資料
            DataTableHelper dtHelper = new DataTableHelper();

            _table = dtHelper.SelectGroupByInto("ReportTable", srcTable,
                                                "產線,單據日期,預計完成日,工作單號,序號,品號,品名,退驗數量,待驗數量,數量,單位" +
                                                ",標準工時,單位人工成本, 總標準工時,Sum(內部工時) 內部工時, Sum(內部工資) 內部工資" +
                                                ",外包工時,外包工資,Sum(已生產數量) 已生產數量,完成%,生產效率,尚需工時,工品編號", lineFilter, "產線,單據日期,預計完成日,工作單號,品號,品名,數量,標準工時,單位人工成本,工品編號");

            //設定欄位
            _table.Columns["單位"].DefaultValue = "KPCS";
            _table.Columns.Add("未完成數量", typeof(decimal), "數量-已生產數量-待驗數量").SetOrdinal(9);

            //取得LaborWage資料庫
            LaborWageHelper     lwHelper = new LaborWageHelper();
            LaborWage工作單品號Table lwTable  = null;

            //運算序號並填入外包工資與工時
            string curWorksheetNumber = string.Empty;

            //int seriesNumber = 1;
            foreach (DataRow row in _table.Rows)
            {
                string wsNumber = row["工作單號"].ToString();
                string pn       = row["品號"].ToString();
                int    wpid     = (int)row["工品編號"];

                if (curWorksheetNumber != wsNumber)
                {
                    curWorksheetNumber = wsNumber;
                    //seriesNumber = 1;
                    lwTable = lwHelper.GetData(curWorksheetNumber);
                }

                //取得退驗
                row["退驗數量"] = DatabaseSet.GetNGAmount(wsNumber, wpid) / 1000.0f;
                row["待驗數量"] = DatabaseSet.GetInspectedAmount(wsNumber, wpid) / 1000.0f;

                //計算未完成數量
                //row["未完成數量"] = (decimal)row["數量"] - (decimal)row["已生產數量"];

                //DataRow[] lwRows = lwTable.Select(string.Format("品號 = '{0}'", row["品號"].ToString()));
                //DataRow[] lwRows = lwTable.Select(string.Format("工品編號 = {0}", row["工品編號"].ToString()));
                object result = lwTable.Compute("SUM(外包工資)", string.Format("工品編號 = {0}", row["工品編號"].ToString()));
                //if (lwRows.Length > 0)
                if (result != null && result != DBNull.Value)
                {
                    //decimal laborWage = (decimal)lwRows[0]["外包工資"];
                    decimal laborWage = Convert.ToDecimal(result);

                    //decimal number = (decimal)lwRows[0]["數量"];
                    row["外包工資"] = laborWage;
                    row["外包工時"] = laborWage / Settings.HourlyPay;
                    //row["已生產數量"] = (decimal)row["已生產數量"] + number;
                }
                if ((decimal)row["總標準工時"] != 0)
                {
                    //row["生產效率"] = ((decimal)row["內部工時"] + (decimal)row["外包工時"]) / ((decimal)row["總標準工時"] * (decimal)row["完成%"]);
                    //row["尚需工時"] = (decimal)row["總標準工時"] * (1 - (decimal)row["完成%"]);
                    row["尚需工時"] = (decimal)row["總標準工時"] - (decimal)row["內部工時"] - (decimal)row["外包工時"];
                }
                else
                {
                    row["尚需工時"] = 0;
                }

                //row["序號"] = seriesNumber++;
                row["序號"] = wpid;
            }

            base.BeforeExport();
        }
コード例 #25
0
        public virtual void Delete(object id)
        {
            TEntity entityToDelete = DatabaseSet.Find(id);

            Delete(entityToDelete);
        }
コード例 #26
0
 public virtual int FillByRange(DatabaseSet.假日DataTable dataTable, global::System.Nullable<global::System.DateTime> 日期, global::System.Nullable<global::System.DateTime> 日期1) {
     this.Adapter.SelectCommand = this.CommandCollection[1];
     if ((日期.HasValue == true)) {
         this.Adapter.SelectCommand.Parameters[0].Value = ((System.DateTime)(日期.Value));
     }
     else {
         this.Adapter.SelectCommand.Parameters[0].Value = global::System.DBNull.Value;
     }
     if ((日期1.HasValue == true)) {
         this.Adapter.SelectCommand.Parameters[1].Value = ((System.DateTime)(日期1.Value));
     }
     else {
         this.Adapter.SelectCommand.Parameters[1].Value = global::System.DBNull.Value;
     }
     if ((this.ClearBeforeFill == true)) {
         dataTable.Clear();
     }
     int returnValue = this.Adapter.Fill(dataTable);
     return returnValue;
 }
コード例 #27
0
 public virtual int FillBy產線(DatabaseSet.員工DataTable dataTable, string 產線) {
     this.Adapter.SelectCommand = this.CommandCollection[1];
     if ((產線 == null)) {
         this.Adapter.SelectCommand.Parameters[0].Value = global::System.DBNull.Value;
     }
     else {
         this.Adapter.SelectCommand.Parameters[0].Value = ((string)(產線));
     }
     if ((this.ClearBeforeFill == true)) {
         dataTable.Clear();
     }
     int returnValue = this.Adapter.Fill(dataTable);
     return returnValue;
 }
コード例 #28
0
ファイル: DatabaseSet.cs プロジェクト: amon0424/SWLHMS
        public bool IsHoliday(DatabaseSet.假日DataTable table, DateTime date)
        {
            DataRow[] rows = table.Select("日期 = #" + date.ToString("yyyy/MM/dd") + "#");

            //如果不在資料庫裡
            if (rows.Length == 0)
            {
                //判斷是否為周六日
                return date.DayOfWeek == DayOfWeek.Saturday || date.DayOfWeek == DayOfWeek.Sunday;
            }
            //如果在資料庫裡
            else
            {
                DatabaseSet.假日Row row = rows[0] as DatabaseSet.假日Row;
                return row.增加;
            }
        }
コード例 #29
0
 public virtual void Insert(TEntity entity)
 {
     DatabaseSet.Add(entity);
 }
コード例 #30
0
 public virtual int FillBy單號(DatabaseSet.工作單品號DataTable dataTable, string 單號) {
     this.Adapter.SelectCommand = this.CommandCollection[1];
     if ((單號 == null)) {
         throw new global::System.ArgumentNullException("單號");
     }
     else {
         this.Adapter.SelectCommand.Parameters[0].Value = ((string)(單號));
     }
     if ((this.ClearBeforeFill == true)) {
         dataTable.Clear();
     }
     int returnValue = this.Adapter.Fill(dataTable);
     return returnValue;
 }
コード例 #31
0
        /// <summary>
        /// Initializes the connector manager with all configured connectors.
        /// </summary>
        /// <param name="dbSet">The set of active Mosaic databases.</param>
        /// <param name="converterManager">The active converter manager to notify about new connections.</param>
        /// <returns><c>true</c> if initialization was successful;<c>false</c> otherwise.</returns>
        public bool Initialize(DatabaseSet dbSet, ConverterManager converterManager)
        {
            if (dbSet == null)
            {
                throw new ArgumentException("Invalid dbSet specified.");
            }

            if (converterManager == null)
            {
                throw new ArgumentException("Invalid converterManager specified.");
            }

            this.Trace("Initializing connector manager...");

            _connectorList.Clear();
            _converterAssignments.Clear();
            _converterManager = converterManager;

            ProcessConfigurationMigration(dbSet.Productive);

            try
            {
                List <Component> componentList = dbSet.Productive.Query <Component>(new CommandFilter("Type", ComponentType.Connector.ToString()));

                foreach (Component component in componentList)
                {
                    if (component.IsActive == false)
                    {
                        continue;
                    }

                    if (component.ConnectedComponentID == 0)
                    {
                        this.Error("No converter has been configured for the connector '{0}' with ID '{1}'.",
                                   component.Description, component.ID);

                        return(false);
                    }

                    this.Info("Initializing connector '{0}' with ID '{1}'.", component.Description, component.ID);
                    IConnector connector = ComponentLoader.LoadInterface <IConnector>(component.Assembly, component.ClassName);

                    if (connector == null)
                    {
                        this.Fatal("Connector '{0}' with ID '{1}' in assembly '{2}' and class '{3}' could not be found.",
                                   component.Description, component.ID, component.Assembly, component.ClassName);
                        return(false);
                    }

                    if (connector.Initialize(component.ID,
                                             dbSet.Productive.Query <ConfigurationValue>(new CommandFilter("ComponentID", component.ID))) == false)
                    {
                        this.Error("Initializing connector '{0}' with ID '{1}' failed.", component.Description, component.ID);
                        return(false);
                    }

                    _connectorList.Add(connector);
                    _converterAssignments.Add(connector.ID, component.ConnectedComponentID);
                }

                // finally start connector threads
                foreach (var connector in _connectorList)
                {
                    Interlocked.Increment(ref _numRunningThreads);

                    if (ThreadPool.QueueUserWorkItem(new WaitCallback(ProcessConnector), connector) == false)
                    {
                        Interlocked.Decrement(ref _numRunningThreads);
                        this.Error("Starting connector thread failed.");
                        return(false);
                    }
                }

                return(true);
            }
            catch (Exception ex)
            {
                this.Error("Initializing connectors failed.", ex);
            }

            return(false);
        }
コード例 #32
0
 public virtual int Update(DatabaseSet dataSet) {
     return this.Adapter.Update(dataSet, "工作單品號");
 }
コード例 #33
0
ファイル: DatabaseSet.cs プロジェクト: amon0424/SWLHMS
        public int Update(DatabaseSet.假日ViewDataTable table)
        {
            OleDbDataAdapter adapter = new OleDbDataAdapter();

            adapter.UpdateCommand = UpdateCommand;
            adapter.InsertCommand = InsertCommand;
            adapter.DeleteCommand = DeleteCommand;

            this.Connection.Open();
            OleDbTransaction trans = this.Connection.BeginTransaction();
            adapter.InsertCommand.Transaction = trans;
            adapter.UpdateCommand.Transaction = trans;
            adapter.DeleteCommand.Transaction = trans;

            try
            {
                int count = 0;
                foreach (DatabaseSet.假日ViewRow row in table)
                {
                    switch (row.RowState)
                    {
                        case DataRowState.Added:
                            //如果要加入週六日
                            if (row.週六日)
                            {
                                adapter.DeleteCommand.Parameters["日期"].Value = row.日期;
                                count += adapter.DeleteCommand.ExecuteNonQuery();
                            }
                            else
                            {
                                adapter.InsertCommand.Parameters["日期"].Value = row.日期;
                                adapter.InsertCommand.Parameters["增加"].Value = true;
                                count += adapter.InsertCommand.ExecuteNonQuery();
                            }
                            break;
                        case DataRowState.Deleted:
                            //如果要移除週六日
                            if ((bool)row["週六日", DataRowVersion.Original])
                            {
                                adapter.InsertCommand.Parameters["日期"].Value = row["日期", DataRowVersion.Original];
                                adapter.InsertCommand.Parameters["增加"].Value = false;
                                count += adapter.InsertCommand.ExecuteNonQuery();
                            }
                            else
                            {
                                adapter.DeleteCommand.Parameters["日期"].Value = row["日期", DataRowVersion.Original];
                                count += adapter.DeleteCommand.ExecuteNonQuery();
                            }
                            break;
                        case DataRowState.Modified:
                            //adapter.UpdateCommand.Parameters["日期"].Value = row.日期;
                            //adapter.UpdateCommand.Parameters["Original_日期"].Value = row["日期", DataRowVersion.Original];
                            //count += adapter.UpdateCommand.ExecuteNonQuery();
                            break;
                        default:
                            break;
                    }
                }

                trans.Commit();
                return count;
            }
            catch (System.Exception ex)
            {
                trans.Rollback();
                throw ex;
            }
            finally
            {
                this.Connection.Close();
            }
        }
コード例 #34
0
        /// <summary>
        /// Initializes the all Mosaic component manager instances and the box picking implementation.
        /// </summary>
        /// <param name="dbSet">The set of active Mosaic databases.</param>
        /// <returns><c>true</c> if initialization was successful;<c>false</c> otherwise.</returns>
        public bool Initialize(DatabaseSet dbSet)
        {
            if (_taskScheduler.Initialize(dbSet) == false)
            {
                Cancel();
                Dispose();
                return(false);
            }

            if (_packConveyorManager.Initialize(dbSet, _captureHost) == false)
            {
                Cancel();
                Dispose();
                return(false);
            }

            if (InitializeBoxSystem(dbSet) == false)
            {
                Cancel();
                Dispose();
                return(false);
            }

            DeletePlcConnections(dbSet);

            if (_orchestrationManager.Initialize(dbSet, _packConveyorManager, _boxSystem, _captureHost) == false)
            {
                Cancel();
                Dispose();
                return(false);
            }

            if (_wcfServiceManager.Initialize(dbSet, _packConveyorManager, _orchestrationManager, _boxSystem) == false)
            {
                Cancel();
                Dispose();
                return(false);
            }

            if (_converterManager.Initialize(dbSet, _orchestrationManager, _taskScheduler) == false)
            {
                Cancel();
                Dispose();
                return(false);
            }

            if (_connectorManager.Initialize(dbSet, _converterManager) == false)
            {
                Cancel();
                Dispose();
                return(false);
            }

            if (_taskScheduler.Start() == false)
            {
                Cancel();
                Dispose();
                return(false);
            }

            return(true);
        }
コード例 #35
0
 public virtual int FillBy系列編號(DatabaseSet.產品品號ViewDataTable dataTable, int 系列編號) {
     this.Adapter.SelectCommand = this.CommandCollection[0];
     this.Adapter.SelectCommand.Parameters[0].Value = ((int)(系列編號));
     if ((this.ClearBeforeFill == true)) {
         dataTable.Clear();
     }
     int returnValue = this.Adapter.Fill(dataTable);
     return returnValue;
 }
コード例 #36
0
ファイル: DatabaseSet.cs プロジェクト: amon0424/SWLHMS
        public int Fill(DatabaseSet.工作單DataTable table, string 單號, int dateType, DateTime from, DateTime to,int doneOrNot)
        {
            單號 = 單號.Replace("'", "''");
            //客戶名稱 = 客戶名稱.Replace("'", "''");

            System.Text.StringBuilder sb = new System.Text.StringBuilder();
            sb.Append("SELECT * FROM 工作單 ");

            System.Collections.Generic.List<string> whereCond = new System.Collections.Generic.List<string>();
            if (單號.Trim() != string.Empty)
                whereCond.Add("單號 LIKE '%" + 單號 + "%'");
            //if (客戶名稱.Trim() != string.Empty)
            //    whereCond.Add("客戶名稱 LIKE'%" + 客戶名稱 + "%'");

            if (dateType > 0)
            {
                if (dateType == 1)
                {
                    whereCond.Add("單據日期 >= #" + from.ToString("yyyy/MM/dd") + "#");
                    whereCond.Add("單據日期 <= #" + to.ToString("yyyy/MM/dd") + "#");
                }
                else
                {
                    whereCond.Add("實際完成日 >= #" + from.ToString("yyyy/MM/dd") + "#");
                    whereCond.Add("實際完成日 <= #" + to.ToString("yyyy/MM/dd") + "#");
                }
            }

            if (doneOrNot > 0)
            {
                if (doneOrNot == 1)
                {
                    whereCond.Add("實際完成日 IS NOT NULL");
                }
                else
                {
                    whereCond.Add("實際完成日 IS NULL");
                }
            }

            if (whereCond.Count > 0)
            {
                string whereStr = string.Join(" AND ", whereCond.ToArray());
                sb.Append(" WHERE " + whereStr);
            }

            OleDbCommand cmd = new OleDbCommand(sb.ToString());
            cmd.Connection = this.Connection;
            this.Adapter.SelectCommand = cmd;

            return this.Adapter.Fill(table);
        }
コード例 #37
0
 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();
     DatabaseSet ds = new DatabaseSet();
     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 = "待驗清單DataTable";
     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;
 }
コード例 #38
0
ファイル: DatabaseSet.cs プロジェクト: amon0424/SWLHMS
        public int UpdateEx(DatabaseSet.工作單品號DataTable table)
        {
            int count = 0;
            foreach (DatabaseSet.工作單品號Row row in table)
            {
                if (row.RowState != DataRowState.Added)
                    continue;

                string idCmdTxt = "SELECT MAX(編號) FROM 工作單品號 WHERE 單號 = ?";

                OleDbCommand cmd = new OleDbCommand(idCmdTxt, Instance.Connection);
                cmd.Parameters.Add(new OleDbParameter("單號", row.單號));
                Instance.Connection.Open();
                object result = cmd.ExecuteScalar();
                Instance.Connection.Close();

                int id = 0;
                if (result != DBNull.Value)
                    id = Convert.ToInt32(result);

                row.編號 = id+1;

                count += Instance.Update(row);
            }

            //string insertCmdTxt = "INSERT INTO 工作單品號 (單號, 品號, 數量, 實際完成日, 客戶需貨日, 預計完成日, 客戶, 編號) " +
            //                "VALUES (?, ?, ?, ?, ?, ?, ?, (SELECT MAX(編號) FROM 工作單品號 WHERE 單號 = ?))";

            //string updateCmdTxt = "UPDATE 工作單品號 SET 單號=?, 品號=?, 數量=?, 實際完成日=?, 客戶需貨日=?, 預計完成日=?, 客戶 = ?, 編號 = ?";

            //OleDbCommand insertCmd = new OleDbCommand(insertCmdTxt, Instance.Connection);
            //insertCmd.Parameters.Add("單號", OleDbType.VarWChar);
            //insertCmd.Parameters.Add("品號", OleDbType.VarWChar);
            //insertCmd.Parameters.Add("數量", OleDbType.VarWChar);
            //insertCmd.Parameters.Add("實際完成日", OleDbType.Date);
            //insertCmd.Parameters.Add("客戶需貨日", OleDbType.Date);
            //insertCmd.Parameters.Add("預計完成日", OleDbType.Date);
            //insertCmd.Parameters.Add("客戶", OleDbType.VarWChar);
            //insertCmd.Parameters.Add("單號2", OleDbType.VarWChar,255,"單號");
            //Instance.Adapter.InsertCommand = insertCmd;

            ////OleDbCommand updateCmd = new OleDbCommand(updateCmdTxt, Instance.Connection);
            ////Instance.Adapter.UpdateCommand = updateCmd;

            count += Instance.Update(table);

            return count;
        }
コード例 #39
0
 public virtual int Fill(DatabaseSet.工作單品號DataTable dataTable) {
     this.Adapter.SelectCommand = this.CommandCollection[0];
     if ((this.ClearBeforeFill == true)) {
         dataTable.Clear();
     }
     int returnValue = this.Adapter.Fill(dataTable);
     return returnValue;
 }
コード例 #40
0
ファイル: DatabaseSet.cs プロジェクト: amon0424/SWLHMS
        public int Fill(DatabaseSet.工時DataTable table, string 員工編號, int 非生產編號, bool date, DateTime from, DateTime to)
        {
            員工編號 = 員工編號.Replace("'", "''");

            System.Text.StringBuilder sb = new System.Text.StringBuilder();
            sb.Append("SELECT 工時.編號, 借入產線, 員工編號, 日期, 工作單號, NULL as 品號, 工時, 工時類型, 數量, NULL as 待驗數量, 非生產編號, 備註, 非生產.名稱 AS 非生產名稱, 員工.姓名 AS 員工姓名 FROM ( 工時 INNER JOIN 非生產 ON 工時.非生產編號 = 非生產.編號 ) INNER JOIN 員工 ON 工時.員工編號 = 員工.編號 ");

            System.Collections.Generic.List<string> whereCond = new System.Collections.Generic.List<string>();

            if (員工編號.Trim() != string.Empty)
                whereCond.Add("工時.員工編號 ='" + 員工編號 + "'");

            whereCond.Add("工時.非生產編號 =" + 非生產編號);

            if (date)
            {
                whereCond.Add("日期 >= #" + from.ToString("yyyy/MM/dd") + "#");
                whereCond.Add("日期 <= #" + to.ToString("yyyy/MM/dd") + "#");
            }

            if (whereCond.Count > 0)
            {
                string whereStr = string.Join(" AND ", whereCond.ToArray());
                sb.Append(" WHERE " + whereStr);
            }

            sb.Append(" ORDER BY 日期,工時.編號 ");

            OleDbCommand cmd = new OleDbCommand(sb.ToString());
            cmd.Connection = this.Connection;
            this.Adapter.SelectCommand = cmd;

            return this.Adapter.Fill(table);
        }
コード例 #41
0
 public virtual int Update(DatabaseSet.工作單品號DataTable dataTable) {
     return this.Adapter.Update(dataTable);
 }
コード例 #42
0
ファイル: DatabaseSet.cs プロジェクト: amon0424/SWLHMS
        public int Fill(DatabaseSet.工時DataTable table, string 員工編號, bool date, DateTime from, DateTime to)
        {
            員工編號 = 員工編號.Replace("'", "''");

            System.Text.StringBuilder sb = new System.Text.StringBuilder();
            sb.Append("SELECT 工時.編號, 借入產線, 員工編號, 工時.日期, 工作單號, WP.編號 as 工品編號, 品號, 工時, 工時類型, 工時.數量, 待驗數量, QCN, 非生產編號, 備註, 非生產.名稱 as 非生產名稱, 員工.姓名 as 員工姓名 " +
                      "FROM ((( 工時 INNER JOIN 非生產 ON 工時.非生產編號 = 非生產.編號 ) " +
                        " LEFT JOIN 產品檢驗 ON 工時.編號 = 產品檢驗.工時資料編號 )" +
                        " LEFT JOIN 工作單品號 as WP ON 工時.工作單號 = WP.單號 AND 工時.工品編號 = WP.編號) " +
                        " INNER JOIN 員工 ON 工時.員工編號 = 員工.編號 ");

            System.Collections.Generic.List<string> whereCond = new System.Collections.Generic.List<string>();

            if (員工編號.Trim() != string.Empty)
                whereCond.Add("工時.員工編號 ='" + 員工編號 + "'");

            if (date)
            {
                whereCond.Add("工時.日期 >= #" + from.ToString("yyyy/MM/dd") + "#");
                whereCond.Add("工時.日期 <= #" + to.ToString("yyyy/MM/dd") + "#");
            }

            if (whereCond.Count > 0)
            {
                string whereStr = string.Join(" AND ", whereCond.ToArray());
                sb.Append(" WHERE " + whereStr);
            }

            sb.Append(" ORDER BY 工時.日期,工時.編號 ");

            OleDbCommand cmd = new OleDbCommand(sb.ToString());
            cmd.Connection = this.Connection;
            this.Adapter.SelectCommand = cmd;

            return this.Adapter.Fill(table);
        }
コード例 #43
0
ファイル: DatabaseSet.cs プロジェクト: amon0424/SWLHMS
        public int FillFilledDataBy員工編號(DatabaseSet.工時DataTable table, string 員工編號)
        {
            員工編號 = 員工編號.Replace("'","''");

            OleDbCommand cmd = new OleDbCommand();
            cmd.CommandText = "SELECT 員工編號, 日期 FROM 工時 GROUP BY 員工編號, 日期" +
                             " HAVING 員工編號 = '" + 員工編號 + "' AND 日期 >= #" + Settings.UnfilledDate.ToString("yyyy/MM/dd") + "# AND 日期 <= #" + DateTime.Today.ToString("yyyy/MM/dd") + "# AND SUM(工時) >= " + Settings.WorkingHoursPerDay;
            cmd.Connection = this.Connection;

            this.Adapter.SelectCommand = cmd;
            return this.Adapter.Fill(table);
        }
コード例 #44
0
        /// <summary>
        /// Initializes the connector manager with all configured connectors.
        /// </summary>
        /// <param name="dbSet">The set of active Mosaic databases.</param>
        /// <param name="orchestrationManager">The active orchestration manager to notify about new converter streams.</param>
        /// <param name="taskScheduler">The active task scheduler to notify about converter streams.</param>
        /// <returns><c>true</c> if initialization was successful;<c>false</c> otherwise.</returns>
        public bool Initialize(DatabaseSet dbSet,
                               OrchestrationManager orchestrationManager,
                               TaskScheduler taskScheduler)
        {
            if (dbSet == null)
            {
                throw new ArgumentException("Invalid dbSet specified.");
            }

            if (orchestrationManager == null)
            {
                throw new ArgumentException("Invalid orchestrationManager specified.");
            }

            if (taskScheduler == null)
            {
                throw new ArgumentException("Invalid taskScheduler specified.");
            }

            this.Trace("Initializing converter manager...");

            _converterList.Clear();
            _taskAssignments.Clear();
            _orchestrationManager = orchestrationManager;
            _taskScheduler        = taskScheduler;

            try
            {
                List <Component> componentList = dbSet.Productive.Query <Component>(new CommandFilter("Type", ComponentType.Converter.ToString()));

                foreach (Component component in componentList)
                {
                    if (component.IsActive == false)
                    {
                        continue;
                    }

                    this.Info("Initializing converter '{0}' with ID '{1}'.", component.Description, component.ID);
                    IConverter converter = ComponentLoader.LoadInterface <IConverter>(component.Assembly, component.ClassName);

                    if (converter == null)
                    {
                        this.Fatal("Converter '{0}' with ID '{1}' in assembly '{2}' and class '{3}' could not be found.",
                                   component.Description, component.ID, component.Assembly, component.ClassName);
                        return(false);
                    }

                    if (converter.Initialize(component.ID,
                                             dbSet.Productive.Query <ConfigurationValue>(new CommandFilter("ComponentID", component.ID))) == false)
                    {
                        this.Error("Initializing converter '{0}' with ID '{1}' failed.", component.Description, component.ID);
                        return(false);
                    }

                    _converterList.Add(converter);

                    if (component.ConnectedComponentID != 0)
                    {
                        _taskAssignments.Add(converter.ID, component.ConnectedComponentID);
                    }
                }

                return(true);
            }
            catch (Exception ex)
            {
                this.Error("Initializing converters failed.", ex);
            }

            return(false);
        }