private void btnRestore_Click(object sender, RoutedEventArgs e) { if (String.IsNullOrEmpty(txtRestorePath.Text)) { System.Windows.MessageBox.Show("请选择还原路径"); return; } try { using (var visaORM = new visaEntities()) { string sql = @"use master RESTORE DATABASE [QZ] FROM DISK = N'" + txtRestorePath.Text + "' WITH FILE = 1, NOUNLOAD , STATS = 10, RECOVERY , REPLACE "; int rowCount = visaORM.ExecuteStoreCommand(sql); } System.Windows.Forms.MessageBox.Show("数据还原成功"); } catch (Exception err) { Log.WriteLog.WriteErorrLog(err); System.Windows.Forms.MessageBox.Show(err.Message); } }
private void btnBackup_Click(object sender, RoutedEventArgs e) { if (String.IsNullOrEmpty(txtBackupPath.Text)) { System.Windows.MessageBox.Show("请选择备份路径"); return; } try { using (var visaORM = new visaEntities()) { string sql = @"BACKUP DATABASE [visa] TO DISK = N'" + txtBackupPath.Text + "' WITH NOINIT , NOUNLOAD , NAME = N'Visa Back', NOSKIP , STATS = 10, NOFORMAT "; int rowCount = visaORM.ExecuteStoreCommand(sql); } System.Windows.Forms.MessageBox.Show("备份成功"); } catch (Exception err) { Log.WriteLog.WriteErorrLog(err); System.Windows.Forms.MessageBox.Show(err.Message); } }
private void SetControlPositionInReport(Report.ReportQZ report, int groupID) { report.xrLabelMemo.Location = GetLabelPoint("Memo", groupID); report.xrLabelPDate.Location = GetLabelPoint("PDate", groupID); report.xrLabelDDate.Location = GetLabelPoint("DDate", groupID); report.xrLabelUserName.Location = GetLabelPoint("UserName", groupID); report.xrLabelNamNimh.Location = GetLabelPoint("NamNimh", groupID); report.xrLabelPID.Location = GetLabelPoint("PID", groupID); report.xrLabelMDate.Location = GetLabelPoint("MDate", groupID); report.xrLabelType.Location = GetLabelPoint("Type", groupID); report.xrLabelTimes.Location = GetLabelPoint("Times", groupID); report.xrLabelDuty.Location = GetLabelPoint("Duty", groupID); report.xrLabelVID.Location = GetLabelPoint("VID", groupID); report.xrLabelBirthday.Visible = true; report.xrLabelBirthday.Location = GetLabelPoint("BDate", groupID); if (report.xrLabelBirthday.Location.X == 0 && report.xrLabelBirthday.Location.Y == 0) report.xrLabelBirthday.Visible = false; report.xrCustomerName.Visible = true; report.xrCustomerName.Location = GetLabelPoint("CustomerName", groupID); if (report.xrCustomerName.Location.X == 0 && report.xrCustomerName.Location.Y == 0) report.xrCustomerName.Visible = false; report.xrCountry.Visible = true; report.xrCountry.Location = GetLabelPoint("Country", groupID); if (report.xrCountry.Location.X == 0 && report.xrCountry.Location.Y == 0) report.xrCountry.Visible = false; visaEntities DataContextP = new visaEntities(); TB_Position pageSize = DataContextP.TB_Position.FirstOrDefault(p => p.FName == "PageSize" && p.FGroupID == groupID); if (pageSize != null) { report.PageWidth = Convert.ToInt32(pageSize.FX); report.PageHeight = Convert.ToInt32(pageSize.FY); } else { report.PageWidth = 3000; report.PageHeight = 2100; } if (groupID == 1) report.Font = new System.Drawing.Font("Times New Roman", 10); else report.Font = new System.Drawing.Font("Times New Roman", 12); }
System.Drawing.Point GetLabelPoint(string LabelName, int GroupID) { int X; int Y; visaEntities visaORM = new visaEntities(); TB_Position pModel = visaORM.TB_Position.OrderByDescending(p => p.FCreateDate).FirstOrDefault(p => p.FName == LabelName && p.FGroupID == GroupID); if (pModel == null) { MessageBox.Show(LabelName + "未设置位置数值"); return new System.Drawing.Point(0, 0); } else { X = (int)pModel.FX; Y = (int)pModel.FY; return new System.Drawing.Point(X, Y); } }
private static string GetVisaNumberString(string FirstLetter, int NumberLenght, ref int i) { string finalQZID = FirstLetter + ("0000000" + i.ToString()).Substring(NumberLenght); visaEntities visaORM = new visaEntities(); var isUsedObj = visaORM.QZKC.FirstOrDefault(q => q.FIsUse == true && q.FQZID == finalQZID); if (isUsedObj != null) { i++; return GetVisaNumberString(FirstLetter, NumberLenght, ref i); } return finalQZID; }