Ejemplo n.º 1
0
        /// <summary>
        /// Add new customer line
        /// </summary>
        /// <param name="customerId"></param>
        /// <param name="lineId"></param>
        private int AddCustomerLine(int customerId, int lineId)
        {
            CustomerLineVo prWDefInVo = new CustomerLineVo
            {
                CustomerId = customerId,
                LineId     = lineId,
                //RegistrationDateTime = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"),
                RegistrationUserCode = UserData.GetUserData().UserCode,
                FactoryCode          = UserData.GetUserData().FactoryCode
            };
            CustomerLineVo outVo = null;

            try
            {
                outVo = (CustomerLineVo)base.InvokeCbm(new AddCustomerLineMasterMntCbm(), prWDefInVo, false);
            }
            catch (Framework.ApplicationException exception)
            {
                popUpMessage.ApplicationError(exception.GetMessageData(), Text);
                Logger.Error(exception.GetMessageData());
            }
            if (outVo != null & outVo.AffectedCount > 0)
            {
                return(outVo.AffectedCount);
            }
            return(0);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Fills all user records to gridview control
        /// </summary>
        private void GridBind()
        {
            Customer_dgv.DataSource = null;
            CustomerLineVo outVo = null;
            CustomerLineVo inVo  = new CustomerLineVo();

            inVo.CustomerId = Convert.ToInt32(CustomerLine_cmb.SelectedValue);
            inVo.LineId     = Convert.ToInt32(Line_cmb.SelectedValue);
            try
            {
                outVo = (CustomerLineVo)DefaultCbmInvoker.Invoke(new GetCustomerLineCbm(), inVo);
                Customer_dgv.AutoGenerateColumns = false;
                Customer_dgv.DataSource          = outVo.customerLineListVo;
            }
            catch (Framework.ApplicationException exception)
            {
                popUpMessage.ApplicationError(exception.GetMessageData(), Text);
                logger.Error(exception.GetMessageData());
            }

            BindingSource CustomerLineBindingSource = new BindingSource(outVo.customerLineListVo, null);

            if (CustomerLineBindingSource.Count == 0)
            {
                messageData = new MessageData("mmci00006", Properties.Resources.mmci00006);
                logger.Info(messageData);
                popUpMessage.Information(messageData, Text);
                return;
            }
            Customer_dgv.ClearSelection();
        }
Ejemplo n.º 3
0
        public override ValueObject Execute(TransactionContext trxContext, ValueObject arg)
        {
            CustomerLineVo inVo = (CustomerLineVo)arg;

            StringBuilder sqlQuery = new StringBuilder();

            sqlQuery.Append("Delete From m_customer_line");
            sqlQuery.Append(" Where	");
            sqlQuery.Append(" line_id = :lineid ");
            sqlQuery.Append(" and factory_cd = :factorycode ");
            if (inVo.CustomerId > 0)
            {
                sqlQuery.Append(" and customer_id = :customerid");
            }

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

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

            sqlParameter.AddParameterInteger("lineid", inVo.LineId);
            sqlParameter.AddParameterString("factorycode", UserData.GetUserData().FactoryCode);
            if (inVo.CustomerId > 0)
            {
                sqlParameter.AddParameterInteger("customerid", inVo.CustomerId);
            }

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

            return(outVo);
        }
Ejemplo n.º 4
0
        public override ValueObject Execute(TransactionContext trxContext, ValueObject arg)
        {
            CustomerLineVo inVo  = (CustomerLineVo)arg;
            CustomerLineVo outVo = new CustomerLineVo();

            StringBuilder sqlQuery = new StringBuilder();

            sqlQuery.Append("Insert into m_customer_line");
            sqlQuery.Append(" ( ");
            sqlQuery.Append(" customer_id, ");
            sqlQuery.Append(" line_id, ");
            sqlQuery.Append(" registration_user_cd, ");
            sqlQuery.Append(" registration_date_time, ");
            sqlQuery.Append(" factory_cd ");
            sqlQuery.Append(" ) ");
            sqlQuery.Append("VALUES	");
            sqlQuery.Append(" ( ");
            sqlQuery.Append(" :customerid ,");
            sqlQuery.Append(" :lineid ,");
            sqlQuery.Append(" :registrationusercd ,");
            sqlQuery.Append(" :registrationdatetime ,");
            sqlQuery.Append(" :factorycode ");
            sqlQuery.Append(" ); ");


            foreach (CustomerLineVo curVo in inVo.customerLineListVo)
            {
                //create command
                DbCommandAdaptor sqlCommandAdapter = base.GetDbCommandAdaptor(trxContext, sqlQuery.ToString());

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

                sqlParameter.AddParameterInteger("customerid", curVo.CustomerId);
                sqlParameter.AddParameterInteger("lineid", inVo.LineId);
                sqlParameter.AddParameterString("registrationusercd", UserData.GetUserData().UserCode);
                sqlParameter.AddParameterDateTime("registrationdatetime", trxContext.ProcessingDBDateTime);
                sqlParameter.AddParameterString("factorycode", UserData.GetUserData().FactoryCode);

                outVo.AffectedCount += sqlCommandAdapter.ExecuteNonQuery(sqlParameter);
            }

            return(outVo);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Delete customer line
        /// </summary>
        /// <param name="customerId"></param>
        /// <param name="lineId"></param>
        private int DeleteCustomerLine(int customerId, int lineId)
        {
            CustomerLineVo delInVo = new CustomerLineVo
            {
                CustomerId = customerId,
                LineId     = lineId
            };
            CustomerLineVo delOutVo = null;

            try
            {
                delOutVo = (CustomerLineVo)base.InvokeCbm(new DeleteCustomerLineMasterMntCbm(), delInVo, false);
            }
            catch (Framework.ApplicationException exception)
            {
                popUpMessage.ApplicationError(exception.GetMessageData(), Text);
                Logger.Error(exception.GetMessageData());
            }
            if (delOutVo != null && delOutVo.AffectedCount > 0)
            {
                return(delOutVo.AffectedCount);
            }
            return(0);
        }
Ejemplo n.º 6
0
        public override ValueObject Execute(TransactionContext trxContext, ValueObject arg)
        {
            CustomerLineVo inVo = (CustomerLineVo)arg;

            StringBuilder sqlQuery = new StringBuilder();

            sqlQuery.Append("Select");
            sqlQuery.Append(" cl.customer_line_id,");
            sqlQuery.Append(" cl.customer_id,");
            sqlQuery.Append(" cl.line_id,");
            sqlQuery.Append(" c.customer_name,");
            sqlQuery.Append(" l.line_name");
            sqlQuery.Append(" from m_customer_line cl");
            sqlQuery.Append(" inner join m_customer c on cl.customer_id = c.customer_id");
            sqlQuery.Append(" inner join m_line l on cl.line_id = l.line_id");
            sqlQuery.Append(" where cl.factory_cd = :faccd ");

            if (inVo.LineId > 0)
            {
                sqlQuery.Append(" and cl.line_id = :lineid");
            }

            if (inVo.CustomerId > 0)
            {
                sqlQuery.Append(" and cl.customer_id = :customerid");
            }

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

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

            sqlParameter.AddParameterString("faccd", UserData.GetUserData().FactoryCode);
            if (inVo.LineId > 0)
            {
                sqlParameter.AddParameterInteger("lineid", inVo.LineId);
            }

            if (inVo.CustomerId > 0)
            {
                sqlParameter.AddParameterInteger("customerid", inVo.CustomerId);
            }

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

            CustomerLineVo outVo = new CustomerLineVo();

            while (dataReader.Read())
            {
                CustomerLineVo currOutVo = new CustomerLineVo
                {
                    CustomerLineId = Convert.ToInt32(dataReader["customer_line_id"]),
                    LineId         = Convert.ToInt32(dataReader["line_id"]),
                    CustomerId     = Convert.ToInt32(dataReader["customer_id"]),
                    CustomerName   = dataReader["customer_name"].ToString(),
                    LineName       = dataReader["line_name"].ToString()
                };

                outVo.customerLineListVo.Add(currOutVo);
            }

            dataReader.Close();

            return(outVo);
        }
Ejemplo n.º 7
0
        public override ValueObject Execute(TransactionContext trxContext, ValueObject arg)
        {
            CustomerLineVo inVo = (CustomerLineVo)arg;

            StringBuilder sqlQuery = new StringBuilder();

            sqlQuery.Append(" SELECT ");
            sqlQuery.Append("  cl.customer_line_id, ");
            sqlQuery.Append("  c.customer_cd, ");
            sqlQuery.Append("  c.customer_name, ");
            sqlQuery.Append("  l.line_cd, ");
            sqlQuery.Append("  l.line_name ");
            sqlQuery.Append(" FROM ");
            sqlQuery.Append("  m_customer_line cl ");
            sqlQuery.Append("  inner join m_customer c on c.customer_id = cl.customer_id ");
            sqlQuery.Append("  inner join m_line l on l.line_id = cl.line_id ");
            sqlQuery.Append(" WHERE ");
            sqlQuery.Append("  c.factory_cd = :factorycode ");
            if (inVo.CustomerId > 0)
            {
                sqlQuery.Append(" AND c.customer_id = :customerid ");
            }
            if (inVo.LineId > 0)
            {
                sqlQuery.Append(" AND l.line_id = :lineid ");
            }


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

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

            if (!string.IsNullOrEmpty(inVo.FactoryCode))
            {
                sqlParameter.AddParameterString("factorycode", inVo.FactoryCode);
            }
            else
            {
                sqlParameter.AddParameterString("factorycode", UserData.GetUserData().FactoryCode);
            }
            if (inVo.CustomerId > 0)
            {
                sqlParameter.AddParameterInteger("customerid", inVo.CustomerId);
            }
            if (inVo.LineId > 0)
            {
                sqlParameter.AddParameterInteger("lineid", inVo.LineId);
            }

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

            CustomerLineVo outVo = new CustomerLineVo();

            while (dataReader.Read())
            {
                CustomerLineVo currOutVo = new CustomerLineVo();
                currOutVo.CustomerLineId = ConvertDBNull <int>(dataReader, "customer_line_id");
                // currOutVo.CustomerCd = ConvertDBNull<string>(dataReader, "customer_cd");
                currOutVo.CustomerName = ConvertDBNull <string>(dataReader, "customer_name");
                //  currOutVo.LineCd = ConvertDBNull<string>(dataReader, "line_cd");
                currOutVo.LineName = ConvertDBNull <string>(dataReader, "line_name");
                outVo.customerLineListVo.Add(currOutVo);
            }
            dataReader.Close();

            return(outVo);
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Binds tree view
        /// </summary>
        /// <param name="prcWrkList"></param>
        private void PopulateTreeView(List <CustomerVo> prcWrkList)
        {
            LineVo linOutVo = new LineVo();

            try
            {
                linOutVo = (LineVo)base.InvokeCbm(new GetLineMasterMntCbm(), linInVo, false);
            }
            catch (Framework.ApplicationException exception)
            {
                popUpMessage.ApplicationError(exception.GetMessageData(), Text);
                Logger.Error(exception.GetMessageData());
                return;
            }

            CustomerLineDetails_tv.Nodes.Clear();

            TreeNode[] headerNode = new TreeNode[prcWrkList.Count];

            int i = 0;

            foreach (CustomerVo prcW in prcWrkList)
            {
                TreeNode child = new TreeNode
                {
                    Text = prcW.CustomerCode + " " + prcW.CustomerName,
                    Tag  = prcW.CustomerId
                };

                headerNode[i] = child;

                int childNodes = linOutVo.LineListVo.Count;

                TreeNode[] rootNodes = new TreeNode[childNodes];

                int node = 0;

                CustomerLineVo inVo = new CustomerLineVo();
                inVo.CustomerId = Convert.ToInt32(Customer_cmb.SelectedValue);
                CustomerLineVo prcDefRsnOutVo = new CustomerLineVo();

                try
                {
                    prcDefRsnOutVo = (CustomerLineVo)base.InvokeCbm(new GetCustomerLineMasterMntCbm(), inVo, false);
                }
                catch (Framework.ApplicationException exception)
                {
                    popUpMessage.ApplicationError(exception.GetMessageData(), Text);
                    Logger.Error(exception.GetMessageData());
                    return;
                }

                foreach (LineVo dfrVo in linOutVo.LineListVo)
                {
                    TreeNode rootChild = new TreeNode
                    {
                        Text = dfrVo.LineCode + " " + dfrVo.LineName,
                        Tag  = dfrVo.LineId
                    };

                    List <CustomerLineVo> prcDefRsnList = prcDefRsnOutVo.customerLineListVo.Where(t => t.CustomerId == Convert.ToInt32(child.Tag)).ToList();

                    foreach (CustomerLineVo prDfRsnVo in prcDefRsnList)
                    {
                        if (prDfRsnVo.LineId == Convert.ToInt32(rootChild.Tag))
                        {
                            rootChild.Checked = true;
                        }
                    }

                    rootNodes[node] = rootChild;

                    headerNode[i].Nodes.Add(rootNodes[node]);

                    node += 1;
                }

                CustomerLineDetails_tv.Nodes.Add(headerNode[i]);

                i += 1;
            }
            if (CustomerLineDetails_tv.Nodes.Count > 0)
            {
                Update_btn.Enabled = true;
            }
        }
Ejemplo n.º 9
0
        /// <summary>
        /// updates customer line
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Update_btn_Click(object sender, EventArgs e)
        {
            if (CustomerLineDetails_tv.Nodes.Count == 0)
            {
                return;
            }
            int prcDefCount;
            int prcWrkId;
            int defRsnId;
            int resultcnt = 0;

            Cursor.Current = Cursors.WaitCursor;
            TreeNodeCollection nodes = CustomerLineDetails_tv.Nodes;

            CustomerLineVo prcDefCheckVo = new CustomerLineVo();

            try
            {
                prcDefCheckVo = (CustomerLineVo)base.InvokeCbm(new GetCustomerLineMasterMntCbm(), new CustomerLineVo(), false);
            }
            catch (Framework.ApplicationException exception)
            {
                popUpMessage.ApplicationError(exception.GetMessageData(), Text);
                Logger.Error(exception.GetMessageData());
                return;
            }

            foreach (TreeNode tn in nodes)
            {
                foreach (TreeNode child in tn.Nodes)
                {
                    //Check customer line is already added.
                    prcWrkId = Convert.ToInt32(tn.Tag.ToString());

                    defRsnId = Convert.ToInt32(child.Tag.ToString());

                    prcDefCount = prcDefCheckVo.customerLineListVo.Where(t => t.CustomerId == prcWrkId && t.LineId == defRsnId).Count();

                    if (child.Checked)
                    {
                        if (prcDefCount == 0)
                        {
                            resultcnt += AddCustomerLine(prcWrkId, defRsnId);
                        }
                    }
                    else
                    {
                        if (prcDefCount == 1)
                        {
                            resultcnt += DeleteCustomerLine(prcWrkId, defRsnId);
                        }
                    }
                }
            }
            if (resultcnt == 0)
            {
                return;
            }
            Cursor.Current = Cursors.Default;
            messageData    = new MessageData("mmci00002", Properties.Resources.mmci00002, null);
            Logger.Info(messageData);
            popUpMessage.Information(messageData, Text);
        }