本文整理汇总了C#中ClassInfo.Save方法的典型用法代码示例。如果您正苦于以下问题:C# ClassInfo.Save方法的具体用法?C# ClassInfo.Save怎么用?C# ClassInfo.Save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ClassInfo
的用法示例。
在下文中一共展示了ClassInfo.Save方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: bt_Save_Click
protected void bt_Save_Click(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(tb_ClassCode.Text.Trim()))
{
lb_Error.Text = "班级编号不能为空";
}
else if (string.IsNullOrEmpty(tbClassName.Text.Trim()))
{
lb_Error.Text = "班级名称不能为空";
}
else if (string.IsNullOrEmpty(tb_OrStdNum.Text.Trim()))
{
lb_Error.Text = "预定人数不能为空";
}
else
{
try
{
ClassInfo testci = ClassInfo.GetByCode(tb_ClassCode.Text.Trim());
if (testci != null)
{
lb_Error.Text = "已经存在相同编号的班级信息!";
}
ClassInfo ci = new ClassInfo();
ci.ClassCode = tb_ClassCode.Text;
ci.GradeCode = ddlGradeCode.SelectedItem.Text;
ci.ProCode = ddlProCode.SelectedValue;
ci.OrStdNum = Convert.ToInt32(tb_OrStdNum.Text);
ci.ClassName = tbClassName.Text;
ci.Save();
Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "", "<script>alert('添加班级成功,请点击班级列表');</script>");
tb_ClassCode.Text = "";
tb_OrStdNum.Text = "";
}
catch (Exception ex)
{
lb_Error.Text = "错误信息:" + ex.Message;
tb_ClassCode.Text = "";
tb_OrStdNum.Text = "";
}
}
}
示例2: ProcessRequest
public void ProcessRequest(HttpContext context)
{
context.Response.ContentType = "application/json";//
string Name = context.Request.QueryString["Name"].ToString();
int PersonsNum = Convert.ToInt32(context.Request.QueryString["PersonsNum"]);
int MajorId = Convert.ToInt32(context.Request.QueryString["MajorId"]);
int GradeId = 0;
int GradeYear = 0;
try
{
GradeId = Convert.ToInt32(context.Request.QueryString["GradeId"]);//年级Id
GradeYear = Convert.ToInt32(context.Request.QueryString["GradeYear"]);//年级
}
catch (Exception)
{
context.Response.Write("{success:false,msg:'新增失败,以上均为必填项。'}");
return;
}
if (Name.Length >= 1 && MajorId != 0 && GradeId != 0)
{
try
{
ClassInfo classInfo = new ClassInfo();
classInfo.Name = Name;
classInfo.PersonsNum = PersonsNum;
classInfo.MajorId = MajorId;
classInfo.GradeId = GradeId;
classInfo.GradeYear = GradeYear;
classInfo.DateCreated = DateTime.Now;
classInfo.Save();
context.Response.Write("{success:true,msg:'新增成功。',DateCreated:'" + DateTime.Now.ToShortDateString() + "', classInfoId:'" + classInfo.Id + "'}");
}
catch (Exception ex)
{
context.Response.Write("{success:false,msg:'" + ex.Message + "'}");
}
}
else
{
context.Response.Write("{success:false,msg:'新增失败,以上均为必填项。'}");
}
}