private void btndlt_Click(object sender, EventArgs e) { if (dataGridView1.CurrentRow != null) { if (MessageBox.Show("Bạn Muốn Xóa Thông Tin Khách Hàng Này?", "Chú Ý !!!", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { var result = SQLProvider.Execute("DELETE FROM [dbo].[Transaction] WHERE CustomerId = @CustomerId;" + "DELETE FROM [dbo].[Account] WHERE CustomerId = @CustomerId; " + "DELETE FROM [dbo].[User] WHERE CustomerId = @CustomerId; " + "DELETE FROM [dbo].[Customer] WHERE CustomerId = @CustomerId; " , paramters: new Dictionary <string, object> { { "CustomerId", dataGridView1.CurrentRow.Cells[0].Value } }); if (result) { //show lên 1 cái form MessageBox.Show("Xóa Thành Công", "Xóa", MessageBoxButtons.OK, MessageBoxIcon.Information); LoadCustomer(); } else { MessageBox.Show("Xóa Không Thành Công", "Lỗi !!", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } }
//根据车牌查找所有对应的待出车记录 public XmlDocument getListByLicenseID(string _reqLicenseID) { this.result = XmlProvider.Document("sqldata"); try { string _sql = readXml("getListByLicenseID"); //读取数据 using (SqlCommand _cmd = new SqlCommand()) { _cmd.Connection = SQLConfig.Connection(this.conn); _cmd.CommandText = _sql; SqlParameter _appLicenseID = new SqlParameter("LicenseID", SqlDbType.NVarChar, 50); _appLicenseID.Value = _reqLicenseID; _cmd.Parameters.Add(_appLicenseID); result = SQLProvider.GetData(_cmd); } } catch (Exception _exc) { Provider.LogErr(this.result, _exc); } return(this.result); }
public static SQLProvider GetSQLProvider(this string provider) { SQLProvider deffinedSQLProvider = SQLProvider.MS_SQL; switch (provider) { case "MS_SQL": deffinedSQLProvider = SQLProvider.MS_SQL; break; case "My_SQL": deffinedSQLProvider = SQLProvider.My_SQL; break; case "SQLite": deffinedSQLProvider = SQLProvider.SQLite; break; case "None": default: deffinedSQLProvider = SQLProvider.None; break; } return(deffinedSQLProvider); }
//修改司机 public XmlDocument motifyDriver(string _driverID, string _driverName, string _driverAccount, string _carTelephone, string _licenseID) { result = XmlProvider.Document("configdata"); string _sql = readXml("motifyDriver"); using (SqlCommand _cmd = new SqlCommand()) { _cmd.Connection = SQLConfig.Connection(this.conn); _cmd.CommandText = _sql; SqlParameter driverID = new SqlParameter("DriverID", SqlDbType.NVarChar, 50); driverID.Value = _driverID; _cmd.Parameters.Add(driverID); SqlParameter driverName = new SqlParameter("DriverName", SqlDbType.NVarChar, 50); driverName.Value = _driverName; _cmd.Parameters.Add(driverName); SqlParameter driverAccount = new SqlParameter("DriverAccount", SqlDbType.NVarChar, 50); driverAccount.Value = _driverAccount; _cmd.Parameters.Add(driverAccount); SqlParameter carTelephone = new SqlParameter("CarTelephone", SqlDbType.NVarChar, 50); carTelephone.Value = _carTelephone; _cmd.Parameters.Add(carTelephone); SqlParameter licenseID = new SqlParameter("LicenseID", SqlDbType.NVarChar, 50); licenseID.Value = _licenseID; _cmd.Parameters.Add(licenseID); result = SQLProvider.Transcation(_cmd); } return(result); }
//延期返回 public XmlDocument delayApply(string _guid, int _delayDays, DateTime _delyEndTime) { result = XmlProvider.Document("sqldata"); string _sql = readXml("delayApply"); //读取数据 using (SqlCommand _cmd = new SqlCommand()) { _cmd.Connection = SQLConfig.Connection(this.conn); _cmd.CommandText = _sql; SqlParameter _applyID = new SqlParameter("CarAppliedID", SqlDbType.NVarChar, 50); _applyID.Value = _guid; _cmd.Parameters.Add(_applyID); SqlParameter _endTime = new SqlParameter("EndTime", SqlDbType.NVarChar, 50); _endTime.Value = _delyEndTime; _cmd.Parameters.Add(_endTime); SqlParameter _days = new SqlParameter("Days", SqlDbType.Int); _days.Value = _delayDays; _cmd.Parameters.Add(_days); result = SQLProvider.Transcation(_cmd); } return(result); }
/// <summary> /// 添加一个临时调度员 /// </summary> /// <param name="_permitAccount">临时调度员账号</param> /// <returns></returns> public XmlDocument addLsDispatcher(string _permitAccount) { result = XmlProvider.Document("configdata"); string _sql = readXml("addLsDispather");//Dispather.xml中的添加临时调度员的标签的type为addLsDispather using (SqlCommand _cmd = new SqlCommand()) { _cmd.Connection = SQLConfig.Connection(this.conn); _cmd.CommandText = _sql; SqlParameter resourceID = new SqlParameter("ResourceID", SqlDbType.NVarChar, 50); resourceID.Value = "LSSYSTEM"; _cmd.Parameters.Add(resourceID); SqlParameter resourcePermit = new SqlParameter("ResourcePermit", SqlDbType.NVarChar, 50); resourcePermit.Value = "LSADMIN"; _cmd.Parameters.Add(resourcePermit); SqlParameter resourcePermitLev = new SqlParameter("ResourcePermitLev", SqlDbType.Int); resourcePermitLev.Value = Convert.ToInt32(1); _cmd.Parameters.Add(resourcePermitLev); //临时调度员账号的账号名称 SqlParameter permitAccount = new SqlParameter("PermitAccount", SqlDbType.NVarChar, 50); permitAccount.Value = _permitAccount; _cmd.Parameters.Add(permitAccount); result = SQLProvider.Transcation(_cmd); } return(result); }
//拒绝预约 public XmlDocument upStauteRefuse(string _guid, string _statue, string _reson) { result = XmlProvider.Document("sqldata"); string _sql = readXml("upStauteRefuse"); //读取数据 using (SqlCommand _cmd = new SqlCommand()) { _cmd.Connection = SQLConfig.Connection(this.conn); _cmd.CommandText = _sql; SqlParameter _applyID = new SqlParameter("CarAppliedID", SqlDbType.NVarChar, 50); _applyID.Value = _guid; _cmd.Parameters.Add(_applyID); SqlParameter _refuseReson = new SqlParameter("RefuseReson", SqlDbType.NVarChar, 200); _refuseReson.Value = _reson; _cmd.Parameters.Add(_refuseReson); SqlParameter _statues = new SqlParameter("AppliedStatue", SqlDbType.NVarChar, 50); _statues.Value = _statue; _cmd.Parameters.Add(_statues); result = SQLProvider.Transcation(_cmd); } return(result); }
public ConstructionReportViewModel( IMillReportsRepository repo, IJointRepository repoJoint, IUserNotify notify) { this.repo = repo; this.notify = notify; this.data = repo.GetPipelineElements(SQLProvider.GetQuery(SQLProvider.SQLStatic.GetWeldedParts).ToString()); if (this.data == null || this.data.Rows.Count <= 0) { log.Warn("Report at Construction: Data Table of Pieces is NULL or empty."); } this.partDataList = FormWeldedParts(data); this.Joints = repoJoint.GetAll() .Where <construct.Joint>(x => x.FirstElement != null && x.SecondElement != null) .ToList <construct.Joint>(); if (this.Joints == null || this.Joints.Count <= 0) { log.Warn("Report at Construction: List of Joints is NULL or empty."); } createCommand = ViewModelSource .Create <CreateReportCommand>(() => new CreateReportCommand(this, repo, notify)); previewCommand = ViewModelSource .Create <PreviewReportCommand>(() => new PreviewReportCommand(this, repo, notify)); reportCommand = ViewModelSource .Create <ReportCommand>(() => new ReportCommand(this, repo, notify)); }
private XmlDocument TokenExecute(string _txt, string _token) { XmlDocument _result = XmlProvider.Document("sqldata"); try { using (SqlCommand _cmd = new SqlCommand()) { _cmd.Connection = SQLConfig.Connection(this.conn); _cmd.CommandText = _txt; SqlParameter _id = new SqlParameter("id", SqlDbType.NVarChar, 50); _id.Value = _token; _cmd.Parameters.Add(_id); SqlParameter _ip = new SqlParameter("ip", SqlDbType.NVarChar, 50); _ip.Value = this.ip; _cmd.Parameters.Add(_ip); SqlParameter _client = new SqlParameter("client", SqlDbType.NVarChar, 50); _client.Value = this.client; _cmd.Parameters.Add(_client); SqlParameter _expired = new SqlParameter("expired", SqlDbType.DateTime); _expired.Value = DateTime.Now.AddHours(1); _cmd.Parameters.Add(_expired); _result = SQLProvider.Transcation(_cmd); } } catch (Exception _exc) { Provider.LogErr(_result, _exc); } return(_result); }
/// <summary> /// 结束维修 /// </summary> /// <param name="_reqFixID"></param> /// <returns></returns> public XmlDocument endFixedStatue(string _reqFixID) { result = XmlProvider.Document("configdata"); string _sql = readXml("endFixedStatue"); try { using (SqlCommand _cmd = new SqlCommand()) { _cmd.Connection = SQLConfig.Connection(this.conn); _cmd.CommandText = _sql; SqlParameter _guid = new SqlParameter("FixID", SqlDbType.NVarChar, 50); _guid.Value = _reqFixID; _cmd.Parameters.Add(_guid); SqlParameter _endTime = new SqlParameter("EndTime", SqlDbType.NVarChar, 50); _endTime.Value = DateTime.Now.ToString(); _cmd.Parameters.Add(_endTime); result = SQLProvider.Transcation(_cmd); } } catch (Exception _exc) { Provider.LogErr(result, _exc); } return(this.result); }
/// <summary> /// 查询某日某车是否有维修记录 /// </summary> /// <param name="_reqLicenseID">车牌</param> /// <param name="_reqDate">日期</param> /// <returns>维修记录</returns> public XmlDocument getDayFixedByLicense(string _reqLicenseID, string _reqDate) { result = XmlProvider.Document("configdata"); string _sql = readXml("getDayFixedByLicense"); try { using (SqlCommand _cmd = new SqlCommand()) { _cmd.Connection = SQLConfig.Connection(this.conn); _cmd.CommandText = _sql; SqlParameter _licenseID = new SqlParameter("LicenseID", SqlDbType.NVarChar, 50); _licenseID.Value = _reqLicenseID; _cmd.Parameters.Add(_licenseID); SqlParameter _startTime = new SqlParameter("StartTime", SqlDbType.NVarChar, 50); _startTime.Value = Convert.ToDateTime(_reqDate); _cmd.Parameters.Add(_startTime); result = SQLProvider.GetData(_cmd); } } catch (Exception _exc) { Provider.LogErr(result, _exc); } return(this.result); }
/// <summary> /// 查询某车牌的车辆在某天的车辆状态 /// </summary> /// <param name="_LicenseID"></param> /// <param name="_Day"></param> /// <returns></returns> public string getCarStateByLicenseIDAndDay(string _LicenseID, string _Day) { result = XmlProvider.Document("configdata"); string _sql = readXml("getCarStateByLicenseIDAndDay");//Car.xml 中的 查询某车牌的车辆在某天的车辆状态 的标签的 type 为 getCarStateByLicenseIDAndDay using (SqlCommand _cmd = new SqlCommand()) { _cmd.Connection = SQLConfig.Connection(this.conn); _cmd.CommandText = _sql; SqlParameter _dChangeDateTime = new SqlParameter("ChangeDateTime", SqlDbType.NVarChar, 50); _dChangeDateTime.Value = _Day; _cmd.Parameters.Add(_dChangeDateTime); SqlParameter _dLicenseID = new SqlParameter("LicenseID", SqlDbType.NVarChar, 50); _dLicenseID.Value = _LicenseID; _cmd.Parameters.Add(_dLicenseID); result = SQLProvider.GetData(_cmd); } if (this.result.DocumentElement.SelectSingleNode("SchemaTable") == null) { return(""); } else { return(this.result.DocumentElement.SelectSingleNode("SchemaTable/NewCarState").InnerText.ToString().Trim());//车辆状态 } }
/// <summary> /// 插入车辆状态更改记录 /// </summary> /// <param name="_parGuid"></param> /// <param name="_parLicenseID"></param> /// <param name="_parState"></param> /// <returns></returns> public XmlDocument insertChangeState(string _parLicenseID, string _parState) { result = XmlProvider.Document("configdata"); string _sql = readXml("insertChangeState"); using (SqlCommand _cmd = new SqlCommand()) { _cmd.Connection = SQLConfig.Connection(this.conn); _cmd.CommandText = _sql; SqlParameter _guid = new SqlParameter("Guid", SqlDbType.NVarChar, 50); _guid.Value = Provider.GUID; _cmd.Parameters.Add(_guid); SqlParameter _licenseid = new SqlParameter("LicenseID", SqlDbType.NVarChar, 50); _licenseid.Value = _parLicenseID; _cmd.Parameters.Add(_licenseid); SqlParameter _state = new SqlParameter("NewCarState", SqlDbType.NVarChar, 50); _state.Value = _parState; _cmd.Parameters.Add(_state); SqlParameter _datetime = new SqlParameter("ChangeDatetime", SqlDbType.NVarChar, 50); _datetime.Value = DateTime.Now; _cmd.Parameters.Add(_datetime); result = SQLProvider.Transcation(_cmd); } return(this.result); }
//司机与车辆绑定 public XmlDocument Bound(string _licenseID, string _account) { result = XmlProvider.Document("data"); string _sql = readXml("Bound"); using (SqlCommand _cmd = new SqlCommand()) { _cmd.Connection = SQLConfig.Connection(this.conn); _cmd.CommandText = _sql; SqlParameter licenseID = new SqlParameter("LicenseID", SqlDbType.NVarChar, 50); licenseID.Value = _licenseID; _cmd.Parameters.Add(licenseID); SqlParameter account = new SqlParameter("DriverAccount", SqlDbType.NVarChar, 50); account.Value = _account; _cmd.Parameters.Add(account); XmlDocument _api = XmlProvider.Document("api"); _api.Load("http://api.qgj.cn/webapi/profile.asmx/GetUser?User="******"ITEM/name").InnerText; SqlParameter name = new SqlParameter("DriverName", SqlDbType.NVarChar, 50); name.Value = _name; _cmd.Parameters.Add(name); result = SQLProvider.Transcation(_cmd); } return(result); }
//判断是否为司机 public string isDriver(string _account) { XmlDocument _result = XmlProvider.Document("data"); string _sql = readXml("getDriver"); //判断司机表是否存在该用户 using (SqlCommand _cmd = new SqlCommand()) { _cmd.Connection = SQLConfig.Connection(this.conn); _cmd.CommandText = _sql; SqlParameter _driverAccount = new SqlParameter("DriverAccount", SqlDbType.NVarChar, 50); _driverAccount.Value = _account; _cmd.Parameters.Add(_driverAccount); _result = SQLProvider.GetData(_cmd); } if (_result.DocumentElement.SelectSingleNode("SchemaTable") != null) { return(_result.DocumentElement.SelectSingleNode("SchemaTable/Player").InnerText.Trim()); } else { return(""); } }
public IQueryExecutor GetQueryExecutorFromProviderType(SQLProvider provider) { switch (provider) { case SQLProvider.SQLServer: return((IQueryExecutor)Lifecycle.Container.GetInstance(typeof(IQueryExecutor), Lifecycle.SQLServerKey)); default: throw new UnknownSQLProviderException(); } }
public string AddEvent() { SQLProvider provider = new SQLProvider(); Task <Stream> task = Request.Content.ReadAsStreamAsync(); task.Wait(); Stream EntityStream = task.Result; BinaryFormatter bf = new BinaryFormatter(); Notifications events = (Notifications)bf.Deserialize(EntityStream); return(provider.AddNotification(events.ListOfEvents[0])); }
private void CheckDB() { SQLProvider selectedProvider = cmbSQLProvider.SelectedItem.ToString().GetSQLProvider(); settings.ProviderName = selectedProvider; bool existDB = false; switch (selectedProvider) { case SQLProvider.My_SQL: { if (!string.IsNullOrWhiteSpace(tbHost?.Text)) { settings = CheckMySQLDB(settings); if (cmbDataBases?.Items?.Count > 0) { existDB = true; } } else { tbResultShow.AppendLine("Check Host name: " + tbHost?.Text); return; } break; } case SQLProvider.SQLite: { settings = CheckSQLiteDB(settings); existDB = !string.IsNullOrWhiteSpace(settings?.Database); break; } default: break; } if (existDB) { if (cmbTables?.Items?.Count > 0) { cmbTables.Enabled = cmbTables?.Items?.Count > 1; } btnSave.Enabled = true; } tbName.Text = SetNameConnection(); }
public IQueryBuilder ResolveFromSQLProvider(SQLProvider provider) { switch (provider) { case SQLProvider.SQLServer: var queryBuilder = (IQueryBuilder)Lifecycle.Container.GetInstance(typeof(IQueryBuilder), Lifecycle.SQLServerKey); return(queryBuilder); default: throw new UnknownSQLProviderException(); } }
//获取所有车辆 public XmlDocument getCarList() { result = XmlProvider.Document("configdata"); string _sql = readXml("getCarList"); using (SqlCommand _cmd = new SqlCommand()) { _cmd.Connection = SQLConfig.Connection(this.conn); _cmd.CommandText = _sql; result = SQLProvider.GetData(_cmd); } return(this.result); }
//获取调度员账号 public string getSysAccount() { result = XmlProvider.Document("sqldata"); string _sql = readXml("getSysAccount"); using (SqlCommand _cmd = new SqlCommand()) { _cmd.Connection = SQLConfig.Connection(this.conn); _cmd.CommandText = _sql; result = SQLProvider.GetData(_cmd); } return(result.DocumentElement.SelectSingleNode("SchemaTable/PermitAccount").InnerText.ToString().Trim()); }
//获取有出车天数的车牌 public string getApplyCount(string _SqlLicenseID, DateTime _SqlStart, DateTime _SqlEnd) { result = XmlProvider.Document("sqldata"); string _sql = "Select Count(*) AS NUM from Car_Applied where licenseid='" + _SqlLicenseID + "' and StartTime>='" + _SqlStart.ToString() + "' and StartTime<='" + _SqlEnd.ToString() + "'"; //读取数据 using (SqlCommand _cmd = new SqlCommand()) { _cmd.Connection = SQLConfig.Connection(this.conn); _cmd.CommandText = _sql; this.result = SQLProvider.GetData(_cmd); } return(result.DocumentElement.SelectSingleNode("SchemaTable/Num").InnerText.ToString().Trim()); }
/// <summary> /// 查询所有车辆状态为出行、维修、空闲的车辆的车牌集合 /// </summary> /// <returns></returns> public XmlDocument getEnableCarLicense() { result = XmlProvider.Document("configdata"); string _sql = readXml("getEnableCarLicense");//Car.xml中的获取所有车辆状态为出行、维修、空闲的车辆的车牌的标签的type为 getEnableCarLicense using (SqlCommand _cmd = new SqlCommand()) { _cmd.Connection = SQLConfig.Connection(this.conn); _cmd.CommandText = _sql; this.result = SQLProvider.GetData(_cmd); } return(result); }
//获取有出车天数的车牌 public XmlDocument getCarListOnDesc(string _licenseidList) { result = XmlProvider.Document("sqldata"); string _sql = " SELECT SUM(CAST(DAYS as int)) AS DAYS ,LicenseID FROM CAR_APPLIED WHERE AppliedStatue!='拒绝' and AppliedStatue!='取消' AND LicenseID!='NULL' AND " + _licenseidList + " group by licenseid order by DAYS ASC"; //读取数据 using (SqlCommand _cmd = new SqlCommand()) { _cmd.Connection = SQLConfig.Connection(this.conn); _cmd.CommandText = _sql; this.result = SQLProvider.GetData(_cmd); } return(result); }
private void GetUsedProduct() { try { if (viewModel.Types.Count > 0) { StringBuilder GetAllUsedProducts = new StringBuilder(); foreach (var item in viewModel.Types) { if (!string.IsNullOrWhiteSpace(GetAllUsedProducts.ToString())) { GetAllUsedProducts.Append(" UNION "); } switch (item) { case PartType.Undefined: GetAllUsedProducts.Append(" "); break; case PartType.Pipe: GetAllUsedProducts.Append(SQLProvider.GetQuery(SQLProvider.SQLStatic.GetAllUsedPipe)); GetAllUsedProducts.Append(" "); break; case PartType.Spool: GetAllUsedProducts.Append(SQLProvider.GetQuery(SQLProvider.SQLStatic.GetAllUsedSpool)); GetAllUsedProducts.Append(" "); break; case PartType.Component: GetAllUsedProducts.Append(" "); GetAllUsedProducts.Append(SQLProvider.GetQuery(SQLProvider.SQLStatic.GetAllUsedComponent)); break; default: GetAllUsedProducts.Append(" "); break; } } data = repo.GetUsedProducts(viewModel.StartPK, viewModel.EndPK, GetAllUsedProducts.ToString()); } } catch (RepositoryException ex) { log.Error(string.Concat(ex.InnerException.Message, ex.Message)); notify.ShowFailure(ex.InnerException.Message, ex.Message); } }
//获取需要调度员控制的车辆数量 public int getControlNum() { result = XmlProvider.Document("configdata"); string _sql = readXml("getControlCarNum"); using (SqlCommand _cmd = new SqlCommand()) { _cmd.Connection = SQLConfig.Connection(this.conn); _cmd.CommandText = _sql; result = SQLProvider.GetData(_cmd); } return(Convert.ToInt32(result.DocumentElement.SelectSingleNode("SchemaTable/SetValue").InnerText.ToString().Trim())); }
public byte[] GetTasks() { TasksCollection tasks = new TasksCollection(); SQLProvider sqlp = new SQLProvider(); tasks = sqlp.GetAllTasks(); MemoryStream memorystream = new MemoryStream(); BinaryFormatter bf = new BinaryFormatter(); bf.Serialize(memorystream, tasks); memorystream.Flush(); memorystream.Position = 0; byte[] Bytes = memorystream.ToArray(); return(Bytes); }
private void setdata(DataRow customerinfo) { string qry = string.Format(@"SELECT CustomerId, FirstName, LastName, IDNumber, Phone FROM [dbo].[Customer] WHERE CustomerId = {0}", Program.CustomerId.ToString()); string qry1 = string.Format(@"SELECT AccountNumber,CreateTime,ExpireDate,Money FROM [dbo].[Account] WHERE CustomerId={0}", Program.CustomerId.ToString()); var infocustomers = SQLProvider.Single(qry); var info = SQLProvider.Single(qry1); textBox1.Text = infocustomers["FirstName"] + string.Empty; textBox2.Text = infocustomers["LastName"] + string.Empty; textBox3.Text = infocustomers["IDNumber"] + string.Empty; textBox7.Text = infocustomers["Phone"] + string.Empty; textBox9.Text = info["AccountNumber"] + string.Empty; textBox5.Text = info["CreateTime"] + string.Empty; textBox8.Text = info["ExpireDate"] + string.Empty; txtmoney.Text = info["Money"] + string.Empty; }
//获取待联系方式的车辆记录 public XmlDocument getSingleCarAndCarTel(string _guid) { result = XmlProvider.Document("configdata"); string _sql = readXml("getSingleCarAndCarTel"); using (SqlCommand _cmd = new SqlCommand()) { _cmd.Connection = SQLConfig.Connection(this.conn); _cmd.CommandText = _sql; SqlParameter guid = new SqlParameter("Guid", SqlDbType.NVarChar, 50); guid.Value = _guid; _cmd.Parameters.Add(guid); result = SQLProvider.GetData(_cmd); } return(this.result); }
//获取待联系方式的车辆记录ByLicenseID public XmlDocument getSingleCarByLicenseID(string _licenseID) { result = XmlProvider.Document("configdata"); string _sql = readXml("getSingleCarByLicenseID"); using (SqlCommand _cmd = new SqlCommand()) { _cmd.Connection = SQLConfig.Connection(this.conn); _cmd.CommandText = _sql; SqlParameter licenseID = new SqlParameter("LicenseID", SqlDbType.NVarChar, 50); licenseID.Value = _licenseID; _cmd.Parameters.Add(licenseID); result = SQLProvider.GetData(_cmd); } return(this.result); }