/// <summary> /// 新增账套 /// </summary> /// <param name="acc"></param> public void creatNew() { try { account.accountID = CommonTools.newAccountID(); account.databaseName = account.accountID.Replace("-", ""); account.creatDate = DateTime.Now.ToString("yyyy-MM-dd"); string filepath = AppDomain.CurrentDomain.BaseDirectory; account.databasePath = filepath + "Database\\"; StringBuilder sqlstr = new StringBuilder(); sqlstr.Append("insert into Account ("); sqlstr.Append("accountID, accountName, databasePath, databaseName, remark,status, creatDate"); sqlstr.Append(") values ("); sqlstr.Append("'" + account.accountID + "', "); sqlstr.Append("'" + account.accountName + "', "); sqlstr.Append("'" + account.databasePath + "', "); sqlstr.Append("'" + account.databaseName + "', "); sqlstr.Append("'" + account.remark + "', "); sqlstr.Append("'" + account.status + "', "); sqlstr.Append("'" + account.creatDate + "' )"); db.ExecVoid(sqlstr.ToString(), "jinxiaocun"); string filePath1 = Path.Combine(filepath, "Default\\base.psi"); string filePath2 = Path.Combine(filepath, "Default\\base_log.psi"); string file1 = account.databasePath + account.databaseName + ".mdf"; string file2 = account.databasePath + account.databaseName + "_log.ldf"; File.Copy(filePath1, file1, true); AddSecurityControll(file1); File.Copy(filePath2, file2, true); AddSecurityControll(file2); StringBuilder str = new StringBuilder(); str.Append("EXEC sp_attach_db "); str.Append("@dbname='" + account.databaseName + "', "); str.Append("@filename1='" + file1 + "', "); str.Append("@filename2='" + file2 + "' "); db.ExecVoid(str.ToString(), "master"); code = "0000"; result = "创建成功!"; } catch (Exception ex) { code = "9999"; result = ex.ToString(); } }
public void Save() { try { if (!string.IsNullOrWhiteSpace(Client.ClientCode)) { Client.SID = CommonTools.GetNewID("KH", Account); StringBuilder sqlstr = new StringBuilder(); sqlstr.Append("insert into Client ("); sqlstr.Append("SID, ClientCode, ClientName, ClientType, Address, Contact, Phone, WeChat, QQ, Email, Fax, Bank, Account, Remark, Creator, CreatDate, Status"); sqlstr.Append(") values ("); sqlstr.Append("'" + Client.SID + "',"); sqlstr.Append("'" + Client.ClientCode + "',"); sqlstr.Append("'" + Client.ClientName + "',"); sqlstr.Append("'" + Client.ClientType + "',"); sqlstr.Append("'" + Client.Address + "',"); sqlstr.Append("'" + Client.Contact + "',"); sqlstr.Append("'" + Client.Phone + "',"); sqlstr.Append("'" + Client.WeChat + "',"); sqlstr.Append("'" + Client.QQ + "',"); sqlstr.Append("'" + Client.Email + "',"); sqlstr.Append("'" + Client.Fax + "',"); sqlstr.Append("'" + Client.Bank + "',"); sqlstr.Append("'" + Client.Account + "',"); sqlstr.Append("'" + Client.Remark + "',"); sqlstr.Append("'" + Client.Creator + "',"); sqlstr.Append("'" + Client.CreatDate + "',"); sqlstr.Append("'" + Client.Status + "')"); db.ExecVoid(sqlstr.ToString(), Account); Code = "0000"; Msg = "保存成功"; } else { Code = "0001"; Msg = "没有可保存的信息"; } } catch (Exception ex) { Code = "0002"; Msg = ex.ToString(); } }
public void Save() { try { if (!string.IsNullOrWhiteSpace(UserInfo.UserName)) { UserInfo.SID = CommonTools.GetNewID("RY", Account); StringBuilder sqlstr = new StringBuilder(); sqlstr.Append("insert into UserInfo ("); sqlstr.Append("SID, LoginID, Password, UserName, Phone, Status,DepartID, Creator, CreatDate"); sqlstr.Append(") values ("); sqlstr.Append("'" + UserInfo.SID + "',"); sqlstr.Append("'" + UserInfo.LoginID + "',"); sqlstr.Append("'" + UserInfo.Password + "',"); sqlstr.Append("'" + UserInfo.UserName + "',"); sqlstr.Append("'" + UserInfo.Phone + "',"); sqlstr.Append("'" + UserInfo.Status + "',"); sqlstr.Append("'" + UserInfo.DepartID + "',"); sqlstr.Append("'" + UserInfo.Creator + "',"); sqlstr.Append("'" + UserInfo.CreatDate + "')"); db.ExecVoid(sqlstr.ToString(), Account); Code = "0000"; Msg = "新增成功"; } else { Code = "0001"; Msg = "无新增用户信息"; } } catch (Exception ex) { Code = "0002"; Msg = ex.ToString(); } }