private CMConstructionToolEntity BuildCMConstructionToolEntity()
        {
            CMConstructionToolEntity cMConstructionToolEntity = CurrentCMConstructionToolEntity;

            if (ddlConstructionToolCategoryID.Items.Count > 0)
            {
                if (ddlConstructionToolCategoryID.SelectedValue == "0")
                {
                    cMConstructionToolEntity.ConstructionToolCategoryID = null;
                }
                else
                {
                    cMConstructionToolEntity.ConstructionToolCategoryID = Int64.Parse(ddlConstructionToolCategoryID.SelectedValue);
                }
            }

            cMConstructionToolEntity.ToolName = txtToolName.Text.Trim();
            if (ddlUnitID.Items.Count > 0)
            {
                if (ddlUnitID.SelectedValue == "0")
                {
                    cMConstructionToolEntity.UnitID = null;
                }
                else
                {
                    cMConstructionToolEntity.UnitID = Int64.Parse(ddlUnitID.SelectedValue);
                }
            }

            cMConstructionToolEntity.IsRemoved = chkIsRemoved.Checked;


            return(cMConstructionToolEntity);
        }
示例#2
0
        Int64 ICMConstructionToolDataAccess.Add(CMConstructionToolEntity cMConstructionToolEntity, DatabaseOperationType option, TransactionRequired reqTran)
        {
            try
            {
                long retValues = -99;

                switch (reqTran)
                {
                case TransactionRequired.No:
                {
                    retValues = Add(cMConstructionToolEntity, option);
                    break;
                }

                case TransactionRequired.Yes:
                {
                    retValues = AddTran(cMConstructionToolEntity, option);
                    break;
                }

                default:
                {
                    retValues = -99;
                    break;
                }
                }

                return(retValues);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
示例#3
0
        Int64 ICMConstructionToolDataAccess.Delete(CMConstructionToolEntity cMConstructionToolEntity, String filterExpression, DatabaseOperationType option, TransactionRequired reqTran)
        {
            try
            {
                long retValues = -99;

                switch (reqTran)
                {
                case TransactionRequired.No:
                {
                    retValues = Delete(cMConstructionToolEntity, filterExpression, option);
                    break;
                }

                case TransactionRequired.Yes:
                {
                    retValues = DeleteTran(cMConstructionToolEntity, filterExpression, option);
                    break;
                }

                default:
                {
                    retValues = -99;
                    break;
                }
                }

                return(retValues);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        private void SaveCMConstructionToolEntity()
        {
            if (IsValid)
            {
                try
                {
                    CMConstructionToolEntity cMConstructionToolEntity = BuildCMConstructionToolEntity();

                    Int64 result = -1;

                    if (cMConstructionToolEntity.IsNew)
                    {
                        result = FCCCMConstructionTool.GetFacadeCreate().Add(cMConstructionToolEntity, DatabaseOperationType.Add, TransactionRequired.No);
                    }
                    else
                    {
                        String filterExpression = SqlExpressionBuilder.PrepareFilterExpression(CMConstructionToolEntity.FLD_NAME_ConstructionToolID, cMConstructionToolEntity.ConstructionToolID.ToString(), SQLMatchType.Equal);
                        result = FCCCMConstructionTool.GetFacadeCreate().Update(cMConstructionToolEntity, filterExpression, DatabaseOperationType.Update, TransactionRequired.No);
                    }

                    if (result > 0)
                    {
                        _ConstructionToolID       = 0;
                        _CMConstructionToolEntity = new CMConstructionToolEntity();
                        PrepareInitialView();
                        BindCMConstructionToolList();

                        if (cMConstructionToolEntity.IsNew)
                        {
                            MiscUtil.ShowMessage(lblMessage, "Construction Tool Information has been added successfully.", false);
                        }
                        else
                        {
                            MiscUtil.ShowMessage(lblMessage, "Construction Tool Information has been updated successfully.", false);
                        }
                    }
                    else
                    {
                        if (cMConstructionToolEntity.IsNew)
                        {
                            MiscUtil.ShowMessage(lblMessage, "Failed to add Construction Tool Information.", false);
                        }
                        else
                        {
                            MiscUtil.ShowMessage(lblMessage, "Failed to update C MConstruction Tool Information.", false);
                        }
                    }
                }
                catch (Exception ex)
                {
                    MiscUtil.ShowMessage(lblMessage, ex.Message, true);
                }
            }
        }
示例#5
0
        private Int64 UpdateTran(CMConstructionToolEntity cMConstructionToolEntity, String filterExpression, DatabaseOperationType option)
        {
            long         returnCode = -99;
            const string SP         = "dbo.CMConstructionTool_SET";

            Database db = DatabaseFactory.CreateDatabase();

            using (DbCommand cmd = db.GetStoredProcCommand(SP))
            {
                AddOptionParameter(cmd, option, db);
                AddOutputParameter(cmd, db);
                AddFilterExpressionParameter(cmd, filterExpression, db);

                db.AddInParameter(cmd, "@ConstructionToolID", DbType.Int64, cMConstructionToolEntity.ConstructionToolID);
                db.AddInParameter(cmd, "@ConstructionToolCategoryID", DbType.Int64, cMConstructionToolEntity.ConstructionToolCategoryID);
                db.AddInParameter(cmd, "@ToolName", DbType.String, cMConstructionToolEntity.ToolName);
                db.AddInParameter(cmd, "@UnitID", DbType.Int64, cMConstructionToolEntity.UnitID);
                db.AddInParameter(cmd, "@IsRemoved", DbType.Boolean, cMConstructionToolEntity.IsRemoved);

                DbConnection connection = db.CreateConnection();
                connection.Open();
                DbTransaction transaction = connection.BeginTransaction();

                try
                {
                    using (IDataReader reader = db.ExecuteReader(cmd, transaction))
                    {
                        returnCode = GetReturnCodeFromParameter(cmd);
                    }

                    if (returnCode > 0)
                    {
                        transaction.Commit();
                    }
                    else
                    {
                        throw new ArgumentException("Error Code." + returnCode.ToString());
                    }
                }
                catch (Exception ex)
                {
                    transaction.Rollback();
                    throw ex;
                }
                finally
                {
                    transaction.Dispose();
                    connection.Close();
                    connection = null;
                }
            }

            return(returnCode);
        }
        protected void lvCMConstructionTool_ItemCommand(object sender, ListViewCommandEventArgs e)
        {
            Int64 ConstructionToolID;

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

            if (ConstructionToolID > 0)
            {
                if (string.Equals(e.CommandName, "EditItem"))
                {
                    _ConstructionToolID = ConstructionToolID;

                    PrepareEditView();

                    cpeEditor.Collapsed   = false;
                    cpeEditor.ClientState = "false";
                }
                else if (string.Equals(e.CommandName, "DeleteItem"))
                {
                    try
                    {
                        Int64 result = -1;

                        String fe = SqlExpressionBuilder.PrepareFilterExpression(CMConstructionToolEntity.FLD_NAME_ConstructionToolID, ConstructionToolID.ToString(), SQLMatchType.Equal);

                        CMConstructionToolEntity cMConstructionToolEntity = new CMConstructionToolEntity();


                        result = FCCCMConstructionTool.GetFacadeCreate().Delete(cMConstructionToolEntity, fe, DatabaseOperationType.Delete, TransactionRequired.No);

                        if (result == 0)
                        {
                            _ConstructionToolID       = 0;
                            _CMConstructionToolEntity = new CMConstructionToolEntity();
                            PrepareInitialView();
                            BindCMConstructionToolList();

                            MiscUtil.ShowMessage(lblMessage, "Construction Tool has been successfully deleted.", true);
                        }
                        else
                        {
                            MiscUtil.ShowMessage(lblMessage, "Failed to delete Construction Tool.", true);
                        }
                    }
                    catch (Exception ex)
                    {
                        MiscUtil.ShowMessage(lblMessage, ex.Message, true);
                    }
                }
            }
        }
示例#7
0
        private Int64 Update(CMConstructionToolEntity cMConstructionToolEntity, String filterExpression, DatabaseOperationType option)
        {
            long         returnCode = -99;
            const string SP         = "dbo.CMConstructionTool_SET";

            using (DbCommand cmd = Database.GetStoredProcCommand(SP))
            {
                AddOptionParameter(cmd, option);
                AddOutputParameter(cmd);
                AddFilterExpressionParameter(cmd, filterExpression);

                Database.AddInParameter(cmd, "@ConstructionToolID", DbType.Int64, cMConstructionToolEntity.ConstructionToolID);
                Database.AddInParameter(cmd, "@ConstructionToolCategoryID", DbType.Int64, cMConstructionToolEntity.ConstructionToolCategoryID);
                Database.AddInParameter(cmd, "@ToolName", DbType.String, cMConstructionToolEntity.ToolName);
                Database.AddInParameter(cmd, "@UnitID", DbType.Int64, cMConstructionToolEntity.UnitID);
                Database.AddInParameter(cmd, "@IsRemoved", DbType.Boolean, cMConstructionToolEntity.IsRemoved);

                using (IDataReader reader = Database.ExecuteReader(cmd))
                {
                    returnCode = GetReturnCodeFromParameter(cmd);

                    switch (returnCode)
                    {
                    case SqlConstants.DB_STATUS_CODE_DATAALREADYEXIST:
                    {
                        throw new ArgumentException("CMConstructionToolEntity already exists. Please specify another CMConstructionToolEntity.");
                    }

                    case SqlConstants.DB_STATUS_CODE_DATAUPDATEDFROMOTHERSESSION:
                    {
                        throw new ArgumentException("CMConstructionToolEntity data already updated from different session.");
                    }

                    case SqlConstants.DB_STATUS_CODE_FAIL_OPERATION:
                    {
                        throw new ArgumentException("CMConstructionToolEntity already exists. Please specify another CMConstructionToolEntity.");
                    }
                    }
                }
            }

            return(returnCode);
        }
        private void PrepareEditView()
        {
            CMConstructionToolEntity cMConstructionToolEntity = CurrentCMConstructionToolEntity;


            if (!cMConstructionToolEntity.IsNew)
            {
                if (ddlConstructionToolCategoryID.Items.Count > 0 && cMConstructionToolEntity.ConstructionToolCategoryID != null)
                {
                    ddlConstructionToolCategoryID.SelectedValue = cMConstructionToolEntity.ConstructionToolCategoryID.ToString();
                }

                txtToolName.Text = cMConstructionToolEntity.ToolName.ToString();
                if (ddlUnitID.Items.Count > 0 && cMConstructionToolEntity.UnitID != null)
                {
                    ddlUnitID.SelectedValue = cMConstructionToolEntity.UnitID.ToString();
                }

                chkIsRemoved.Checked = cMConstructionToolEntity.IsRemoved;

                btnSubmit.Text    = "Update";
                btnAddNew.Visible = true;
            }
        }
示例#9
0
 Int64 ICMConstructionToolFacade.Delete(CMConstructionToolEntity cMConstructionToolEntity, String filterExpression, DatabaseOperationType option, TransactionRequired reqTran)
 {
     return(DataAccessFactory.CreateCMConstructionToolDataAccess().Delete(cMConstructionToolEntity, filterExpression, option, reqTran));
 }
示例#10
0
 Int64 ICMConstructionToolFacade.Add(CMConstructionToolEntity cMConstructionToolEntity, DatabaseOperationType option, TransactionRequired reqTran)
 {
     return(DataAccessFactory.CreateCMConstructionToolDataAccess().Add(cMConstructionToolEntity, option, reqTran));
 }
 protected void btnAddNew_Click(object sender, EventArgs e)
 {
     _ConstructionToolID       = 0;
     _CMConstructionToolEntity = new CMConstructionToolEntity();
     PrepareInitialView();
 }