コード例 #1
0
        public override ValueObject Execute(TransactionContext trxContext, ValueObject vo)
        {
            MaintenanceMachineVTVo inVo     = (MaintenanceMachineVTVo)vo;
            StringBuilder          sql      = new StringBuilder();
            MaintenanceMachineVTVo voNOList = new MaintenanceMachineVTVo();
            //create command
            DbCommandAdaptor sqlCommandAdapter = base.GetDbCommandAdaptor(trxContext, sql.ToString());

            //create parameter
            DbParameterList sqlParameter = sqlCommandAdapter.CreateParameterList();

            sql.Append(@"select count(*) as SerialCount from t_vt_maintenance where ");
            sql.Append(" machine_serial  =:machine_serial");
            sqlParameter.AddParameterString("machine_serial", inVo.MachineSerial);

            sqlCommandAdapter = base.GetDbCommandAdaptor(trxContext, sql.ToString());

            //execute SQL
            IDataReader dataReader = sqlCommandAdapter.ExecuteReader(trxContext, sqlParameter);

            while (dataReader.Read())
            {
                MaintenanceMachineVTVo outVo = new MaintenanceMachineVTVo
                {
                    AffectedCount = Convert.ToInt32(dataReader["SerialCount"].ToString()),
                };
                voNOList.AffectedCount = outVo.AffectedCount;
            }
            dataReader.Close();
            return(voNOList);
        }
