/// <summary> /// /// </summary> /// <param name="Name"> </param> /// <returns></returns> public static Entity.Enterprise GetEnterpriseInfo(string Name) { Entity.Enterprise entity = null; DBOperatorBase db = new DataBase(); IDBTypeElementFactory dbFactory = db.GetDBTypeElementFactory(); try { IDataReader dataReader = db.ExecuteReader(Config.con, CommandType.Text, "Select * from [Enterprise] where Name='" + Name + "'", null); while (dataReader.Read()) { entity = new Entity.Enterprise(); entity.EnterpriseID = DataHelper.ParseToInt(dataReader["EnterpriseID"].ToString()); entity.Name = dataReader["Name"].ToString(); entity.AreaCode = dataReader["AreaCode"].ToString(); } } catch (Exception ex) { } finally { db.Conn.Close(); } return(entity); }
protected void btn_save_Click(object sender, EventArgs e) { string str = checkInfo(); if (str != "") { Alert.ShowInTop(str, MessageBoxIcon.Warning); } else { Entity.Contract entity = new Entity.Contract(); entity.ContractNumber = txt_ContractNumber.Text.Trim(); //int EID = DAL.Enterprise.GetEnterpriseID(txt_Enterprise.Text.Trim()); //entity.ProduceID = EID; Entity.Enterprise enterprise = DAL.Enterprise.GetEnterpriseInfo(txt_Enterprise.Text.Trim()); entity.ProduceID = enterprise.EnterpriseID; entity.ProduceArea = enterprise.AreaCode; entity.HandleID = int.Parse(drop_handle.SelectedValue.Trim()); entity.WasteCode = drop_Waste.SelectedValue.Trim(); entity.StartDate = Date_Start.SelectedDate; entity.EndDate = Date_End.SelectedDate; entity.SignDate = Date_Sign.SelectedDate; entity.Remark = txt_Remark.Text.Trim(); entity.Amount = decimal.Parse(NB_Amount.Text.Trim()); entity.CreateUser = Request.Cookies["Cookies"].Values["UserName"].ToString(); entity.UpdateUser = Request.Cookies["Cookies"].Values["UserName"].ToString(); entity.CreateDate = DateTime.Now; entity.UpdateDate = DateTime.Now; entity.StatusID = 1; entity.Total = 0; int iReturn = 0; if (sGuid == string.Empty || sGuid == null) { iReturn = DAL.Contract.AddContract(entity); } else { entity.ContractID = int.Parse(sGuid); iReturn = DAL.Contract.UpdateContract(entity); } if (iReturn == 1) { Alert.ShowInTop(" 保存成功!", MessageBoxIcon.Information); // PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference()); } else { Alert.ShowInTop(" 保存失败!", MessageBoxIcon.Warning); } } }
public static int AddEnterprise(Entity.Enterprise entity) { int iReturn = 0; DBOperatorBase db = new DataBase(); IDBTypeElementFactory dbFactory = db.GetDBTypeElementFactory(); SqlTransactionHelper thelper = new SqlTransactionHelper(DAL.Config.con); IDbTransaction trans = thelper.StartTransaction(); try { IDbDataParameter[] prams = { dbFactory.MakeInParam("@Name", DBTypeConverter.ConvertCsTypeToOriginDBType(entity.Name.GetType().ToString()), entity.Name, 50), dbFactory.MakeInParam("@LawManCode", DBTypeConverter.ConvertCsTypeToOriginDBType(entity.LawManCode.GetType().ToString()), entity.LawManCode, 20), dbFactory.MakeInParam("@OrganizationCode", DBTypeConverter.ConvertCsTypeToOriginDBType(entity.OrganizationCode.GetType().ToString()), entity.OrganizationCode, 20), dbFactory.MakeInParam("@PastName", DBTypeConverter.ConvertCsTypeToOriginDBType(entity.PastName.GetType().ToString()), entity.PastName, 50), dbFactory.MakeInParam("@SetUpDate", DBTypeConverter.ConvertCsTypeToOriginDBType(entity.SetUpDate.GetType().ToString()), entity.SetUpDate, 0), dbFactory.MakeInParam("@Type", DBTypeConverter.ConvertCsTypeToOriginDBType(entity.Type.GetType().ToString()), entity.Type, 32), dbFactory.MakeInParam("@FaxNumber", DBTypeConverter.ConvertCsTypeToOriginDBType(entity.FaxNumber.GetType().ToString()), entity.FaxNumber, 20), dbFactory.MakeInParam("@Industry", DBTypeConverter.ConvertCsTypeToOriginDBType(entity.Industry.GetType().ToString()), entity.Industry, 32), dbFactory.MakeInParam("@AreaCode", DBTypeConverter.ConvertCsTypeToOriginDBType(entity.AreaCode.GetType().ToString()), entity.AreaCode, 20), dbFactory.MakeInParam("@PostCode", DBTypeConverter.ConvertCsTypeToOriginDBType(entity.PostCode.GetType().ToString()), entity.PostCode, 20), dbFactory.MakeInParam("@Address", DBTypeConverter.ConvertCsTypeToOriginDBType(entity.Address.GetType().ToString()), entity.Address, 80), dbFactory.MakeInParam("@LawMan", DBTypeConverter.ConvertCsTypeToOriginDBType(entity.LawMan.GetType().ToString()), entity.LawMan, 10), dbFactory.MakeInParam("@Email", DBTypeConverter.ConvertCsTypeToOriginDBType(entity.Email.GetType().ToString()), entity.Email, 50), dbFactory.MakeInParam("@Phone1", DBTypeConverter.ConvertCsTypeToOriginDBType(entity.Phone1.GetType().ToString()), entity.Phone1, 20), dbFactory.MakeInParam("@Telphone1", DBTypeConverter.ConvertCsTypeToOriginDBType(entity.Telphone1.GetType().ToString()), entity.Telphone1, 20), dbFactory.MakeInParam("@CreateDate", DBTypeConverter.ConvertCsTypeToOriginDBType(entity.CreateDate.GetType().ToString()), entity.CreateDate, 0), dbFactory.MakeInParam("@CreateUser", DBTypeConverter.ConvertCsTypeToOriginDBType(entity.CreateUser.GetType().ToString()), entity.CreateUser, 50), dbFactory.MakeInParam("@UpdateDate", DBTypeConverter.ConvertCsTypeToOriginDBType(entity.UpdateDate.GetType().ToString()), entity.UpdateDate, 0), dbFactory.MakeInParam("@UpdateUser", DBTypeConverter.ConvertCsTypeToOriginDBType(entity.UpdateUser.GetType().ToString()), entity.UpdateUser, 50), dbFactory.MakeOutReturnParam() }; iReturn = db.ExecuteNonQueryTrans(trans, CommandType.StoredProcedure, "proc_Enterprise_Add", prams); iReturn = int.Parse(prams[19].Value.ToString()); thelper.CommitTransaction(trans); iReturn = 1; } catch (Exception ex) { thelper.RollTransaction(trans); iReturn = 0; } finally { db.Conn.Close(); } return(iReturn); }
/// <summary> /// /// </summary> /// <param name="EnterpriseID"> </param> /// <returns></returns> public static Entity.Enterprise GetEnterprise(int EnterpriseID) { Entity.Enterprise entity = null; DBOperatorBase db = new DataBase(); IDBTypeElementFactory dbFactory = db.GetDBTypeElementFactory(); try { IDataReader dataReader = db.ExecuteReader(Config.con, CommandType.Text, "Select * from [Enterprise] where EnterpriseID='" + EnterpriseID + "'", null); while (dataReader.Read()) { entity = new Entity.Enterprise(); entity.EnterpriseID = DataHelper.ParseToInt(dataReader["EnterpriseID"].ToString()); entity.Name = dataReader["Name"].ToString(); entity.LawManCode = dataReader["LawManCode"].ToString(); entity.OrganizationCode = dataReader["OrganizationCode"].ToString(); entity.PastName = dataReader["PastName"].ToString(); entity.SetUpDate = DataHelper.ParseToDate(dataReader["SetUpDate"].ToString()); entity.Type = DataHelper.ParseToInt(dataReader["Type"].ToString()); entity.FaxNumber = dataReader["FaxNumber"].ToString(); entity.Industry = DataHelper.ParseToInt(dataReader["Industry"].ToString()); entity.AreaCode = dataReader["AreaCode"].ToString(); entity.PostCode = dataReader["PostCode"].ToString(); entity.Address = dataReader["Address"].ToString(); entity.LawMan = dataReader["LawMan"].ToString(); entity.Email = dataReader["Email"].ToString(); entity.Phone1 = dataReader["Phone1"].ToString(); entity.Telphone1 = dataReader["Telphone1"].ToString(); //entity.CreateDate = DataHelper.ParseToDate(dataReader["CreateDate"].ToString()); //entity.CreateUser = dataReader["CreateUser"].ToString(); //entity.UpdateDate = DataHelper.ParseToDate(dataReader["UpdateDate"].ToString()); //entity.UpdateUser = dataReader["UpdateUser"].ToString(); } } catch (Exception ex) { } finally { db.Conn.Close(); } return(entity); }
private void LoadData(string thisGuid) { if (thisGuid != string.Empty) { //BindGrid(); Entity.Enterprise entity = DAL.Enterprise.GetEnterprise(int.Parse(thisGuid)); txt_qymc.Text = entity.Name; if (!string.IsNullOrEmpty(entity.AreaCode)) { drp_sd.SelectedValue = entity.AreaCode; } if (!string.IsNullOrEmpty(entity.Type.ToString())) { drp_sd.SelectedValue = entity.Type.ToString(); } //else //{ // drp_sd.Items.FindByText("请选择").Selected = true; //} txt_cname.Text = entity.PastName; txt_dz.Text = entity.Address; txt_jgdm.Text = entity.LawManCode; if (entity.Industry != -2) { drop_industry.SelectedValue = entity.Industry.ToString(); //drop_industry.Items.FindByValue(ds.Tables[0].Rows[0]["行业类别"].ToString()).Selected = true; } txt_frdb.Text = entity.LawMan; txt_czhm.Text = entity.FaxNumber; txt_email.Text = entity.Email; txt_tel1.Text = entity.Telphone1; txt_OrgCode.Text = entity.OrganizationCode; txt_Postcode.Text = entity.PostCode; txt_mobile1.Text = entity.Phone1; if (entity.SetUpDate.ToString() != "" && entity.SetUpDate.ToString() != "1900-01-01 00:00:00.000" && entity.SetUpDate.ToString() != "1900/1/1 0:00:00") { txt_createdate.Text = DateTime.Parse(entity.SetUpDate.ToString()).ToString("yyyy-MM-dd"); } } }
protected void btn_save_Click(object sender, EventArgs e) { string msg = checkInput(); if (msg != "") { Alert.Show(msg); return; } else { #region 保存Enterprise //保存Enterprise Entity.Enterprise enterprise = new Entity.Enterprise(); enterprise.Name = txt_qymc.Text.Trim(); enterprise.AreaCode = drp_sd.SelectedValue.ToString(); enterprise.PastName = txt_cname.Text.Trim(); enterprise.Address = txt_dz.Text.Trim(); enterprise.LawManCode = txt_jgdm.Text.Trim(); enterprise.LawMan = txt_frdb.Text.Trim(); enterprise.Email = txt_email.Text.Trim(); enterprise.Telphone1 = txt_tel1.Text.Trim(); enterprise.Phone1 = txt_mobile1.Text.Trim(); enterprise.OrganizationCode = txt_OrgCode.Text.Trim(); enterprise.PostCode = txt_Postcode.Text.Trim(); enterprise.Type = int.Parse(drop_type.SelectedValue.Trim()); try { enterprise.SetUpDate = DateTime.Parse(txt_createdate.Text.ToString()); } catch { enterprise.SetUpDate = DateTime.Parse("1900-01-01 0:00:00"); } enterprise.FaxNumber = txt_czhm.Text.Trim(); if (drop_industry.SelectedValue == null) { enterprise.Industry = 0; } else { enterprise.Industry = int.Parse(drop_industry.SelectedValue.ToString()); } enterprise.CreateDate = DateTime.Now; enterprise.UpdateDate = DateTime.Now; enterprise.CreateUser = Request.Cookies["Cookies"].Values["UserName"].ToString(); enterprise.UpdateUser = Request.Cookies["Cookies"].Values["UserName"].ToString(); int iReturn = 0; if (sGuid == string.Empty || sGuid == null) { iReturn = DAL.Enterprise.AddEnterprise(enterprise); } else { enterprise.EnterpriseID = int.Parse(sGuid); iReturn = DAL.Enterprise.UpdateEnterprise(enterprise); } if (iReturn == 1) { Alert.ShowInTop(" 保存成功!", MessageBoxIcon.Information); // PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference()); } else { Alert.ShowInTop(" 保存失败!", MessageBoxIcon.Warning); } } #endregion }