public override ValueObject Execute(TransactionContext trxContext, ValueObject vo)
        {
            InvertoryVo   inVo = (InvertoryVo)vo;
            StringBuilder sql  = new StringBuilder();

            sql.Append("update m_invertory_time set invertory_time_cd=:invertory_time_cd,invertory_time_name=:invertory_time_name");
            sql.Append(" where invertory_time_id =:invertory_time_id");

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

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

            sqlParameter.AddParameterString("invertory_time_cd", inVo.InvertoryTimeCode);
            sqlParameter.AddParameterString("invertory_time_name", inVo.InvertoryTimeName);
            sqlParameter.AddParameterInteger("invertory_time_id", inVo.InvertoryTimeId);
            sqlParameter.AddParameterString("factory_cd", inVo.FactoryCode);
            sqlParameter.AddParameterString("registration_user_cd", inVo.RegistrationUserCode);
            //execute SQL

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

            return(outVo);
        }
Example #2
0
        public override ValueObject Execute(TransactionContext trxContext, ValueObject vo)
        {
            InvertoryVo   inVo     = (InvertoryVo)vo;
            StringBuilder sql      = new StringBuilder();
            InvertoryVo   voNOList = new InvertoryVo();
            //create command
            DbCommandAdaptor sqlCommandAdapter = base.GetDbCommandAdaptor(trxContext, sql.ToString());

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

            sql.Append(@"select count(*) as RowCount from t_invertory_equipments where ");
            sql.Append(" warehouse_main_id  =:warehouse_main_id");
            sqlParameter.AddParameterInteger("warehouse_main_id", inVo.WarehouseMainId);
            sql.Append(" and  invertory_time_id  =:invertory_time_id");
            sqlParameter.AddParameterInteger("invertory_time_id", inVo.InvertoryTimeId);

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

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

            while (dataReader.Read())
            {
                InvertoryVo outVo = new InvertoryVo
                {
                    AffectedCount = Convert.ToInt32(dataReader["RowCount"].ToString()),
                };
                voNOList.AffectedCount = outVo.AffectedCount;
            }
            dataReader.Close();
            return(voNOList);
        }
Example #3
0
        private void GridBind()
        {
            InvertoryTimeDetails_dgv.DataSource = null;
            try
            {
                InvertoryVo vo = new InvertoryVo
                {
                    InvertoryTimeCode = InvertoryTimeCode_txt.Text,
                    InvertoryTimeName = InvertoryTimeName_txt.Text
                };

                ValueObjectList <InvertoryVo> volist = (ValueObjectList <InvertoryVo>)DefaultCbmInvoker.Invoke(new GetInvertoryTimeCbm(), vo);
                if (volist.GetList() != null && volist.GetList().Count > 0)
                {
                    InvertoryTimeDetails_dgv.AutoGenerateColumns = false;
                    BindingSource bindingsource = new BindingSource(volist.GetList(), null);
                    InvertoryTimeDetails_dgv.DataSource = bindingsource;
                }
                else
                {
                    messageData = new MessageData("mmci00006", Properties.Resources.mmci00006, null);
                    logger.Info(messageData);
                    popUpMessage.Information(messageData, Text);
                }
                InvertoryTimeDetails_dgv.ClearSelection();
                Update_btn.Enabled = false;
                Delete_btn.Enabled = false;
            }
            catch (Framework.ApplicationException exception)
            {
                popUpMessage.ApplicationError(exception.GetMessageData(), Text);
                logger.Error(exception.GetMessageData());
            }
        }
        public override ValueObject Execute(TransactionContext trxContext, ValueObject vo)
        {
            InvertoryVo   inVo = (InvertoryVo)vo;
            StringBuilder sql  = new StringBuilder();

            sql.Append("update  t_account_main set invertory_time_id =:invertory_time_id where account_main_id =:account_main_id");

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

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

            sqlParameter.AddParameterInteger("account_main_id", inVo.AccountMainId);
            sqlParameter.AddParameterInteger("invertory_time_id", inVo.InvertoryTimeId);


            //execute SQL

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

            return(outVo);
        }
