如何保存复选框

如何保存复选框

问题描述:

数据服务

Data Services

public static void AddNewMaterial(int material_id, string material, string UTP, string Use_Type,string Salt, string Salt_Type)
  {
  OracleDatabase db =(OracleDatabase)DatabaseFactory.CreateDatabase("PHTS");
 using (System.Data.Common.DbCommand cmd = db.GetStoredProcCommand("AddNewMaterial"))  
           {
  db.AddInParameter(cmd, "I_Material_ID", DbType.Int32, material_id);
  db.AddInParameter(cmd, "I_Material", DbType.String, material);
  db.AddInParameter(cmd, "I_UTP", DbType.String, UTP);
  db.AddInParameter(cmd, "I_Use_Type", DbType.String, Use_Type);
  db.AddInParameter(cmd, "I_Salt", DbType.String, Salt);
  db.AddInParameter(cmd, "I_Salt_Type", DbType.String, Salt_Type);
  db.ExecuteNonQuery(cmd);
            }
  }



UserInterface



UserInterface

private void Savebutton_Click(object sender, EventArgs e)
        {
            int material_id = Convert.ToInt32(this.MIDtextBox.Text);
            string material = this.MaterialtextBox.Text;
            string UTP = this.UTPcheckBox.Text;
            string Use_Type = this.UseTypecomboBox.Text;
            string Salt = this.SaltCheckbox.Text;
            string Salt_Type = this.SaltComboBox.Text;
            
PHTS.DataServices.cslMaterial.AddNewMaterial(material_id, material, UTP, Use_Type,Salt, Salt_Type);
            MessageBox.Show("Record Saved");
            
        }



如何将Checkbox.checked项目保存为数据库"Y",如果未选中,则必须另存为"N"

谢谢



How can I save the Checkbox.checked Item to database as "Y" and if is not checked then I have to save as "N"

Thanks

string isChecked = checkbox1.Checked ? "Y" : "N";



现在,您可以将所需的字符串保存在数据库中(但是您选择这样做).这不是火箭手术.



Now you have the desired string that you can save in the database (however you''re choosing to do that). It ain''t rocket surgery.