Example #1
0
        protected void lbtnEditSave_Click(object sender, EventArgs e)
        {
            try
            {
                if (hdnfield.Value != "")
                {
                    string CustomField = string.Empty;
                    bool IsSuccess = false;
                    int fieldId = Convert.ToInt32(hdnfield.Value);

                    AdvanceManageFieldBase objManageFields = new AdvanceManageFieldBase(ConnectionString);
                    objManageFields.FieldId = fieldId;

                    objManageFields.FieldName = txtEditFieldName.Text;
                    objManageFields.FieldType = DropDownList1.SelectedValue.ToString();
                    if (txtEditMaxLen.Text != "")
                        objManageFields.MaxLength = Convert.ToInt32(txtEditMaxLen.Text);

                    if (DropDownList1.SelectedItem.Value == "Text Box")
                        objManageFields.DefaultValue = txtEditDefaultValue.Text;

                    if (DropDownList1.SelectedItem.Value == "Check Box")
                        objManageFields.DefaultValue = chkEditDefault.Checked.ToString();

                    if (DropDownList1.SelectedItem.Value == "Date")
                        objManageFields.DefaultValue = txtEditDate.Text;
                    if (txtEditDispPos.Text != "")
                        objManageFields.DisplayPosition = Convert.ToInt32(txtEditDispPos.Text);
                    objManageFields.PrimaryField = chkEditPrimaryField.Checked;
                    objManageFields.RequiredField = chkEditReqField.Checked;
                    objManageFields.PersonalizedField = chkEditPersonalizedField.Checked;
                    objManageFields.Reserved = false;

                    IsSuccess = objManageFields.Update(ConnectionString);

                    if (DropDownList1.SelectedItem.Value == "Drop Down List" || DropDownList1.SelectedItem.Value == "Radio Button List")
                    {
                        DataTable dtFields = new DataTable("ManageFieldsProperty");
                        dtFields.Columns.Add("Item"); //or something similar
                        dtFields.Columns.Add("value");
                        dtFields.Columns.Add("FieldId");
                        for (int i = 0; i < Gridview2.Rows.Count; ++i)
                        {
                            DataRow dr = dtFields.NewRow();
                            TextBox box2 = (TextBox)Gridview2.Rows[i].Cells[0].FindControl("TextBox1");
                            TextBox box3 = (TextBox)Gridview2.Rows[i].Cells[0].FindControl("TextBox2");

                            dr["Item"] = box2.Text;
                            dr["value"] = box3.Text;
                            dr["FieldId"] = fieldId;
                            dtFields.Rows.Add(dr);
                        }
                        //removing all fields before updating values
                        AdvanceManageFieldsPropertyBase objMFProp = new AdvanceManageFieldsPropertyBase(ConnectionString);
                        objMFProp.Item = "FieldId";
                        objMFProp.Value = fieldId.ToString();
                        IsSuccess = objMFProp.Delete(ConnectionString);

                        DatabaseHelperExtension odbseHelper = new DatabaseHelperExtension(ConnectionString);
                        odbseHelper.AddColumn("Item", "Item");
                        odbseHelper.AddColumn("value", "value");
                        odbseHelper.AddColumn("FieldId", "FieldId");
                        odbseHelper.ExcuteSQLBulkCopy(dtFields, "AdvanceManageFieldsProperty", ref IsSuccess);
                    }
                    lblmsg.Style.Add("color", "green");
                    lblmsg.Text = txtEditFieldName.Text + "  updated successfully";
                    bindGrid("");
                }
            }
            catch (Exception ex)
            {

                throw ex;
            }
        }
 /// <summary>
 /// Populates the fields of a single objects from the columns found in an open reader.
 /// </summary>
 /// <param name="obj" type="AdvanceManageFieldsProperty">Object of AdvanceManageFieldsProperty to populate</param>
 /// <param name="rdr" type="IDataReader">An object that implements the IDataReader interface</param>
 ///
 /// <remarks>
 ///
 /// <RevisionHistory>
 /// Author				Date			Description
 /// DLGenerator			8/29/2012 03:30:46 PM		Created function
 /// 
 /// </RevisionHistory>
 ///
 /// </remarks>
 ///
 internal static void PopulateObjectFromReader(AdvanceManageFieldsPropertyBase obj,IDataReader rdr)
 {
     obj.ManageFieldPropertyID = rdr.GetInt64(rdr.GetOrdinal(AdvanceManageFieldsPropertyFields.ManageFieldPropertyID));
     obj.FieldId = rdr.GetInt64(rdr.GetOrdinal(AdvanceManageFieldsPropertyFields.FieldId));
     obj.Item = rdr.GetString(rdr.GetOrdinal(AdvanceManageFieldsPropertyFields.Item));
     obj.Value = rdr.GetString(rdr.GetOrdinal(AdvanceManageFieldsPropertyFields.Value));
 }