/// <summary> /// 增加一条数据 /// </summary> public int Add(Model.Company model) { StringBuilder strSql = new StringBuilder(); strSql.Append("INSERT INTO Company("); strSql.Append("Name,Location,LAT,LON,UAVNum,LinkPhone,Linker,WebSite)"); strSql.Append(" VALUES ("); strSql.Append("@in_Name,@in_Location,@in_LAT,@in_LON,@in_UAVNum,@in_LinkPhone,@in_Linker,@in_WebSite)"); // ,Buffer+ "geometry::STGeomFromText('POLYGON ((" + model.Buffer + "))', 4326))" SqlParameter[] cmdParms = new SqlParameter[] { new SqlParameter("@in_Name", SqlDbType.NVarChar), new SqlParameter("@in_Location", SqlDbType.NVarChar), new SqlParameter("@in_LON", SqlDbType.Decimal), new SqlParameter("@in_LAT", SqlDbType.Decimal), new SqlParameter("@in_UAVNum", SqlDbType.Int), new SqlParameter("@in_LinkPhone", SqlDbType.NVarChar), new SqlParameter("@in_Linker", SqlDbType.NVarChar), new SqlParameter("@in_WebSite", SqlDbType.NVarChar) }; cmdParms[0].Value = model.Name; cmdParms[1].Value = model.Location; cmdParms[2].Value = model.LON; cmdParms[3].Value = model.LAT; cmdParms[4].Value = model.UAVNum; cmdParms[5].Value = model.LinkPhone; cmdParms[6].Value = model.Linker; cmdParms[7].Value = model.WebSite; return(DbHelperSQL.ExecuteSql(strSql.ToString(), cmdParms)); }
internal int SaveAll(Model.Company company) { string query = @"INSERT INTO tblCompany (CompanyName) VALUES('" + company.CompanyName + "')"; int rowCount = _dbCompanRepository.SaveOrDelete(query); return(rowCount); }
public List <Company> Read() { string companyReadCmd = "SELECT Id, Name, FoundedDate FROM Company WHERE DeleteTime IS NULL"; List <Model.Company> retVal = new List <Company>(); using (SqlConnection sqlCon = new SqlConnection(connectionString)) { using (SqlCommand cmd = new SqlCommand(companyReadCmd, sqlCon)) { sqlCon.Open(); using (SqlDataReader reader = cmd.ExecuteReader()) { while (reader.Read()) { Model.Company company = new Model.Company(); company.Id = (int)reader["Id"]; company.Name = reader["Name"].ToString(); company.FoundedDate = reader["FoundedDate"] != null && reader["FoundedDate"] != DBNull.Value ? Convert.ToDateTime(reader["FoundedDate"]) : DateTime.MinValue; retVal.Add(company); } } } } return(retVal); }
public string AddCompany(Model.Company company) { MySqlCommand mySqlCmd = null; MySqlDataReader reader = null; try { // add to job order status Dictionary <string, string> insertParam = new Dictionary <string, string>(); insertParam.Add("name", company.name); insertParam.Add("address_1", company.address1); insertParam.Add("address_2", company.address2); insertParam.Add("postcode", company.postcode); insertParam.Add("state_id", company.stateId); insertParam.Add("country_id", company.countryId); insertParam.Add("registration_number", company.registrationNumber); mySqlCmd = GenerateAddCmd(TABLE_COMPANIES, insertParam); PerformSqlNonQuery(mySqlCmd); return(mySqlCmd.LastInsertedId.ToString()); } catch (Exception e) { DBLogger.GetInstance().Log(DBLogger.ESeverity.Info, e.Message); DBLogger.GetInstance().Log(DBLogger.ESeverity.Info, e.StackTrace); } finally { CleanUp(reader, mySqlCmd); } return(null); }
internal static void Validate(Model.Company company) { if (company == null) { throw new ArgumentNullException("company"); } if (company.BonusFee <= 0) { throw new ArgumentException("Match Rate must be greater then zero."); } if (company.BonusFee > 1000) { throw new ArgumentException("Match Rate must be lesser or equal to 1000."); } if (company.MaxBonusFee <= 0) { throw new ArgumentException("Match Ceiling must be greater then zero."); } if (company.MaxBonusFee > 100) { throw new ArgumentException("Match Ceiling Fee must be lesser then 100."); } ValidateVestingRules(company.VestingRules); }
public bool UpdateCompany(string companyId, Model.Company company) { MySqlCommand mySqlCmd = null; MySqlDataReader reader = null; try { Dictionary <string, string> updateParam = new Dictionary <string, string>(); updateParam.Add("name", company.name); updateParam.Add("address_1", company.address1); updateParam.Add("address_2", company.address2); updateParam.Add("postcode", company.postcode); updateParam.Add("state_id", company.stateId); updateParam.Add("country_id", company.countryId); updateParam.Add("registration_number", company.registrationNumber); Dictionary <string, string> destinationParam = new Dictionary <string, string>(); destinationParam.Add("id", companyId); mySqlCmd = GenerateEditCmd(TABLE_COMPANIES, updateParam, destinationParam); return(PerformSqlNonQuery(mySqlCmd) != 0); } catch (Exception e) { DBLogger.GetInstance().Log(DBLogger.ESeverity.Info, e.Message); DBLogger.GetInstance().Log(DBLogger.ESeverity.Info, e.StackTrace); } finally { CleanUp(reader, mySqlCmd); } return(false); }
public frmLookForQuotation(Model.Company company) { InitializeComponent(); FormUtility.FormatForm(this); gridUtility = new GridUtility(gridControl1); m_Company = company; }
/// <summary> /// 得到一个对象实体 /// </summary> public Model.Company DataRowToModel(DataRow row) { Model.Company model = new Model.Company(); if (row != null) { if (row["ID"] != null && row["ID"].ToString() != "") { model.ID = int.Parse(row["ID"].ToString()); } if (row["Name"] != null) { model.Name = row["Name"].ToString(); } if (row["Address"] != null) { model.Address = row["Address"].ToString(); } if (row["Phone"] != null) { model.Phone = row["Phone"].ToString(); } if (row["OpenTime"] != null) { model.OpenTime = row["OpenTime"].ToString(); } if (row["Summary"] != null) { model.Summary = row["Summary"].ToString(); } } return(model); }
/// <summary> /// 增加一条数据 /// </summary> public bool Add(Model.Company model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into Company("); strSql.Append("ID,Name,Address,Phone,OpenTime,Summary)"); strSql.Append(" values ("); strSql.Append("@ID,@Name,@Address,@Phone,@OpenTime,@Summary)"); SQLiteParameter[] parameters = { new SQLiteParameter("@ID", DbType.Int32, 8), new SQLiteParameter("@Name", DbType.String), new SQLiteParameter("@Address", DbType.String), new SQLiteParameter("@Phone", DbType.String), new SQLiteParameter("@OpenTime", DbType.String), new SQLiteParameter("@Summary", DbType.String) }; parameters[0].Value = model.ID; parameters[1].Value = model.Name; parameters[2].Value = model.Address; parameters[3].Value = model.Phone; parameters[4].Value = model.OpenTime; parameters[5].Value = model.Summary; int rows = DbHelperSQLite.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
[HttpDelete()] //Update public IActionResult Delete([FromBody] Model.Company value) { try { if (!_authorization.Check(Request.Headers["Authorization"])) { return(StatusCode(StatusCodes.Status401Unauthorized)); } int Id = value.Id; if (Id != 0) { int Company = _companyRepo.Update(Id, null, true); if (Company < 1) { return(StatusCode(StatusCodes.Status206PartialContent)); } else if (Company == 1) { return(StatusCode(StatusCodes.Status200OK, Company)); } else { return(StatusCode(StatusCodes.Status501NotImplemented)); } } else { return(StatusCode(StatusCodes.Status405MethodNotAllowed)); } } catch (Helper.RepoException ex) { switch (ex.Type) { case EnumResultTypes.INVALIDARGUMENT: return(StatusCode(StatusCodes.Status400BadRequest)); case EnumResultTypes.NOTFOUND: return(StatusCode(StatusCodes.Status204NoContent)); case EnumResultTypes.SQLERROR: return(StatusCode(StatusCodes.Status408RequestTimeout)); case EnumResultTypes.ERROR: return(StatusCode(StatusCodes.Status500InternalServerError)); default: return(StatusCode(StatusCodes.Status501NotImplemented)); } } catch (NullReferenceException) { return(StatusCode(StatusCodes.Status400BadRequest)); } catch (Exception ex) { ErrHandler.Go(ex, null, null); return(StatusCode(StatusCodes.Status501NotImplemented)); } }
private void paper_Load(object sender, EventArgs e) { /*this.IsMdiContainer=true;//设置父窗体是容器 * Form2 f2=new Form2();//实例化子窗体 * f2.MdiParent=this;//设置窗体的父子关系 * f2.Parent=panel2;//设置子窗体的容器为父窗体中的Panel * f2.Show();*/ String path = @"E:\Desktop\2.png"; //路径 this.pictureBox.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom; pictureBox.Image = Image.FromFile(path); Model.Images img = new Model.Images(); outtextbox_ImageNumber.Text = img.ImageNumber; outtextbox_PartsName.Text = img.PartsName; outtextbox_UpdateTime.Text = img.UpdateTime.ToShortDateString().ToString();; Model.Company com = new Model.Company(); outtextbox_CompanyName.Text = com.CompanyName; outtextbox_CompanyNumber.Text = com.CompanyNumber; Model.Product pro = new Model.Product(); outtextbox_ProductName.Text = pro.ProductName; outtextbox_ProductType.Text = pro.ProductType; }
public Model.Company getCompanyByID(string companyID) { SocketRequest = new SocketRequest(); SocketRequest.Action = ACTION.GET_COMPANY_BYID; SocketRequest.CompanyID = companyID; //send request string requestAsJSON = JsonConvert.SerializeObject(SocketRequest); communicationController.SendMessage(requestAsJSON); // used for testing purposes string JsonString = communicationController.ReadReplyMessage(); Model.Company tempCompany = new Model.Company(); communicationController.clientSocket.NoDelay = true; //deserializing tempCompany = JsonConvert.DeserializeObject <Model.Company>(JsonString); communicationController.clientSocket.Close(); if (tempCompany.companyID == null) { return(null); } else { return(tempCompany); } }
protected override void Delete() { if (this.company == null) { return; } if (MessageBox.Show(Properties.Resources.ConfirmToDelete, this.Text, MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) != DialogResult.OK) { return; } try { this.companyManager.Delete(this.company.CompanyId); this.company = this.companyManager.GetNext(this.company); if (this.company == null) { this.company = this.companyManager.GetLast(); } } catch { throw new Exception(""); } return; }
private void SaveButton_Click(object sender, EventArgs e) { Model.Company company = new Model.Company(); company.Name = nameTextBox.Text; SqlConnection _con = new SqlConnection(Model.Common.ConnectionString()); string QueryDuplicate = @"SELECT COUNT(*) FROM Companies where Name='" + company.Name + "' "; SqlCommand commandDuplicateCheck = new SqlCommand(QueryDuplicate, _con); DataTable ds = new DataTable(); SqlDataAdapter da = new SqlDataAdapter(commandDuplicateCheck); da.Fill(ds); if (ds.Rows[0][0].ToString() == "1") { string msg = "Duplicate Entry not Allowed."; MessageBox.Show(msg); } else { bool isAdded = _companyManager.Add(company: company); if (isAdded) { MessageBox.Show("Successfully Saved."); nameTextBox.Clear(); CompanyLode(); return; } MessageBox.Show("Sory! Saved failed"); } }
public Model.Company GetCompany(int cvr) { SqlConnection conn = new SqlConnection(DBConnectionString); Model.Company _company = new Model.Company(); try { conn.Open(); SqlCommand cmd = new SqlCommand("GetCompany", conn); cmd.CommandType = CommandType.StoredProcedure; SqlParameter parameter = new SqlParameter(); cmd.Parameters.Add(new SqlParameter("@CVR", cvr)); SqlDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { _company = new Model.Company(int.Parse(reader["CVR"].ToString()), reader["Name"].ToString(), int.Parse(reader["Offer_Number"].ToString()), reader["FK_Type"].ToString(), reader["FK_Traffic_Company"].ToString(), GetPermit(reader["FK_Permit"].ToString())); } reader.Close(); } catch (SqlException e) { System.Windows.MessageBox.Show(e.Message); } finally { conn.Close(); conn.Dispose(); } return(_company); }
private void repositoryItemHyperLinkEdit1_Click(object sender, EventArgs e) { this._company = this.bindingSourceCompany.Current as Model.Company; if (this._company != null) { this.action = "view"; this.Refresh(); } }
public void TestCreateCompany() { var service = new EfModelService(); var model = new Model.Company(); model.Name = DateTime.Now.Millisecond.ToString(); service.SaveCompany(model); }
/// <summary> /// Update a Company. /// </summary> public void Update(Model.Company company) { // // todo: add other logic here. // Validate(company); company.UpdateTime = DateTime.Now; accessor.Update(company); }
public frmEditProductProperties(Model.QuotationDetail quotationDetail, Model.Product product, Model.Company company) { InitializeComponent(); m_QuotationDetail = quotationDetail; m_Product = product; m_Company = company; FormUtility.FormatForm(this); lblNotify1.Text = ""; }
public CompanyEditForm() { InitializeComponent(); this.requireValueExceptions.Add(Model.Company.PROPERTY_COMPANYNAME, new AA(Properties.Resources.RequireDataForNames, this.textEditCompanyName)); this.invalidValueExceptions.Add(Model.Company.PROPERTY_COMPANYNAME, new AA("公司名稱已存在", this.textEditCompanyName)); this.action = "view"; this._company = this._companyManager.SelectIsDefaultCompany(); }
public void MyClick(ref ChooseItem item) { ChooseCompanyForm f = new ChooseCompanyForm(); if (f.ShowDialog() == System.Windows.Forms.DialogResult.OK) { Model.Company company = f.SelectedItem as Model.Company; item = new ChooseItem(company, company.CompanyId, company.CompanyName); } }
/// <summary> /// Insert a Company. /// </summary> public void Insert(Model.Company company) { // // todo:add other logic here // Validate(company); company.InsertTime = DateTime.Now; company.CompanyId = Guid.NewGuid().ToString(); accessor.Insert(company); }
protected override void MoveNext() { Model.Company company = this.companyManager.GetNext(this.company); if (bindingSourceCompany == null) { throw new InvalidOperationException(Properties.Resources.ErrorNoMoreRows); } this.company = company; }
//Shipped by private void btne_ShippedBy_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e) { Settings.BasicData.Company.ChooseCompanyForm f = new Book.UI.Settings.BasicData.Company.ChooseCompanyForm(); if (f.ShowDialog() == DialogResult.OK) { Model.Company company = f.SelectedItem as Model.Company; this.btne_ShippedBy.EditValue = string.IsNullOrEmpty(company.CompanyEnglishName) ? company.CompanyName : company.CompanyEnglishName; this.txt_ShippedByAddress.EditValue = company.CompanyAddress3; } }
/// <summary> /// gridview4单击事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void gridView4_Click(object sender, EventArgs e) { Model.Company company = this.bindingSource_company.Current as Model.Company; if (company != null) { this.currentcompany = company; this.action = "view"; this.Refresh(); } }
private void Validate(Model.Company company) { if (string.IsNullOrEmpty(company.CompanyName)) { throw new Helper.RequireValueException(Model.Company.PROPERTY_COMPANYNAME); } if (accessor.IsExistsCompanyName(company.CompanyId, company.CompanyName)) { throw new Helper.InvalidValueException(Model.Company.PROPERTY_COMPANYNAME); } }
public ActionResult Edit(Model.Company company) { if (new BLL.Company().Update(company)) { return(Json(new { success = 0, msg = "提交成功" })); } else { return(Json(new { success = 0, msg = "提交失败" })); } }
public ActionResult Add(Model.Company company) { company.Category = 1; if (new BLL.Company().Add(company) > 0) { return(Json(new { success = 0, msg = "提交成功" })); } else { return(Json(new { success = 0, msg = "提交失败" })); } }
internal bool CheckDuplecateUpdateCompany(Model.Company company) { string query = @"SELECT * FROM tblCompany WHERE CompanyName='" + company.CompanyName + "' AND Id!='" + company.Id + "'"; DataTable dt = _dbCompanRepository.CheckAll(query); if (dt.Rows.Count > 0) { return(false); } return(true); }
public Response Put(string companyId, [FromBody] Model.Company company) { var result = companyDao.UpdateCompany(companyId, company); if (false == result) { response = Utility.Utils.SetResponse(response, false, Constant.ErrorCode.EGeneralError); return(response); } response = Utility.Utils.SetResponse(response, true, Constant.ErrorCode.ESuccess); return(response); }