protected void btnSubmit_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(txtName.Text)) { WebUtility.ShowMsg("联系人不能为空!"); return; } if (!Utility.IsNumeric(txtPhone.Text)) { WebUtility.ShowMsg("联系方式只能为数字!"); return; } if (string.IsNullOrWhiteSpace(txtCompanyName.Text)) { WebUtility.ShowMsg("公司名称不能为空!"); return; } if (string.IsNullOrWhiteSpace(txtCompanyAddress.Text)) { WebUtility.ShowMsg("公司地址不能为空!"); return; } if (string.IsNullOrWhiteSpace(hfPosition.Value)) { WebUtility.ShowMsg("请在地图中选择准确位置!"); return; } bool isAdd = false; Model.Key_CircleSaleMan entApplication = circleSaleMan.GetEntity(new string[] { "UserID" }, this.LoginUser.UserID); if (entApplication == null) { entApplication = new ADeeWu.HuoBi3J.Model.Key_CircleSaleMan(); entApplication.CreateTime = DateTime.Now; entApplication.ModifyTime = DateTime.Now; isAdd = true; } entApplication.CheckState = (int)UserSessionCheckState.NotAudit; entApplication.ModifyTime = DateTime.Now; entApplication.Phone = txtPhone.Text; entApplication.UserID = this.LoginUser.UserID; entApplication.Memo = txtMemo.Value; entApplication.QQ = txtQQ.Text; entApplication.CompanyAddress = txtCompanyAddress.Text; entApplication.CompanyName = txtCompanyName.Text; entApplication.Job = txtJob.Text; entApplication.Name = txtName.Text; var position = hfPosition.Value.Split(new char[] { '|' }); entApplication.PositionX = Utility.GetFloat(position[0], 0); entApplication.PositionY = Utility.GetFloat(position[1], 0); if (isAdd) { var user = new DAL.Users().GetEntity(LoginUser.UserID); if (user.Money <= 50) { WebUtility.ShowMsg(string.Format("你的余额为:{0},申请货比三家业务员余额大于50元!", user.Money)); return; } if (circleSaleMan.Add(entApplication) > 0) { WebUtility.ShowMsg(this, "提交申请成功!我们将尽快为您处理!"); } else { WebUtility.ShowMsg(this, "操作失败!请与我们联系!"); } } else { if (circleSaleMan.Update(entApplication) > 0) { WebUtility.ShowMsg(this, "提交申请成功!我们将尽快为您处理!"); } else { WebUtility.ShowMsg(this, "操作失败!请与我们联系!"); } } }
public ADeeWu.HuoBi3J.Model.Key_CircleSaleMan GetEntity(string where) { DataTable dt = this.Select(where,""); if(dt.Rows.Count==0) return null; DataRow dr = dt.Rows[0]; ADeeWu.HuoBi3J.Model.Key_CircleSaleMan Entity = new ADeeWu.HuoBi3J.Model.Key_CircleSaleMan(); Entity.ID = long.Parse(dr["ID"].ToString()); Entity.Name = dr["Name"] as string; Entity.UserID = dr["UserID"] as long?; Entity.QQ = dr["QQ"] as string; Entity.Phone = dr["Phone"] as string; Entity.CompanyName = dr["CompanyName"] as string; Entity.CompanyAddress = dr["CompanyAddress"] as string; Entity.Job = dr["Job"] as string; Entity.PositionX = dr["PositionX"] as double?; Entity.PositionY = dr["PositionY"] as double?; Entity.CheckState = dr["CheckState"] as int?; Entity.ModifyTime = dr["ModifyTime"] as DateTime?; Entity.CreateTime = dr["CreateTime"] as DateTime?; Entity.Memo = dr["Memo"] as string; return Entity; }
public ADeeWu.HuoBi3J.Model.Key_CircleSaleMan[] GetEntityList(string orderBy,string[] columns,params object[] values) { StringBuilder builder = new StringBuilder(); builder.Append("select * from [Key_CircleSaleMan] where 1=1"); db.Parameters.Clear(); for(int i=0;i<columns.Length;i++) { builder.AppendFormat(" and [{0}]=@{0}", columns[i]); db.Parameters.Append("@"+columns[i],values[i]); } if (!string.IsNullOrEmpty(orderBy)) { builder.AppendFormat(" order by {0}", orderBy); } DataTable dt = db.Select(builder.ToString()); ADeeWu.HuoBi3J.Model.Key_CircleSaleMan[] EntityList = new ADeeWu.HuoBi3J.Model.Key_CircleSaleMan[dt.Rows.Count]; if (dt.Rows.Count == 0) return EntityList; for (int i = 0; i < dt.Rows.Count; i++) { DataRow dr = dt.Rows[i]; ADeeWu.HuoBi3J.Model.Key_CircleSaleMan Entity = new ADeeWu.HuoBi3J.Model.Key_CircleSaleMan(); Entity.ID = long.Parse(dr["ID"].ToString()); Entity.Name = dr["Name"] as string; Entity.UserID = dr["UserID"] as long?; Entity.QQ = dr["QQ"] as string; Entity.Phone = dr["Phone"] as string; Entity.CompanyName = dr["CompanyName"] as string; Entity.CompanyAddress = dr["CompanyAddress"] as string; Entity.Job = dr["Job"] as string; Entity.PositionX = dr["PositionX"] as double?; Entity.PositionY = dr["PositionY"] as double?; Entity.CheckState = dr["CheckState"] as int?; Entity.ModifyTime = dr["ModifyTime"] as DateTime?; Entity.CreateTime = dr["CreateTime"] as DateTime?; Entity.Memo = dr["Memo"] as string; EntityList[i] = Entity; } return EntityList; }
public ADeeWu.HuoBi3J.Model.Key_CircleSaleMan GetEntity(long ID) { db.Parameters.Clear(); db.Parameters.Append("@ID",ID); DataTable dt = db.Select("select * from [Key_CircleSaleMan] where 1=1 and [ID]=@ID"); if(dt.Rows.Count==0) return null; DataRow dr = dt.Rows[0]; ADeeWu.HuoBi3J.Model.Key_CircleSaleMan Entity = new ADeeWu.HuoBi3J.Model.Key_CircleSaleMan(); Entity.ID = long.Parse(dr["ID"].ToString()); Entity.Name = dr["Name"] as string; Entity.UserID = dr["UserID"] as long?; Entity.QQ = dr["QQ"] as string; Entity.Phone = dr["Phone"] as string; Entity.CompanyName = dr["CompanyName"] as string; Entity.CompanyAddress = dr["CompanyAddress"] as string; Entity.Job = dr["Job"] as string; Entity.PositionX = dr["PositionX"] as double?; Entity.PositionY = dr["PositionY"] as double?; Entity.CheckState = dr["CheckState"] as int?; Entity.ModifyTime = dr["ModifyTime"] as DateTime?; Entity.CreateTime = dr["CreateTime"] as DateTime?; Entity.Memo = dr["Memo"] as string; return Entity; }