/// <summary> /// 更新一条数据 /// </summary> public void Update(TSM.Model.pms_Product_Batch model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update pms_Product_Batch set "); strSql.Append("ProductBatchName=@ProductBatchName,"); strSql.Append("BisnessContactID=@BisnessContactID,"); strSql.Append("QualityContactID=@QualityContactID,"); strSql.Append("CustomerInfoID=@CustomerInfoID,"); strSql.Append("FinalCustInfoID=@FinalCustInfoID,"); strSql.Append("ProductDate=@ProductDate"); strSql.Append(" where ProductBatchID=@ProductBatchID "); SqlParameter[] parameters = { new SqlParameter("@ProductBatchID", SqlDbType.Int, 4), new SqlParameter("@ProductBatchName", SqlDbType.VarChar, 64), new SqlParameter("@BisnessContactID", SqlDbType.Int, 4), new SqlParameter("@QualityContactID", SqlDbType.Int, 4), new SqlParameter("@CustomerInfoID", SqlDbType.Int, 4), new SqlParameter("@FinalCustInfoID", SqlDbType.Int, 4), new SqlParameter("@ProductDate", SqlDbType.DateTime) }; parameters[0].Value = model.ProductBatchID; parameters[1].Value = model.ProductBatchName; parameters[2].Value = model.BisnessContactID; parameters[3].Value = model.QualityContactID; parameters[4].Value = model.CustomerInfoID; parameters[5].Value = model.FinalCustInfoID; parameters[6].Value = model.ProductDate; DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); }
private void SaveProductType() { TSM.Model.pms_Product_Batch modelpms_Product_Batch = new TSM.Model.pms_Product_Batch(); modelpms_Product_Batch.ProductBatchName = tbxBatchName.Text.Trim(); modelpms_Product_Batch.CustomerInfoID = int.Parse(ddlCompany.SelectedValue); modelpms_Product_Batch.FinalCustInfoID = int.Parse(ddlFinCostum.SelectedValue); modelpms_Product_Batch.BisnessContactID = int.Parse(ddlBisContact.SelectedValue); modelpms_Product_Batch.QualityContactID = int.Parse(ddlQuaContact.SelectedValue); modelpms_Product_Batch.ProductDate = DateTime.Now.Date; m_bllpms_Product_Batch.Add(modelpms_Product_Batch); }
/// <summary> /// 得到一个对象实体 /// </summary> public TSM.Model.pms_Product_Batch GetModel(int ProductBatchID) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 ProductBatchID,ProductBatchName,BisnessContactID,QualityContactID,CustomerInfoID,FinalCustInfoID,ProductDate from pms_Product_Batch "); strSql.Append(" where ProductBatchID=@ProductBatchID "); SqlParameter[] parameters = { new SqlParameter("@ProductBatchID", SqlDbType.Int, 4) }; parameters[0].Value = ProductBatchID; TSM.Model.pms_Product_Batch model = new TSM.Model.pms_Product_Batch(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { if (ds.Tables[0].Rows[0]["ProductBatchID"].ToString() != "") { model.ProductBatchID = int.Parse(ds.Tables[0].Rows[0]["ProductBatchID"].ToString()); } model.ProductBatchName = ds.Tables[0].Rows[0]["ProductBatchName"].ToString(); if (ds.Tables[0].Rows[0]["BisnessContactID"].ToString() != "") { model.BisnessContactID = int.Parse(ds.Tables[0].Rows[0]["BisnessContactID"].ToString()); } if (ds.Tables[0].Rows[0]["QualityContactID"].ToString() != "") { model.QualityContactID = int.Parse(ds.Tables[0].Rows[0]["QualityContactID"].ToString()); } if (ds.Tables[0].Rows[0]["CustomerInfoID"].ToString() != "") { model.CustomerInfoID = int.Parse(ds.Tables[0].Rows[0]["CustomerInfoID"].ToString()); } if (ds.Tables[0].Rows[0]["FinalCustInfoID"].ToString() != "") { model.FinalCustInfoID = int.Parse(ds.Tables[0].Rows[0]["FinalCustInfoID"].ToString()); } if (ds.Tables[0].Rows[0]["ProductDate"].ToString() != "") { model.ProductDate = DateTime.Parse(ds.Tables[0].Rows[0]["ProductDate"].ToString()); } return(model); } else { return(null); } }
private void SaveProductType() { TSM.Model.pms_Product_Batch modelpms_Product_Batch = new TSM.Model.pms_Product_Batch(); modelpms_Product_Batch.ProductBatchName = tbxBatchName.Text.Trim(); modelpms_Product_Batch.BisnessContactID = int.Parse(ddlBisContact.SelectedValue); modelpms_Product_Batch.QualityContactID = int.Parse(ddlQuaContact.SelectedValue); modelpms_Product_Batch.CustomerInfoID = int.Parse(ddlCompany.SelectedValue); modelpms_Product_Batch.FinalCustInfoID = int.Parse(ddlFinCustom.SelectedValue); modelpms_Product_Batch.ProductDate = DateTime.Now.Date; modelpms_Product_Batch.ProductBatchID = int.Parse(lbBatchID.Text); m_bllpms_Product_Batch.Update(modelpms_Product_Batch); FineUI.Alert.Show("保存成功!", String.Empty, FineUI.Alert.DefaultMessageBoxIcon, FineUI.ActiveWindow.GetHidePostBackReference()); PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference()); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(TSM.Model.pms_Product_Batch model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into pms_Product_Batch("); strSql.Append("ProductBatchName,BisnessContactID,QualityContactID,CustomerInfoID,FinalCustInfoID,ProductDate)"); strSql.Append(" values ("); strSql.Append("@ProductBatchName,@BisnessContactID,@QualityContactID,@CustomerInfoID,@FinalCustInfoID,@ProductDate)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@ProductBatchName", SqlDbType.VarChar, 64), new SqlParameter("@BisnessContactID", SqlDbType.Int, 4), new SqlParameter("@QualityContactID", SqlDbType.Int, 4), new SqlParameter("@CustomerInfoID", SqlDbType.Int, 4), new SqlParameter("@FinalCustInfoID", SqlDbType.Int, 4), new SqlParameter("@ProductDate", SqlDbType.DateTime) }; parameters[0].Value = model.ProductBatchName; parameters[1].Value = model.BisnessContactID; parameters[2].Value = model.QualityContactID; parameters[3].Value = model.CustomerInfoID; parameters[4].Value = model.FinalCustInfoID; parameters[5].Value = model.ProductDate; object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters); if (obj == null) { return(1); } else { return(Convert.ToInt32(obj)); } }
private void LoadData() { //绑定三个下拉列表控件 DataSet dsCom = m_bllpms_Company_Info.GetList(""); DataSet dsContact = m_bllpms_User_Info.GetList(""); ddlCompany.DataValueField = "CompanyInfoID"; ddlCompany.DataTextField = "CompanyName"; ddlCompany.DataSource = dsCom.Tables[0]; ddlCompany.DataBind(); ddlFinCustom.DataValueField = "CompanyInfoID"; ddlFinCustom.DataTextField = "CompanyName"; ddlFinCustom.DataSource = dsCom.Tables[0]; ddlFinCustom.DataBind(); ddlBisContact.DataValueField = "UserInfoID"; ddlBisContact.DataTextField = "UserName"; ddlBisContact.DataSource = dsContact.Tables[0]; ddlBisContact.DataBind(); ddlQuaContact.DataValueField = "UserInfoID"; ddlQuaContact.DataTextField = "UserName"; ddlQuaContact.DataSource = dsContact.Tables[0]; ddlQuaContact.DataBind(); //// 默认的排序列和排序方向 //Grid1.SortColumnIndex = 0; //Grid1.SortDirection = "DESC"; // 每页记录数 Grid1.PageSize = 15; //// 点击删除按钮时,至少选中一项 //ResolveDeleteGridItem(btnDeleteSelected, Grid1); int id = GetQueryIntValue("id"); TSM.Model.pms_Product_Batch modelpms_Product_Batch = m_bllpms_Product_Batch.GetModel(id); if (modelpms_Product_Batch == null) { // 参数错误,首先弹出Alert对话框然后关闭弹出窗口 Alert.Show("参数错误!", String.Empty, ActiveWindow.GetHideReference()); return; } //给控件赋初值,显示 lbBatchID.Text = modelpms_Product_Batch.ProductBatchID.ToString().Trim(); tbxBatchName.Text = modelpms_Product_Batch.ProductBatchName.ToString().Trim(); ddlBisContact.SelectedValue = modelpms_Product_Batch.BisnessContactID.ToString().Trim(); ddlQuaContact.SelectedValue = modelpms_Product_Batch.QualityContactID.ToString().Trim(); ddlCompany.SelectedValue = modelpms_Product_Batch.CustomerInfoID.ToString().Trim(); ddlFinCustom.SelectedValue = modelpms_Product_Batch.FinalCustInfoID.ToString().Trim(); //绑定表格 BindGrid(); //父窗口向子窗口传值 string BatchId = lbBatchID.Text.ToString().Trim(); btnNew.OnClientClick = Window1.GetShowReference("~/pms_Product_Info_new.aspx?id=" + BatchId, "添加新产品"); }