コード例 #2
0
        private void delete_btn_Click(object sender, EventArgs e)
        {
            if (mainternance_vt_dgv.Rows.Count > 0 && mainternance_vt_dgv.DataSource != null && searchstatus_cbm.Text == "Danh sách")
            {
                try
                {
                    if (MessageBox.Show("Bạn có chắc xóa thiết bị này !", "Thông báo", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK)

                    {
                        MaintenanceMachineVTVo selectedvo = (MaintenanceMachineVTVo)mainternance_vt_dgv.CurrentRow.DataBoundItem;
                        MaintenanceMachineVTVo outVo      = new MaintenanceMachineVTVo();
                        outVo = (MaintenanceMachineVTVo)DefaultCbmInvoker.Invoke(new Cbm.DeleteMainternanceMachineVTCbm(), selectedvo);

                        if (outVo.AffectedCount > 0)
                        {
                            messageData = new MessageData("mmce00001", Properties.Resources.mmce00001, "Số Máy" + " : " + machine_serial_cmb.Text);
                            logger.Info(messageData);
                            popUpMessage.Information(messageData, Text);
                        }
                        GridBind_mainternance();
                    }
                }
                catch (Framework.ApplicationException exception)
                {
                    popUpMessage.ApplicationError(exception.GetMessageData(), Text);
                    logger.Error(exception.GetMessageData());
                }
            }
            if (mainternance_vt_dgv.Rows.Count > 0 && mainternance_vt_dgv.DataSource != null && searchstatus_cbm.Text != "Danh sách")
            {
                MessageBox.Show("Không thể xóa với loại tìm kiếm là LỊCH SỬ", "Thông báo", MessageBoxButtons.OKCancel, MessageBoxIcon.Error);
            }
        }
コード例 #3
0
        void GridBind_mainternance()
        {
            try
            {
                MaintenanceMachineVTVo inVo = new MaintenanceMachineVTVo
                {
                    MachineSerial   = machine_serial_cmb.Text,
                    MachineLocation = location_cmb.Text,
                    RFId            = rfid_txt.Text,
                    MachineModel    = machine_model_cmb.Text,
                    MachineSupplier = machine_supplier_cmb.Text,
                    MachineStatus   = machine_status_cmb.Text,
                    SearchStatus    = searchstatus_cbm.Text,                 //Danh sách     Lịch sử
                };
                ValueObjectList <MaintenanceMachineVTVo> listvo = (ValueObjectList <MaintenanceMachineVTVo>)DefaultCbmInvoker.Invoke(new Cbm.SearchMainternanceMachineVTCbm(), inVo);
                mainternance_vt_dgv.DataSource = listvo.GetList();

                caculatorDatePlan();
            }
            catch (Framework.ApplicationException exception)
            {
                popUpMessage.ApplicationError(exception.GetMessageData(), Text);
                logger.Error(exception.GetMessageData());
            }
        }
コード例 #4
0
        void caculatorDatePlan()
        {
            //   mainternance_vt_dgv.Columns["col_factorycd"]
            // mainternance_vt_dgv.Columns["col_machineqty"]
            //  mainternance_vt_dgv.Columns["col_checkstatus"]
            for (int i = 0; i < mainternance_vt_dgv.RowCount; i++)
            {
                DateTime startdatetime   = DateTime.Parse(mainternance_vt_dgv.Rows[i].Cells["col_factorycd"].Value.ToString());
                int      monthrepeat     = int.Parse(mainternance_vt_dgv.Rows[i].Cells["col_machineqty"].Value.ToString());
                DateTime compareDateTime = startdatetime.AddDays(0);
                bool     checkstatus     = bool.Parse(mainternance_vt_dgv.Rows[i].Cells["col_checkstatus"].Value.ToString());
                DateTime NowDateTime     = DateTime.Now;
                TimeSpan ts = compareDateTime - NowDateTime;


                if (compareDateTime < NowDateTime && searchstatus_cbm.Text == "Danh sách")
                {
                    TimeSpan timeDate = NowDateTime - startdatetime;
                    //double totalday = timeDate.TotalDays;
                    //double ng = totalday / 10;
                    int solan = (int)(timeDate.TotalDays / monthrepeat) + 1;
                    if (solan > 0)
                    {
                        for (int j = 1; j <= solan; j++)
                        {
                            MaintenanceMachineVTVo InVo = new MaintenanceMachineVTVo()
                            {
                                MachineModel  = mainternance_vt_dgv.Rows[i].Cells["col_machinemodel"].Value.ToString(),
                                MachineSerial = mainternance_vt_dgv.Rows[i].Cells["col_machineserial"].Value.ToString(),
                                StartDay      = startdatetime.AddDays(monthrepeat * j),
                                MonthRepeat   = monthrepeat,
                                CheckStatus   = false,
                            };

                            MaintenanceMachineVTVo AddVo = (MaintenanceMachineVTVo)DefaultCbmInvoker.Invoke(new Cbm.AddMainternanceMachineVTCbm(), InVo);
                        }
                    }
                }
                if (checkstatus == false)
                {
                    if (ts.TotalDays < 8 && ts.TotalDays > -1)
                    {
                        //vang
                        { mainternance_vt_dgv.Rows[i].DefaultCellStyle.BackColor = Color.Yellow; }
                    }
                    if (float.Parse(Convert.ToString(ts.TotalDays)) < 0)
                    {
                        //do
                        mainternance_vt_dgv.Rows[i].DefaultCellStyle.BackColor = Color.Red;
                    }
                    if (float.Parse(Convert.ToString(ts.TotalDays)) > 7)
                    {
                        //trang
                        mainternance_vt_dgv.Rows[i].DefaultCellStyle.BackColor = Color.White;
                    }
                }
            }
        }
コード例 #5
0
        private void search_info_btn_Click(object sender, EventArgs e)
        {
            checkboxHeader.Visible = true;
            addcheckboxheader();
            mainternance_vt_dgv.DataSource = null;
            mainternance_vt_dgv.ReadOnly   = false;
            //change datasourch
            mainternance_vt_dgv.Columns["col_machineid"].DataPropertyName        = "MainternanceId";
            mainternance_vt_dgv.Columns["col_rfid"].DataPropertyName             = "RFId";
            mainternance_vt_dgv.Columns["col_machineserial"].DataPropertyName    = "MachineSerial";
            mainternance_vt_dgv.Columns["col_machinename"].DataPropertyName      = "MachineName";
            mainternance_vt_dgv.Columns["col_machinemodel"].DataPropertyName     = "MachineModel";
            mainternance_vt_dgv.Columns["col_machineqty"].DataPropertyName       = "MonthRepeat";
            mainternance_vt_dgv.Columns["col_machinelocation"].DataPropertyName  = "MachineLocation";
            mainternance_vt_dgv.Columns["col_machinesupplier"].DataPropertyName  = "MachineSupplier";
            mainternance_vt_dgv.Columns["col_machinestatus"].DataPropertyName    = "MachineStatus";
            mainternance_vt_dgv.Columns["col_factorycd"].DataPropertyName        = "StartDay";
            mainternance_vt_dgv.Columns["col_machinecostvalue"].DataPropertyName = "RegistrationUserCode";
            mainternance_vt_dgv.Columns["col_datetime"].DataPropertyName         = "RegistrationDateTime";

            //change header
            mainternance_vt_dgv.Columns["col_machineqty"].HeaderText       = "Month Repeat";
            mainternance_vt_dgv.Columns["col_factorycd"].HeaderText        = "Start Day";
            mainternance_vt_dgv.Columns["col_machinecostvalue"].HeaderText = "User Add";
            //change status
            mainternance_vt_dgv.Columns["col_checkstatus"].DataPropertyName = "CheckStatus";
            mainternance_vt_dgv.Columns["col_checkstatus"].Visible          = true;
            mainternance_vt_dgv.Columns["col_rfid"].Visible = false;

            try
            {
                MaintenanceMachineVTVo inVo = new MaintenanceMachineVTVo
                {
                    MachineSerial   = machine_serial_cmb.Text,
                    MachineLocation = location_cmb.Text,
                    RFId            = rfid_txt.Text,
                    MachineModel    = machine_model_cmb.Text,
                    MachineSupplier = machine_supplier_cmb.Text,
                    MachineStatus   = machine_status_cmb.Text
                };
                ValueObjectList <MaintenanceMachineVTVo> listvo = (ValueObjectList <MaintenanceMachineVTVo>)DefaultCbmInvoker.Invoke(new Cbm.SearchMainternanceMachineVTCbm(), inVo);
                mainternance_vt_dgv.DataSource = listvo.GetList();

                caculatorDatePlan();
            }
            catch (Framework.ApplicationException exception)
            {
                popUpMessage.ApplicationError(exception.GetMessageData(), Text);
                logger.Error(exception.GetMessageData());
            }
        }
コード例 #6
0
        public override ValueObject Execute(TransactionContext trxContext, ValueObject vo)
        {
            MaintenanceMachineVTVo inVo = (MaintenanceMachineVTVo)vo;
            StringBuilder          sql  = new StringBuilder();

            sql.Append(@"insert into t_vt_maintenance(machine_serial,
            machine_model ,
            start_day ,
            month_repeat,
            check_status,
            registration_user_cd,
            registration_date_time,
            factory_cd) ");

            sql.Append(@"values(:machine_serial ,
            :machine_model,
            :start_day ,
            :month_repeat ,
            :check_status,
            :registration_user_cd,
            now(),
            :factory_cd)");

            //create command
            DbCommandAdaptor sqlCommandAdapter = base.GetDbCommandAdaptor(trxContext, sql.ToString());

            //create parameter
            DbParameterList sqlParameter = sqlCommandAdapter.CreateParameterList();

            sqlParameter.AddParameter("machine_serial", inVo.MachineSerial);
            sqlParameter.AddParameter("machine_model", inVo.MachineModel);
            sqlParameter.AddParameter("start_day", inVo.StartDay);
            sqlParameter.AddParameter("month_repeat", inVo.MonthRepeat);
            sqlParameter.AddParameter("check_status", inVo.CheckStatus);
            sqlParameter.AddParameter("registration_user_cd", UserData.GetUserData().UserCode);
            sqlParameter.AddParameter("factory_cd", UserData.GetUserData().FactoryCode);



            //execute SQL

            MaintenanceMachineVTVo outVo = new MaintenanceMachineVTVo
            {
                AffectedCount = sqlCommandAdapter.ExecuteNonQuery(sqlParameter)
            };

            return(outVo);
        }
コード例 #7
0
        private void Ok_btn_Click(object sender, EventArgs e)
        {
            //col_machineserial
            //col_machinemodel
            if (checkdata())
            {
                try
                {
                    for (int i = 0; i < dgv.RowCount; i++)
                    {
                        MaintenanceMachineVTVo inVo = new MaintenanceMachineVTVo
                        {
                            MachineModel  = dgv.Rows[i].Cells["col_machinemodel"].Value.ToString(),
                            MachineSerial = dgv.Rows[i].Cells["col_machineserial"].Value.ToString(),
                            StartDay      = start_day_dtp.Value,
                            MonthRepeat   = int.Parse(month_repeat_txt.Text),
                            CheckStatus   = false,
                        };
                        CheckoutVo = (MaintenanceMachineVTVo)DefaultCbmInvoker.Invoke(new Cbm.CheckMainternanceMachineVTCbm(), inVo);

                        if (CheckoutVo.AffectedCount == 0)
                        {
                            outVo = (MaintenanceMachineVTVo)DefaultCbmInvoker.Invoke(new Cbm.AddMainternanceMachineVTCbm(), inVo);
                        }
                    }
                }
                catch (Framework.ApplicationException exception)
                {
                    popUpMessage.ApplicationError(exception.GetMessageData(), Text);
                    logger.Error(exception.GetMessageData());
                }
            }
            if (outVo.AffectedCount > 0)
            {
                messageData = new MessageData("mmce00001", Properties.Resources.mmce00001, "Model: " + " : " + machine_model);
                logger.Info(messageData);
                popUpMessage.Information(messageData, Text);
            }
        }
コード例 #8
0
 private void update_info_btn_Click(object sender, EventArgs e)
 {
     if (mainternance_vt_dgv.RowCount > 0)
     {
         try
         {
             for (int i = 0; i < mainternance_vt_dgv.RowCount; i++)
             {
                 MaintenanceMachineVTVo inVo  = (MaintenanceMachineVTVo)mainternance_vt_dgv.Rows[i].DataBoundItem;
                 MaintenanceMachineVTVo outVo = new MaintenanceMachineVTVo();
                 outVo = (MaintenanceMachineVTVo)DefaultCbmInvoker.Invoke(new Cbm.UpdateinfoMainternanceMachineVTCbm(), inVo);
             }
             messageData = new MessageData("mmce00001", Properties.Resources.mmce00001, "UPDATE: " + " : " + "LIST");
             logger.Info(messageData);
             popUpMessage.Information(messageData, Text);
         }
         catch (Framework.ApplicationException exception)
         {
             popUpMessage.ApplicationError(exception.GetMessageData(), Text);
             logger.Error(exception.GetMessageData());
         }
     }
 }
コード例 #9
0
        public override ValueObject Execute(TransactionContext trxContext, ValueObject vo)
        {
            MaintenanceMachineVTVo inVo = (MaintenanceMachineVTVo)vo;
            StringBuilder          sql  = new StringBuilder();


            sql.Append("Delete From t_vt_maintenance");
            sql.Append(" Where	");
            sql.Append(" machine_serial = :machine_serial ;");


            DbCommandAdaptor sqlCommandAdapter = base.GetDbCommandAdaptor(trxContext, sql.ToString());

            //create parameter
            DbParameterList sqlParameter = sqlCommandAdapter.CreateParameterList();

            sqlParameter.AddParameter("machine_serial", inVo.MachineSerial);

            MaintenanceMachineVTVo outVo = new MaintenanceMachineVTVo {
                AffectedCount = sqlCommandAdapter.ExecuteNonQuery(sqlParameter)
            };

            return(outVo);
        }
コード例 #10
0
        public override ValueObject Execute(TransactionContext trxContext, ValueObject vo)
        {
            MaintenanceMachineVTVo inVo = (MaintenanceMachineVTVo)vo;
            StringBuilder          sql  = new StringBuilder();
            ValueObjectList <MaintenanceMachineVTVo> voList = new ValueObjectList <MaintenanceMachineVTVo>();
            //create command
            DbCommandAdaptor sqlCommandAdapter = base.GetDbCommandAdaptor(trxContext, sql.ToString());

            //create parameter
            DbParameterList sqlParameter = sqlCommandAdapter.CreateParameterList();

            sql.Append(@"select a.maintenance_id,  a.machine_model, a.machine_serial, a.start_day, a.month_repeat, a.check_status, a.registration_user_cd, 
                        a.registration_date_time, a.factory_cd, b.machine_name, b.machine_suppiler, b.machine_status, b.machine_qty, b.rfid_cd, b.machine_location
                         from t_vt_maintenance a 
                          left join t_vt_machine b on a.machine_serial = b.machine_serial where 1=1 ");

            if (!String.IsNullOrEmpty(inVo.RFId))
            {
                sql.Append(@" and   b.rfid_cd  =:rfid_cd");
                sqlParameter.AddParameterString("rfid_cd", inVo.RFId);
            }

            if (!String.IsNullOrEmpty(inVo.MachineSerial))
            {
                sql.Append(" and a.machine_serial  =:machine_serial");
                sqlParameter.AddParameterString("machine_serial", inVo.MachineSerial);
            }
            if (!String.IsNullOrEmpty(inVo.MachineModel))
            {
                sql.Append(" and b.machine_model  =:machine_model");
                sqlParameter.AddParameterString("machine_model", inVo.MachineModel);
            }
            if (!String.IsNullOrEmpty(inVo.MachineSupplier))
            {
                sql.Append(" and b.machine_suppiler  =:machine_suppiler");
                sqlParameter.AddParameterString("machine_suppiler", inVo.MachineSupplier);
            }
            if (!String.IsNullOrEmpty(inVo.MachineLocation))
            {
                sql.Append(" and b.machine_location  =:machine_location");
                sqlParameter.AddParameterString("machine_location", inVo.MachineLocation);
            }
            if (!String.IsNullOrEmpty(inVo.MachineStatus))
            {
                sql.Append(" and b.machine_status  =:machine_status");
                sqlParameter.AddParameterString("machine_status", inVo.MachineStatus);
            }
            sqlCommandAdapter = base.GetDbCommandAdaptor(trxContext, sql.ToString());

            //execute SQL
            IDataReader dataReader = sqlCommandAdapter.ExecuteReader(trxContext, sqlParameter);

            while (dataReader.Read())
            {
                MaintenanceMachineVTVo outVo = new MaintenanceMachineVTVo
                {
                    MainternanceId  = int.Parse(dataReader["maintenance_id"].ToString()),
                    RFId            = dataReader["rfid_cd"].ToString(),
                    MachineName     = dataReader["machine_name"].ToString(),
                    MachineSerial   = dataReader["machine_serial"].ToString(),
                    MachineModel    = dataReader["machine_model"].ToString(),
                    MachineLocation = dataReader["machine_location"].ToString(),
                    MachineSupplier = dataReader["machine_suppiler"].ToString(),
                    MachineStatus   = dataReader["machine_status"].ToString(),

                    StartDay    = DateTime.Parse(dataReader["start_day"].ToString()),
                    MonthRepeat = int.Parse(dataReader["month_repeat"].ToString()),
                    CheckStatus = bool.Parse(dataReader["check_status"].ToString()),

                    RegistrationUserCode = dataReader["registration_user_cd"].ToString(),
                    RegistrationDateTime = DateTime.Parse(dataReader["registration_date_time"].ToString()),
                    FactoryCode          = dataReader["factory_cd"].ToString()
                };
                voList.add(outVo);
            }
            dataReader.Close();
            return(voList);
        }