Ejemplo n.º 1
0
        protected void lvPRMMaterialReceive_ItemCommand(object sender, ListViewCommandEventArgs e)
        {
            Int64 MaterialReceiveID;

            Int64.TryParse(e.CommandArgument.ToString(), out MaterialReceiveID);

            if (MaterialReceiveID > 0)
            {
                if (string.Equals(e.CommandName, "DeleteItem"))
                {
                    try
                    {
                        Int64 result = -1;

                        String fe = SqlExpressionBuilder.PrepareFilterExpression(PRMMaterialReceiveEntity.FLD_NAME_MaterialReceiveID, MaterialReceiveID.ToString(), SQLMatchType.Equal);

                        PRMMaterialReceiveEntity pRMMaterialReceiveEntity = new PRMMaterialReceiveEntity();


                        result = FCCPRMMaterialReceive.GetFacadeCreate().Delete(pRMMaterialReceiveEntity, fe, DatabaseOperationType.Delete, TransactionRequired.No);

                        if (result == 0)
                        {
                            _MaterialReceiveID        = 0;
                            _PRMMaterialReceiveEntity = new PRMMaterialReceiveEntity();
                            PrepareInitialView();
                            BindPRMMaterialReceiveList();

                            MiscUtil.ShowMessage(lblMessage, "Material Receive has been successfully deleted.", true);
                        }
                        else
                        {
                            MiscUtil.ShowMessage(lblMessage, "Failed to delete Material Receive.", true);
                        }
                    }
                    catch (Exception ex)
                    {
                        MiscUtil.ShowMessage(lblMessage, ex.Message, true);
                    }
                }
                else if (string.Equals(e.CommandName, "ResetAP"))
                {
                    try
                    {
                        #region Approval Process

                        Boolean apResult = APRobot.ResetApprovalProcessForMRR(MaterialReceiveID);

                        if (apResult == true)
                        {
                            MiscUtil.ShowMessage(lblMessage, "Approval Process has been reset successfully.", UIConstants.MessageType.GREEN);
                        }
                        else
                        {
                            MiscUtil.ShowMessage(lblMessage, "Failed to reset approval process.", UIConstants.MessageType.RED);
                        }

                        BindList();

                        #endregion
                    }
                    catch (Exception ex)
                    {
                        MiscUtil.ShowMessage(lblMessage, ex.Message, true);
                    }
                }
            }
        }