Example #5
0
        void GridBind()
        {
            InvertoryVo inVo = new InvertoryVo()
            {
                AssetCode         = assetcodetrim,
                InvertoryTimeCode = InvertoryTimeCode_cbm.Text,
                NowLocation       = location_cbm.Text,
            };

            try
            {
                ValueObjectList <InvertoryVo> listvo = (ValueObjectList <InvertoryVo>)DefaultCbmInvoker.Invoke(new Cbm.SearchInvertoryCheckCbm(), inVo);
                InvertoryCheck_dgv.DataSource = listvo.GetList();
            }
            catch (Framework.ApplicationException exception)
            {
                popUpMessage.ApplicationError(exception.GetMessageData(), Text);
                logger.Error(exception.GetMessageData());
            }
            if (InvertoryCheck_dgv.RowCount > 0)
            {
                for (int i = 0; i < InvertoryCheck_dgv.RowCount; i++)
                {
                    if (InvertoryCheck_dgv.Rows[i].Cells["colBeforeLocation"].Value.ToString() != InvertoryCheck_dgv.Rows[i].Cells["colNowLocation"].Value.ToString())
                    {
                        InvertoryCheck_dgv.Rows[i].DefaultCellStyle.BackColor = Color.Red;
                    }
                }
            }
            if (thongbao >= 1)
            {
                MessageBox.Show(mess, "", MessageBoxButtons.OK);
                thongbao = 0;
            }
        }
Example #6
0
 private void update_btn_Click(object sender, EventArgs e)
 {
     for (int i = 0; i < InvertoryCheck_dgv.RowCount; i++)
     {
         //colRankNameNow
         DataGridViewComboBoxCell cell = InvertoryCheck_dgv.Rows[i].Cells["colRankNameNow"] as DataGridViewComboBoxCell;
         if (cell.Value != null)
         {
             InvertoryVo outVo = new InvertoryVo();
             InvertoryVo inVo  = new InvertoryVo()
             {
                 AssetId     = int.Parse(InvertoryCheck_dgv.Rows[i].Cells["colAssetId"].Value.ToString()),
                 RankNameNow = cell.Value.ToString(),
             };
             outVo = (InvertoryVo)DefaultCbmInvoker.Invoke(new UpdateWHInvertoryRankCbm(), inVo);
             outVo = (InvertoryVo)DefaultCbmInvoker.Invoke(new UpdateACCInvertoryRankCbm(), inVo);
             if (i == InvertoryCheck_dgv.RowCount - 1)
             {
                 if (outVo.AffectedCount == 1)
                 {
                     if (MessageBox.Show("Update Finish !", "Update", MessageBoxButtons.OK) == DialogResult.OK)
                     {
                         Search_btn_Click(sender, e);
                     }
                 }
             }
         }
     }
     asset_Code_cmb.Select();
 }
Example #7
0
        public override ValueObject Execute(TransactionContext trxContext, ValueObject vo)
        {
            InvertoryVo   inVo = (InvertoryVo)vo;
            StringBuilder sql  = new StringBuilder();

            sql.Append("update  t_warehouse_main set rank_id = (select rank_id from m_rank where rank_name = :rank_name) where asset_id =:asset_id");

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

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

            sqlParameter.AddParameterInteger("asset_id", inVo.AssetId);
            sqlParameter.AddParameter("rank_name", inVo.RankNameNow);


            //execute SQL

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

            return(outVo);
        }
Example #8
0
        private void BindUpdateCavityData()
        {
            int selectedrowindex = InvertoryTimeDetails_dgv.SelectedCells[0].RowIndex;

            InvertoryVo vo = (InvertoryVo)InvertoryTimeDetails_dgv.Rows[selectedrowindex].DataBoundItem;

            AddInvertoryTimeForm addform = new AddInvertoryTimeForm();

            addform.vo = vo;
            addform.ShowDialog();
            if (addform.IntSuccess > 0)
            {
                messageData = new MessageData("mmci00002", Properties.Resources.mmci00002, null);
                logger.Info(messageData);
                popUpMessage.Information(messageData, Text);

                GridBind();
            }
            else if (addform.IntSuccess == 0)
            {
                messageData = new MessageData("mmci00007", Properties.Resources.mmci00007, null);
                logger.Info(messageData);
                popUpMessage.Information(messageData, Text);
                GridBind();
            }
        }
