【发布时间】:2017-11-06 05:17:06
【问题描述】:
首先,我想指出,我一直在寻找解决这个问题的方法,但没有运气。
所以基本上我在 Radform1 中有一个 Mysql 函数,我想从 CustomAppointmentEditForm 调用
Radform1
public RadForm1()
{
InitializeComponent();
}
CustomAppointmentEditForm
public CustomAppointmentEditForm()
{
InitializeComponent();
}
我想从 Radform1 调用的函数
private void Update_LeadInfo()
{
try
{
using (MySqlConnection cn = new MySqlConnection(ConString))
{
string UniqueID = textBoxDescription.Text;
string CVR = txtCVR.Text;
string Firma = txtFirma.Text;
string Nummer = txtNummer.Text;
string Addresse = txtAddresse.Text;
string Postnr = txtPostnr.Text;
string By = txtBy.Text;
string Noter = txtNoter.Text;
string Email = txtEmail.Text;
string StartDato = dateStart.Text + " " + timeStart.Text;
string SlutDato = dateEnd.Text + " " + timeEnd.Text;
string Afholdt = radCheckBox1.CheckState.ToString();
if(Afholdt == "Checked")
{
Afholdt = "1";
}
else
{
Afholdt = "0";
}
if(chkAllDay.CheckState == CheckState.Checked)
{
StartDato = dateStart.Text + " " + "00:00";
SlutDato = dateEnd.Text + " " + "00:00";
}
cn.Open();
Console.WriteLine(UniqueID);
MySqlCommand cmd = new MySqlCommand();
cmd.Connection = cn;
cmd.CommandText = "UPDATE Leads SET CVR = ('" + CVR + "'), Firma = ('" + Firma + "'), Nummer = ('" + Nummer + "'), Addresse = ('" + Addresse + "'), Postnr = ('" + Postnr + "'), Bynavn = ('" + By + "'), Noter = ('" + Noter + "'), Afholdt = ('" + Afholdt + "'), Email = ('" + Email + "'), Slut_Dato = ('" + SlutDato + "') WHERE UniqueID = ('" + UniqueID + "');";
cmd.ExecuteNonQuery();
cmd.Dispose();
cn.Close();
}
}
catch (Exception Fejl)
{
Console.WriteLine(Fejl);
}
}
我知道有一个简单的解决方案,在此先感谢
【问题讨论】:
-
您需要在您的
CustomAppointmentEditForm中引用Radform1。这已经被问了四万亿次了。 -
你能举个例子吗?如前所述,我正在使用 Radforms,有一点不同
-
Radform1 formObj = new Radform1();然后像这样调用 show 方法formObj.Update_LeadInfo(); -
@Taco2 完全没有区别。 OOP 保持 OOP 独立于您正在使用的任何框架、库等。
-
我认为@un-lucky 的意思是
formObj.Update_LeadInfo()。