Пример #1
0
        public bool AddType(ITypes type)
        {
            bool success = false;
            try
            {
                Database db = DatabaseFactory.CreateDatabase(Constant.Database_Connection_Name);
                DbCommand dbCommand = db.GetStoredProcCommand(Constant.SP_Type_Insert);

                db.AddInParameter(dbCommand, "@sTypeName", DbType.String, type.TypeName);
                db.AddOutParameter(dbCommand, "@iTypeId", DbType.Int32, 4);

                if (db.ExecuteNonQuery(dbCommand) > 0)
                {
                    int newItemID = (int)db.GetParameterValue(dbCommand, "@iTypeId");

                    if (newItemID > 0)
                    {
                        success = true;
                        type.TypeId = newItemID;
                    }
                }
            }
            catch (System.Exception ex)
            {
                ex.Data.Add("BusinessLayerException", GetType().ToString() + Constant.Error_Seperator + "public bool AddType(Type type)");
                throw ex;
            }
            return success;
        }
Пример #2
0
    protected void btnTypeSave_Click(object sender, EventArgs e)
    {
        try
        {
            Boolean save = true;
            ITypes type = new ITypes();
            type.TypeName = txtType.Text.Trim();
            if (type.Save())
            {

                //
                // Types
                //
                DataSet dsTypes = (new TypesDAO()).GetAllTypes();
                if (dsTypes == null || dsTypes.Tables.Count == 0)
                {
                    ddlType.Items.Add(new ListItem("--No Data Found--", "-1"));
                }
                else
                {
                    Master.BindDropdown("TypeName", "TypeId", dsTypes, ddlType);
                    ddlType.Items.Add(new ListItem("--Please Select--", "-1"));
                    ddlType.SelectedValue = type.TypeId.ToString();
                }

                ddlType.Visible = true;
                RequiredFieldValidator10.Enabled = false;
                txtType.Visible = false;
                btnTypeSave.Visible = false;
                btnAddType.Visible = true;
            }
        }
        catch (Exception ex)
        {
            ex.Data.Add("UILayerException", this.GetType().ToString() + Constant.Error_Seperator + "protected void btnTypeSave_Click(object sender, EventArgs e)");
            if (Master.LoggedUser != null && Master.LoggedUser.UserName != null && Master.LoggedUser.UserName != string.Empty)
                Response.Redirect("Error.aspx?LogId=" + LankaTilesExceptions.WriteEventLogs(ex, Constant.Database_Connection_Name, Master.LoggedUser.UserName), false);
            else
                Response.Redirect("Error.aspx?LogId=" + LankaTilesExceptions.WriteEventLogs(ex, Constant.Database_Connection_Name, "Annonimous"), false);

        }
    }