Example #9
0
        public override ValueObject Execute(TransactionContext trxContext, ValueObject vo)
        {
            InvertoryVo   inVo = (InvertoryVo)vo;
            StringBuilder sql  = new StringBuilder();

            sql.Append("insert into t_invertory_equipments(warehouse_main_id, location_id, invertory_time_id,invertory_value, registration_user_cd, registration_date_time, factory_cd) ");
            sql.Append("values(:warehouse_main_id,:location_id,:invertory_time_id,:invertory_value, :registration_user_cd,now(),:factory_cd)");

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

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

            sqlParameter.AddParameterInteger("warehouse_main_id", inVo.WarehouseMainId);
            sqlParameter.AddParameterInteger("invertory_time_id", inVo.InvertoryTimeId);
            sqlParameter.AddParameter("invertory_value", bool.Parse(inVo.InvertoryValue.ToString()));
            sqlParameter.AddParameterString("factory_cd", inVo.FactoryCode);
            sqlParameter.AddParameterString("registration_user_cd", inVo.RegistrationUserCode);
            sqlParameter.AddParameterInteger("location_id", inVo.LocationID);
            //execute SQL

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

            return(outVo);
        }
        public override ValueObject Execute(TransactionContext trxContext, ValueObject vo)
        {
            InvertoryVo   inVo = (InvertoryVo)vo;
            StringBuilder sql  = new StringBuilder();
            ValueObjectList <InvertoryVo> voList = new ValueObjectList <InvertoryVo>();
            DbCommandAdaptor sqlCommandAdapter   = base.GetDbCommandAdaptor(trxContext, string.Empty);
            DbParameterList  sqlParameter        = sqlCommandAdapter.CreateParameterList();

            sql.Append("select invertory_time_id, invertory_time_cd, invertory_time_name, registration_user_cd,registration_date_time,factory_cd from  m_invertory_time");
            sql.Append(" Where 1=1 ");
            if (!String.IsNullOrEmpty(inVo.FactoryCode))
            {
                sql.Append(" and factory_cd = :factory_cd ");
                sqlParameter.AddParameterString("factory_cd", inVo.FactoryCode);
            }
            if (inVo.InvertoryTimeId > 0)
            {
                sql.Append(" and invertory_time_id = :invertory_time_id ");
                sqlParameter.AddParameterInteger("invertory_time_id", inVo.InvertoryTimeId);
            }
            if (!string.IsNullOrEmpty(inVo.InvertoryTimeCode))
            {
                sql.Append(" and invertory_time_cd = :invertory_time_cd ");
                sqlParameter.AddParameterString("invertory_time_cd", inVo.InvertoryTimeCode);
            }
            if (!string.IsNullOrEmpty(inVo.InvertoryTimeName))
            {
                sql.Append(" and invertory_time_name = :invertory_time_name ");
                sqlParameter.AddParameterString("invertory_time_name", inVo.InvertoryTimeName);
            }

            sql.Append(" order by invertory_time_id desc ");
            //create command
            //DbCommandAdaptor
            sqlCommandAdapter = base.GetDbCommandAdaptor(trxContext, sql.ToString());

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

            while (dataReader.Read())
            {
                InvertoryVo outVo = new InvertoryVo
                {
                    InvertoryTimeCode = dataReader["invertory_time_cd"].ToString(),
                    InvertoryTimeId   = int.Parse(dataReader["invertory_time_id"].ToString()),
                    InvertoryTimeName = dataReader["invertory_time_name"].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);
        }
        public override ValueObject Execute(TransactionContext trxContext, ValueObject vo)
        {
            InvertoryVo      inVo = (InvertoryVo)vo;
            StringBuilder    sql  = new StringBuilder();
            DbCommandAdaptor sqlCommandAdapter = base.GetDbCommandAdaptor(trxContext, string.Empty);
            DbParameterList  sqlParameter      = sqlCommandAdapter.CreateParameterList();

            sql.Append("delete from  m_invertory_time Where 1=1 ");
            if (!String.IsNullOrEmpty(inVo.FactoryCode))
            {
                sql.Append(" and factory_cd = :factory_cd ");
                sqlParameter.AddParameterString("factory_cd", inVo.FactoryCode);
            }
            if (inVo.InvertoryTimeId > 0)
            {
                sql.Append(" and invertory_time_id = :invertory_time_id ");
                sqlParameter.AddParameterInteger("invertory_time_id", inVo.InvertoryTimeId);
            }
            if (!string.IsNullOrEmpty(inVo.InvertoryTimeCode))
            {
                sql.Append(" and invertory_time_cd = :invertory_time_cd ");
                sqlParameter.AddParameterString("invertory_time_cd", inVo.InvertoryTimeCode);
            }
            if (!string.IsNullOrEmpty(inVo.InvertoryTimeName))
            {
                sql.Append(" and invertory_time_name = :invertory_time_name ");
                sqlParameter.AddParameterString("invertory_time_name", inVo.InvertoryTimeName);
            }



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


            //execute SQL

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

            return(outVo);
        }
        private bool checkdate()
        {
            if (InvertoryTimeCode_txt.Text.Trim().Length == 0)
            {
                messageData = new MessageData("mmcc00005", Properties.Resources.mmcc00005, InvertoryTimeCode_lbl.Text);
                popUpMessage.Warning(messageData, Text);
                InvertoryTimeCode_txt.Focus();
                return(false);
            }
            if (InvertoryTimeName_txt.Text.Trim().Length == 0)
            {
                messageData = new MessageData("mmcc00005", Properties.Resources.mmcc00005, InvertoryTimeName_lbl.Text);
                popUpMessage.Warning(messageData, Text);
                InvertoryTimeName_txt.Focus();
                return(false);
            }
            InvertoryTimeCode_txt.Text = InvertoryTimeCode_txt.Text.Trim();
            InvertoryTimeName_txt.Text = InvertoryTimeName_txt.Text.Trim();
            InvertoryVo outVo = new InvertoryVo(),
                        inVo  = new InvertoryVo {
                InvertoryTimeId = vo.InvertoryTimeId, InvertoryTimeCode = InvertoryTimeCode_txt.Text
            };

            try
            {
                outVo = (InvertoryVo)DefaultCbmInvoker.Invoke(new CheckInvertoryTimeCbm(), inVo);
                if (outVo.AffectedCount > 0)
                {
                    messageData = new MessageData("mmcc00006", Properties.Resources.mmcc00006, InvertoryTimeCode_lbl.Text);
                    popUpMessage.Warning(messageData, Text);
                    InvertoryTimeCode_txt.Focus();
                    return(false);
                }
            }
            catch (Com.Nidec.Mes.Framework.ApplicationException exception)
            {
                popUpMessage.ApplicationError(exception.GetMessageData(), Text);
                logger.Error(exception.GetMessageData());
                return(false);
            }
            return(true);
        }
Example #13
0
        private void Delete_btn_Click(object sender, EventArgs e)
        {
            if (InvertoryTimeDetails_dgv.SelectedRows.Count > 0)
            {
                int selectedrowindex = InvertoryTimeDetails_dgv.SelectedCells[0].RowIndex;

                InvertoryVo vo = (InvertoryVo)InvertoryTimeDetails_dgv.Rows[selectedrowindex].DataBoundItem;

                messageData = new MessageData("mmcc00004", Properties.Resources.mmcc00004, vo.InvertoryTimeCode);
                logger.Info(messageData);
                DialogResult dialogResult = popUpMessage.ConfirmationOkCancel(messageData, Text);

                if (dialogResult == DialogResult.OK)
                {
                    try
                    {
                        InvertoryVo outVo = (InvertoryVo)DefaultCbmInvoker.Invoke(new DeleteInvertoryTimeCbm(), vo);

                        if (outVo.AffectedCount > 0)
                        {
                            messageData = new MessageData("mmci00003", Properties.Resources.mmci00003, null);
                            logger.Info(messageData);
                            popUpMessage.Information(messageData, Text);

                            GridBind();
                        }
                        else if (outVo.AffectedCount == 0)
                        {
                            messageData = new MessageData("mmci00007", Properties.Resources.mmci00007, null);
                            logger.Info(messageData);
                            popUpMessage.Information(messageData, Text);
                            GridBind();
                        }
                    }
                    catch (Com.Nidec.Mes.Framework.ApplicationException exception)
                    {
                        popUpMessage.ApplicationError(exception.GetMessageData(), Text);
                        logger.Error(exception.GetMessageData());
                    }
                }
            }
        }
Example #14
0
        public override ValueObject Execute(TransactionContext trxContext, ValueObject vo)
        {
            InvertoryVo      inVo = (InvertoryVo)vo;
            StringBuilder    sql  = new StringBuilder();
            DbCommandAdaptor sqlCommandAdapter = base.GetDbCommandAdaptor(trxContext, string.Empty);
            DbParameterList  sqlParameter      = sqlCommandAdapter.CreateParameterList();

            sql.Append("Select Count(*) as InvertoryCount ");
            sql.Append(" from  m_invertory_time");
            sql.Append(" Where 1=1 ");

            if (!String.IsNullOrEmpty(inVo.FactoryCode))
            {
                sql.Append(" and factory_cd = :factory_cd ");
                sqlParameter.AddParameterString("factory_cd", inVo.FactoryCode);
            }
            if (!string.IsNullOrEmpty(inVo.InvertoryTimeCode))
            {
                sql.Append(" and UPPER(invertory_time_cd) = UPPER(:invertory_time_cd) ");
                sqlParameter.AddParameterString("invertory_time_cd", inVo.InvertoryTimeCode);
            }
            if (inVo.InvertoryTimeId > 0)
            {
                sql.Append(" and invertory_time_id != :invertory_time_id "); ///?????
                sqlParameter.AddParameterInteger("invertory_time_id", inVo.InvertoryTimeId);
            }


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

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

            while (dataReader.Read())
            {
                outVo.AffectedCount = Convert.ToInt32(dataReader["InvertoryCount"].ToString());
            }
            dataReader.Close();
            return(outVo);
        }
 private void Ok_btn_Click(object sender, EventArgs e)
 {
     if (checkdate())
     {
         InvertoryVo outvo = new InvertoryVo();
         InvertoryVo invo  = new InvertoryVo
         {
             InvertoryTimeId      = vo.InvertoryTimeId,
             InvertoryTimeCode    = InvertoryTimeCode_txt.Text,
             InvertoryTimeName    = InvertoryTimeName_txt.Text,
             FactoryCode          = UserData.GetUserData().FactoryCode,
             RegistrationUserCode = UserData.GetUserData().UserCode
         };
         try
         {
             if (invo.InvertoryTimeId > 0)
             {
                 outvo = (InvertoryVo)DefaultCbmInvoker.Invoke(new UpdateInvertoryTimeCbm(), invo);
             }
             else
             {
                 outvo = (InvertoryVo)DefaultCbmInvoker.Invoke(new AddInvertoryTimeCbm(), invo);
             }
         }
         catch (Framework.ApplicationException exception)
         {
             popUpMessage.ApplicationError(exception.GetMessageData(), Text);
             logger.Error(exception.GetMessageData());
             return;
         }
         if ((IntSuccess > 0) || (IntSuccess == 0))
         {
             this.DialogResult = DialogResult.OK;
             this.Close();
         }
         messageData = new MessageData("mmce00001", Properties.Resources.mmce00001, InvertoryTimeCode_lbl.Text + " : " + InvertoryTimeCode_txt.Text);
         logger.Info(messageData);
         popUpMessage.Information(messageData, Text);
         return;
     }
 }
Example #16
0
        public override ValueObject Execute(TransactionContext trxContext, ValueObject vo)
        {
            InvertoryVo   inVo = (InvertoryVo)vo;
            StringBuilder sql  = new StringBuilder();
            //create command
            DbCommandAdaptor sqlCommandAdapter = base.GetDbCommandAdaptor(trxContext, sql.ToString());

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

            sql.Append(@"select max(invertory_time_id) maxid from m_invertory_time ");
            sqlCommandAdapter = base.GetDbCommandAdaptor(trxContext, sql.ToString());

            //IDataReader dataReader = sqlCommandAdapter.ExecuteScalar(sqlParameter);

            InvertoryVo outVo = new InvertoryVo
            {
                InvertoryTimeId = int.Parse(sqlCommandAdapter.ExecuteScalar(sqlParameter).ToString()),
            };

            //dataReader.Close();
            return(outVo);
        }
Example #17
0
        void addandupdate()
        {
            InvertoryVo checkvo = new InvertoryVo();

            asset_Code_cmb.Select();
            InvertoryCheck_dgv.DataSource = null;

            string str = asset_Code_cmb.Text;

            string[] arrListStr = str.Split(',');
            assetcodetrim = arrListStr[0];
            //sua lai, doi warehouse va accout id thanh asset_id
            //sua database t_invertory_equipments doi warehouse id thanh asset_id
            ValueObjectList <WareHouseMainVo> Wlistvo = (ValueObjectList <WareHouseMainVo>)DefaultCbmInvoker.Invoke(new Cbm.GetWarehouseMainIdCbm(), new WareHouseMainVo()
            {
                AssetCode = assetcodetrim,
            });
            List <WareHouseMainVo> Wlist = Wlistvo.GetList();

            ValueObjectList <AccountMainVo> alistvo = (ValueObjectList <AccountMainVo>)DefaultCbmInvoker.Invoke(new Cbm.GetAccountMainIdCbm(), new AccountMainVo()
            {
                AssetCode = assetcodetrim,
            });
            List <AccountMainVo> alist = alistvo.GetList();

            if (checkdata())
            {
                for (int i = 0; i < Wlist.Count; i++)
                {
                    WareHouseMainVo w     = Wlist[i];
                    AccountMainVo   a     = alist[i];
                    InvertoryVo     outVo = new InvertoryVo();
                    InvertoryVo     inVo  = new InvertoryVo()
                    {
                        WarehouseMainId      = w.WareHouseMainId,
                        AccountMainId        = a.AcountMainId,
                        InvertoryTimeId      = ((InvertoryVo)this.InvertoryTimeCode_cbm.SelectedItem).InvertoryTimeId,
                        InvertoryValue       = true,
                        RegistrationUserCode = UserData.GetUserData().UserName,
                        FactoryCode          = UserData.GetUserData().FactoryCode,
                        LocationID           = ((LocationVo)this.location_cbm.SelectedItem).LocationId,
                        //  RankID = ((RankVo)this.rank_name_cbm.SelectedItem).RankId,
                    };
                    try
                    {
                        checkvo = (InvertoryVo)DefaultCbmInvoker.Invoke(new CheckInvertoryRowCbm(), inVo);

                        if (checkvo.AffectedCount == 1)
                        {
                            mess += assetcodetrim + " is checked into " + InvertoryTimeCode_cbm.Text + "\n";
                            //if(i == Wlist.Count -1)
                            //{
                            //    MessageBox.Show(mess, "Info", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            //}
                            //MessageBox.Show("This machine:" + assetcodetrim + " is checked into " + InvertoryTimeCode_cbm.Text, "Messager", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            thongbao++;
                        }
                        if (checkvo.AffectedCount == 0)
                        {
                            outVo = (InvertoryVo)DefaultCbmInvoker.Invoke(new AddInvertoryCheckCbm(), inVo);
                            outVo = (InvertoryVo)DefaultCbmInvoker.Invoke(new UpdateWHInvertoryCheckCbm(), inVo);
                            outVo = (InvertoryVo)DefaultCbmInvoker.Invoke(new UpdateACCInvertoryCheckCbm(), inVo);
                            //    outVo = (InvertoryVo)DefaultCbmInvoker.Invoke(new UpdateACCRankCheckCbm(), inVo);
                        }
                    }
                    catch (Framework.ApplicationException exception)
                    {
                        popUpMessage.ApplicationError(exception.GetMessageData(), Text);
                        logger.Error(exception.GetMessageData());
                    }
                }


                if (test == "b")
                {
                    colRankNameNowTextBox.Visible = false;
                    colRankNameNow.Visible        = true;
                    ValueObjectList <RankVo> rankcode = (ValueObjectList <RankVo>)DefaultCbmInvoker.Invoke(new GetRankCbm(), new RankVo());
                    colRankNameNow.DisplayMember = "RankName";
                    colRankNameNow.DataSource    = rankcode.GetList();
                }
                else
                {
                    assetcodetrim = "";
                }
            }
        }
Example #18
0
        private void Inventory_Offline_btn_Click(object sender, EventArgs e)
        {
            if (location_cbm.Text != "" && InvertoryTimeCode_cbm.Text != "")
            {
                thongbao = 0;
                test     = "a";
                Excel.Application xlApp       = new Excel.Application();
                Excel.Workbook    xlWorkbook  = xlApp.Workbooks.Open(linksave_txt.Text);
                Excel._Worksheet  xlWorksheet = xlWorkbook.Sheets[1];
                Excel.Range       xlRange     = xlWorksheet.UsedRange;

                int rowCount = xlRange.Rows.Count;
                int colCount = xlRange.Columns.Count;
                int dem      = 0;
                for (int i = 2; i <= rowCount; i++)
                {
                    if (xlRange.Cells[i, 1] != null && xlRange.Cells[i, 1].Value != null && InvertoryTimeCode_cbm.Text != "")
                    {
                        asset_Code_cmb.Text = (xlRange.Cells[i, 1].Value.ToString()).Substring(0, 10);
                        addandupdate();
                        GridBind();
                        colRankNameNowTextBox.Visible = true;
                        colRankNameNow.Visible        = false;
                    }
                    if (InvertoryCheck_dgv.RowCount > 0)
                    {
                        for (int j = dem; j < InvertoryCheck_dgv.RowCount; j++)
                        {
                            ValueObjectList <RankVo> rankcode = (ValueObjectList <RankVo>)DefaultCbmInvoker.Invoke(new GetRankCbm(), new RankVo()
                            {
                                RankCode = (xlRange.Cells[i, 2].Value.ToString())
                            });
                            List <RankVo> rankname = new List <RankVo>();
                            rankname = rankcode.GetList();

                            InvertoryCheck_dgv.Rows[j].Cells["colRankNameNowTextBox"].Value = rankname[0].RankName;

                            InvertoryVo outVo = new InvertoryVo();
                            InvertoryVo inVo  = new InvertoryVo()
                            {
                                AssetId     = int.Parse(InvertoryCheck_dgv.Rows[j].Cells["colAssetId"].Value.ToString()),
                                RankNameNow = InvertoryCheck_dgv.Rows[j].Cells["colRankNameNowTextBox"].Value.ToString(),
                            };
                            outVo = (InvertoryVo)DefaultCbmInvoker.Invoke(new UpdateWHInvertoryRankCbm(), inVo);
                            outVo = (InvertoryVo)DefaultCbmInvoker.Invoke(new UpdateACCInvertoryRankCbm(), inVo);
                            dem   = dem + 1;
                        }
                    }
                }
                asset_Code_cmb.Text = "";
                // GridBind();
                Search_btn_Click(sender, e);
                GC.Collect(); //can delete
                GC.WaitForPendingFinalizers();

                Marshal.ReleaseComObject(xlRange);
                Marshal.ReleaseComObject(xlWorksheet);

                xlWorkbook.Close();
                Marshal.ReleaseComObject(xlWorkbook);

                xlApp.Quit();
                Marshal.ReleaseComObject(xlApp);
            }
            if (thongbao >= 1)
            {
                MessageBox.Show(mess, "Messager", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            asset_Code_cmb.Select();
        }
Example #19
0
        public override ValueObject Execute(TransactionContext trxContext, ValueObject vo)
        {
            InvertoryVo   inVo = (InvertoryVo)vo;
            StringBuilder sql  = new StringBuilder();
            ValueObjectList <InvertoryVo> voList = new ValueObjectList <InvertoryVo>();
            DbCommandAdaptor sqlCommandAdapter   = base.GetDbCommandAdaptor(trxContext, string.Empty);
            DbParameterList  sqlParameter        = sqlCommandAdapter.CreateParameterList();

            sql.Append(@"select c.asset_id, a.invertory_time_id, a.invertory_time_cd,  a.invertory_time_name,b.invertory_equipments_id,  b.invertory_value, b.registration_user_cd, b.registration_date_time, b.factory_cd, d.asset_cd, d.asset_name, e.location_cd as beforelocation, f.rank_name , g.location_cd as nowlocation, c.warehouse_main_id from t_invertory_equipments b 
                left join m_invertory_time a on b.invertory_time_id = a.invertory_time_id
                 left join t_warehouse_main c on b.warehouse_main_id = c.warehouse_main_id
                left join m_asset d on d.asset_id = c.asset_id
                left join m_location e on e.location_id = c.after_location_id
                left join m_rank f on f.rank_id = c.rank_id
                  left join m_location g on g.location_id = b.location_id
                ");
            sql.Append(" Where 1=1 ");

            if (!string.IsNullOrEmpty(inVo.AssetCode))
            {
                sql.Append(" and d.asset_cd = :asset_cd ");
                sqlParameter.AddParameterString("asset_cd", inVo.AssetCode);
            }
            if (!string.IsNullOrEmpty(inVo.InvertoryTimeCode))
            {
                sql.Append(" and a.invertory_time_cd = :invertory_time_cd ");
                sqlParameter.AddParameterString("invertory_time_cd", inVo.InvertoryTimeCode);
            }
            if (!string.IsNullOrEmpty(inVo.NowLocation))
            {
                sql.Append(" and g.location_cd = :location_cd ");
                sqlParameter.AddParameterString("location_cd", inVo.NowLocation);
            }



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

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

            while (dataReader.Read())
            {
                InvertoryVo outVo = new InvertoryVo
                {
                    InvertoryEquipmentId = int.Parse(dataReader["invertory_equipments_id"].ToString()),
                    AssetCode            = dataReader["asset_cd"].ToString(),
                    AssetName            = dataReader["asset_name"].ToString(),
                    InvertoryValue       = bool.Parse(dataReader["invertory_value"].ToString()),
                    BeforeLocation       = dataReader["beforelocation"].ToString(),
                    NowLocation          = dataReader["nowlocation"].ToString(),
                    RankNameBefore       = dataReader["rank_name"].ToString(),
                    RegistrationUserCode = dataReader["registration_user_cd"].ToString(),
                    RegistrationDateTime = DateTime.Parse(dataReader["registration_date_time"].ToString()),
                    FactoryCode          = dataReader["factory_cd"].ToString(),
                    WarehouseMainId      = int.Parse(dataReader["warehouse_main_id"].ToString()),
                    AssetId = int.Parse(dataReader["asset_id"].ToString()),
                };
                voList.add(outVo);
            }
            dataReader.Close();
            return(voList);
        }
        private void ok_btn_Click(object sender, EventArgs e)
        {
            if (Checkdata())
            {
                InvertoryVo     CheckTimeIdVo = (InvertoryVo)DefaultCbmInvoker.Invoke(new GetMaxCheckTimeIdCbm(), new InvertoryVo());
                WareHouseMainVo outVo1        = new WareHouseMainVo();
                WareHouseMainVo outVo2        = new WareHouseMainVo();
                WareHouseMainVo inVo          = new WareHouseMainVo()
                {
                    WareHouseMainId = WareHouseMainVo.WareHouseMainId,
                    ///
                    BeforeLocationId = ((LocationVo)this.cmbBeforeLocation.SelectedItem).LocationId,
                    DetailPositionId = ((DetailPositionVo)this.cmbDetailPosition.SelectedItem).DetailPositionId,
                    AfterLocationId  = ((LocationVo)this.cmbAfterLocation.SelectedItem).LocationId,
                    AssetId          = ((AssetVo)this.cmbNoNumber.SelectedItem).AssetId,
                    QTY                 = Int16.Parse(txtqty.Text),
                    UnitId              = ((UnitVo)cmbUnit.SelectedItem).UnitId,
                    AssetNo             = Int16.Parse(cmbNoNumber.Text),
                    AccountCodeId       = ((AccountCodeVo)this.cmbAccountCode.SelectedItem).AccountCodeId,
                    AccountLocationId   = ((AccountLocationVo)this.cmbSectionCode.SelectedItem).AccountLocationId,
                    RankId              = ((RankVo)this.cmbRankCode.SelectedItem).RankId,
                    CommnetsData        = txtComment.Text,
                    StartDepreciation   = dtpStartDepreciation.Value,
                    EndDepreciation     = dtpEndDepreciation.Value,
                    CurrentDepreciation = double.Parse(txtCurrentDepreciation.Text),
                    MonthlyDepreciation = double.Parse(txtMonthlyDepreciation.Text),
                    AccumDepreciation   = double.Parse(txtAccumDepreciation.Text),
                    NetValue            = double.Parse(txtNetValue.Text),
                    //  LocationId = ((LocationVo)this.location_cmb.SelectedItem).LocationId,
                    UserLocationId       = ((UserLocationVo)this.cmbUserName.SelectedItem).UserLocationId,
                    RegistrationDateTime = DateTime.Now,
                    FactoryCode          = UserData.GetUserData().FactoryCode,
                    RegistrationUserCode = UserData.GetUserData().UserCode,
                    InvertoryId          = CheckTimeIdVo.InvertoryTimeId,
                };
                try
                {
                    if (inVo.WareHouseMainId > 0)                                                               //update
                    {
                        outVo1 = (WareHouseMainVo)DefaultCbmInvoker.Invoke(new UpdateWareHouseMainCbm(), inVo); //sai
                        outVo2 = (WareHouseMainVo)DefaultCbmInvoker.Invoke(new AddWareHouseHistoryMainCbm(), inVo);
                    }
                    else//add
                    {
                        outVo1 = (WareHouseMainVo)DefaultCbmInvoker.Invoke(new AddWareHouseMainCbm(), inVo);
                        outVo2 = (WareHouseMainVo)DefaultCbmInvoker.Invoke(new AddWareHouseHistoryMainCbm(), inVo);

                        if (outVo1.AffectedCount > 0)
                        {
                            ValueObjectList <WareHouseMainVo> outVoWareHouse = (ValueObjectList <WareHouseMainVo>)DefaultCbmInvoker.Invoke(new GetWarehouseMainIdCbm(), new WareHouseMainVo()
                            {
                                AssetCode = txtAssetCode.Text
                            });

                            InvertoryVo outVoCheckTime = new InvertoryVo();
                            InvertoryVo inVoCheckTime  = new InvertoryVo()
                            {
                                WarehouseMainId      = outVoWareHouse.GetList()[0].WareHouseMainId,
                                InvertoryTimeId      = CheckTimeIdVo.InvertoryTimeId,
                                InvertoryValue       = true,
                                RegistrationUserCode = UserData.GetUserData().UserName,
                                FactoryCode          = UserData.GetUserData().FactoryCode,
                                LocationID           = ((LocationVo)this.cmbAfterLocation.SelectedItem).LocationId,
                            };
                            outVoCheckTime = (InvertoryVo)DefaultCbmInvoker.Invoke(new AddInvertoryCheckCbm(), inVoCheckTime);
                        }
                        cmbUnit.Text      = "";
                        txtAssetCode.Text = "";
                    }
                    AccountMainVo accountOutVo = new AccountMainVo();
                    accountOutVo = (AccountMainVo)DefaultCbmInvoker.Invoke(new UpdateItemAccountMainCbm(), new AccountMainVo()
                    {
                        AssetId = inVo.AssetId, LocationId = inVo.AfterLocationId, RankId = inVo.RankId, UserLocationId = inVo.UserLocationId, RegistrationUserCode = inVo.RegistrationUserCode, RegistrationDateTime = DateTime.Now,
                    });
                }
                catch (Framework.ApplicationException exception)
                {
                    popUpMessage.ApplicationError(exception.GetMessageData(), Text);
                    logger.Error(exception.GetMessageData());
                    return;
                }
                if (outVo1.AffectedCount > 0)
                {
                    messageData = new MessageData("mmce00001", Properties.Resources.mmce00001, asset_code_lbl.Text + " : " + txtAssetCode.Text);
                    logger.Info(messageData);
                    popUpMessage.Information(messageData, Text);
                    return;
                }
                if (outVo2.AffectedCount > 0)
                {
                    messageData = new MessageData("mmce00001", Properties.Resources.mmce00001, asset_code_lbl.Text + " : " + txtAssetCode.Text);
                    logger.Info(messageData);
                    popUpMessage.Information(messageData, Text);

                    return;
                }
            }
        }