public void funLoad() { xDoc = new XmlDocument(); if (Command == "New") { xDoc.Load(Application.StartupPath + "/TempDoc/Emp.xml"); } else { ConnectServer.cConection cConn = new ConnectServer.cConection(cMain.UserName); string strDoc = cConn.getLastDoc(cMain.Connection, cMain.OfficeSpaceId, cMain.DatabaseName, "emp_job", int.Parse(ID_TEMP)); xDoc.LoadXml(strDoc); } string RootPath = "//Document/Data/Section[@ID='1']/Items[@Name='Data']"; ucTxbName._XPath = RootPath + "/Item[@Name='Name']"; ucTxbPosition._XPath = RootPath + "/Item[@Name='Position']"; ucNDSalary._XPath = RootPath + "/Item[@Name='Salary']"; picImage._XPath = RootPath + "/Item[@Name='Image']"; ucGridWork._XPath = "//Document/Data/Section[@ID='2']/Items[@Name='Data']"; ucMappingControls1._XmlDocument = xDoc; ucMappingControls1.AddControl(ucTxbName); ucMappingControls1.AddControl(ucTxbPosition); ucMappingControls1.AddControl(ucNDSalary); ucMappingControls1.AddControl(picImage); ucMappingControls1.AddControl(ucGridWork); }
public bool funEditDocument(string iConnection, string iUserName, string iOfficeSpaceId, DataTable dt, int currentIndex, string Database) { Connection = iConnection; UserName = iUserName; OfficeSpaceId = iOfficeSpaceId; DatabaseName = Database; if (dt.Rows.Count == 0) { return(false); } string ID = "" + dt.Rows[currentIndex]["ID"]; string Name = "" + dt.Rows[currentIndex]["NAME"]; ConnectServer.cConection cConn = new ConnectServer.cConection(iUserName); frmDocument frm = new frmDocument(); frm._DocXML = cConn.getLastDoc(iConnection, iOfficeSpaceId, DatabaseName, "document", int.Parse(ID)); frm._DocumentID = ID; frm._DocumentName = Name; frm._Command = "Edit"; bool OP = false; if (frm.ShowDialog() == DialogResult.OK) { OP = true; } if (!frm.IsDisposed) { frm.Close(); frm.Dispose(); } return(OP); }
private void frmGetPosition_Load(object sender, EventArgs e) { ConnectServer.cConection cConn = new ConnectServer.cConection(cMain.UserName); NextwaverDB.NColumns NCS_S = new NextwaverDB.NColumns(); NCS_S.Add(new NextwaverDB.NColumn("POSITION_CODE")); NCS_S.Add(new NextwaverDB.NColumn("POSITION_NAME")); NCS_S.Add(new NextwaverDB.NColumn("PARENT_CODE")); DataTable dt = cConn.Retreive(cMain.Connection, cMain.OfficeSpaceId, cMain.DatabaseName, "position", NCS_S); string strSort = "POSITION_CODE ASC"; DataView dtview = new DataView(dt); dtview.Sort = strSort; DataTable dtsorted = dtview.ToTable(); ArrayList alTemp = new ArrayList(); string POSITION_NAME, POSITION_CODE, PARENT_CODE; for (int i = 0; i < dtsorted.Rows.Count; i++) { POSITION_NAME = dtsorted.Rows[i]["POSITION_NAME"].ToString(); POSITION_CODE = dtsorted.Rows[i]["POSITION_CODE"].ToString(); PARENT_CODE = dtsorted.Rows[i]["PARENT_CODE"].ToString(); TreeNode tnTemp = new TreeNode(); tnTemp.Text = POSITION_NAME + " - " + POSITION_CODE; tnTemp.Tag = POSITION_NAME; tnTemp.Name = POSITION_CODE; alTemp.Add(tnTemp); if (PARENT_CODE == "") { tvMain.Nodes.Add(tnTemp); } else { for (int j = 0; j < alTemp.Count; j++) { TreeNode tnnTemp = (TreeNode)alTemp[j]; if (tnnTemp.Name == PARENT_CODE) { tnnTemp.Nodes.Add(tnTemp); break; } } } } tvMain.ExpandAll(); }
public bool editUser(string iConnection, string iUserName, string iOfficeSpaceId, DataTable dt, int currentIndex, string Database) { Connection = iConnection; UserName = iUserName; OfficeSpaceId = iOfficeSpaceId; DatabaseName = Database; if (dt.Rows.Count == 0) { return(false); } string POSITION_CODE = dt.Rows[currentIndex]["POSITION_CODE"].ToString(); frmUser frm = new frmUser(); frm.Command = "Edit"; frm.ID_TEMP = dt.Rows[currentIndex]["ID"].ToString(); frm._Title = dt.Rows[currentIndex]["TITLE"].ToString(); frm._FIRSTNAME = dt.Rows[currentIndex]["FIRSTNAME"].ToString(); frm._LASTNAME = dt.Rows[currentIndex]["LASTNAME"].ToString(); frm._Password = dt.Rows[currentIndex]["PASSWORD"].ToString(); frm._USERNAME = dt.Rows[currentIndex]["USERNAME"].ToString(); ConnectServer.cConection cConn = new ConnectServer.cConection(cMain.UserName); NextwaverDB.NColumns NCS = new NextwaverDB.NColumns(); NCS.Add(new NextwaverDB.NColumn("POSITION_NAME")); NextwaverDB.NWheres NWS = new NextwaverDB.NWheres(); NWS.Add(new NextwaverDB.NWhere("POSITION_CODE", POSITION_CODE)); DataTable dtTemp = cConn.Retreive(cMain.Connection, cMain.OfficeSpaceId, cMain.DatabaseName, "position", NCS, NWS); frm._POSITION_CODE = POSITION_CODE; frm._POSITION_NAME = dtTemp.Rows[0][0].ToString(); bool bOutput = false; if (frm.ShowDialog() == DialogResult.OK) { bOutput = true; } if (!frm.IsDisposed) { frm.Close(); frm.Dispose(); } return(bOutput); }
private string SelectXML() { string SQL = @"select Author_XML from [user] where UserID='@UserID'"; SQL = SQL.Replace("@UserID", UserID); ConnectServer.cConection WebService = new ConnectServer.cConection(UserID); DataSet ds = WebService.Retreive(SQL, strConnect); if (ds == null) { return(null); } DataTable dt = ds.Tables[0]; return(dt.Rows[0][0].ToString()); }
private void funSave() { string BookName = txbBookName.Text; string BookType = txbBookType.Text; string BookPrice = txbPrice.Text; ConnectServer.cConection cConn = new ConnectServer.cConection(cMain.UserName); NextwaverDB.NColumns NCS = new NextwaverDB.NColumns(); NCS.Add(new NextwaverDB.NColumn("BOOKNAME", BookName)); NCS.Add(new NextwaverDB.NColumn("BOOKTYPE", BookType)); NCS.Add(new NextwaverDB.NColumn("BOOKPRICE", BookPrice)); if (Command == "New") { if (cConn.InsertData(cMain.Connection, cMain.OfficeSpaceId, "Test", "Book", NCS)) { MessageBox.Show("เพิ่มข้อมูลเรียบร้อยแล้ว"); this.DialogResult = DialogResult.OK; this.Hide(); } else { MessageBox.Show("ไม่สามารถเพิ่มข้อมูลได้เนื่องจาก :" + cConn.ErrorMsg()); } } else { NextwaverDB.NWheres NWS = new NextwaverDB.NWheres(); NWS.Add(new NextwaverDB.NWhere("ID", ID)); if (cConn.UpdateData(cMain.Connection, cMain.OfficeSpaceId, "Test", "Book", NCS, NWS)) { MessageBox.Show("แก้ไขข้อมูลเรียบร้อยแล้ว"); this.DialogResult = DialogResult.OK; this.Hide(); } else { MessageBox.Show("ไม่สามารถแก้ไขข้อมูลได้เนื่องจาก :" + cConn.ErrorMsg()); } } }
public void fnLoad(string iConnection, string iUserName, string iOfficeSpaceId, string iDatabaseName, string iTableName, string iDocId) { Connection = iConnection; UserName = iUserName; OfficeSpaceId = iOfficeSpaceId; DatabaseName = iDatabaseName; TableName = iTableName; DocId = iDocId; cConn = new ConnectServer.cConection(iUserName); fnLoadGrid(); labCLASS.Text = DatabaseName; labOBJECT.Text = TableName; labDOC_ID.Text = DocId; DataTable dt = cConn.Retreive(Connection, OfficeSpaceId, "system", "users"); cbxUser.DataSource = dt; cbxUser.DisplayMember = "USERNAME"; cbxUser.ValueMember = "USERNAME"; DataTable dtFun = new DataTable("Data"); dtFun.Columns.Add("Name"); string[] FunList = Function.FUNCTION_LIST; for (int i = 0; i < FunList.Length; i++) { DataRow dr = dtFun.NewRow(); dr.BeginEdit(); dr["Name"] = FunList[i]; dr.EndEdit(); dtFun.Rows.Add(dr); } cbxFunction.DataSource = dtFun; cbxFunction.DisplayMember = "Name"; cbxFunction.ValueMember = "Name"; }
private string setPositon(string str) { if (str == "A") { return("Administrator"); } NextwaverDB.NColumns NCS = new NextwaverDB.NColumns(); NCS.Add(new NextwaverDB.NColumn("ID")); NCS.Add(new NextwaverDB.NColumn("POSITION_NAME")); NextwaverDB.NWheres NWS = new NextwaverDB.NWheres(); NWS.Add(new NextwaverDB.NWhere("POSITION_CODE", str)); ConnectServer.cConection cConn = new ConnectServer.cConection(UserID); DataTable dt = cConn.Retreive(strConnect, Program.OffiecSpaceId, Program.DatabaseName, "position", NCS, NWS); position_id = dt.Rows[0]["ID"].ToString(); return(dt.Rows[0]["POSITION_NAME"].ToString()); }
private void funSave() { if (ucMappingControls1.funSaveXml()) { string strDoc = xDoc.OuterXml; NextwaverDB.NColumns NCS = new NextwaverDB.NColumns(); NCS.Add(new NextwaverDB.NColumn("NAME", ucTxbName._Value)); NCS.Add(new NextwaverDB.NColumn("CREATE_BY", cMain.UserName)); NCS.Add(new NextwaverDB.NColumn("CREATE_DATE", DateTime.Now.ToString("dd-mm-yyyy"))); ConnectServer.cConection cConn = new ConnectServer.cConection(cMain.UserName); if (Command == "New") { if (cConn.InsertData(cMain.Connection, cMain.OfficeSpaceId, cMain.DatabaseName, "emp_job", NCS, strDoc)) { this.DialogResult = DialogResult.OK; this.Hide(); } else { MessageBox.Show("ไม่สามารถบันทึกข้อมูลได้เนื่องจาก :" + cConn.ErrorMsg()); } } else { NextwaverDB.NWheres NWS = new NextwaverDB.NWheres(); NWS.Add(new NextwaverDB.NWhere("ID", ID_TEMP)); if (cConn.UpdateData(cMain.Connection, cMain.OfficeSpaceId, cMain.DatabaseName , "emp_job", NCS, NWS, strDoc)) { this.DialogResult = DialogResult.OK; this.Hide(); } else { MessageBox.Show("ไม่สามารถบันทึกข้อมูลได้เนื่องจาก :" + cConn.ErrorMsg()); } } } }
private bool funValidate() { NextwaverDB.NWheres NWS = new NextwaverDB.NWheres(); NWS.Add(new NextwaverDB.NWhere("USERNAME", txtUser.Text)); NWS.Add(new NextwaverDB.NWhere("PASSWORD", txtPass.Text)); NextwaverDB.NColumns NCS_S = new NextwaverDB.NColumns(); NCS_S.Add(new NextwaverDB.NColumn("USERNAME")); NCS_S.Add(new NextwaverDB.NColumn("POSITION_CODE")); NCS_S.Add(new NextwaverDB.NColumn("ID")); ConnectServer.cConection cConn = new ConnectServer.cConection("System"); DataTable dt = cConn.Retreive(_Connection, Program.OffiecSpaceId, Program.DatabaseName, "users", NCS_S, NWS); if (dt.Rows.Count == 0) { return(false); } Position = "" + dt.Rows[0]["POSITION_CODE"]; Position_ID = "" + dt.Rows[0]["ID"]; return(true); }
public bool checkACL(string iConnection, string iOfficeSpaceId, string Database, string iTableName, string iDocId, string iUserName, string FUNCTION) { try { ConnectServer.cConection cConn = new ConnectServer.cConection(iUserName); NextwaverDB.NWheres NWS = new NextwaverDB.NWheres(); NWS.Add("CLASS", Database); NWS.Add("OBJECT", iTableName); NWS.Add("DOC_ID", iDocId); NWS.Add("USERNAME", iUserName); NWS.Add("FUNCTION", FUNCTION); DataTable dt = cConn.Retreive(iConnection, iOfficeSpaceId, "system", "acl_users", NWS); if (dt.Rows.Count > 0) { return(true); } else { return(false); } } catch { return(false); } }
private void funCreateExpand() { //taskPane1 ConnectServer.cConection cConn = new ConnectServer.cConection(UserID); string strDoc = cConn.getLastDoc(strConnect, Program.OffiecSpaceId, Program.DatabaseName, "position", int.Parse(position_id)); XmlDocument xmlImage = new XmlDocument(); xmlImage.Load(Application.StartupPath + @"\Image.xml"); xmlConfig = new XmlDocument(); XmlNodeList nodeView; if (position == "A") { XmlDocument xmlConfigT = new XmlDocument(); xmlConfigT.Load("MConfig.xml"); nodeView = xmlConfigT.SelectNodes("//Config/Views/View"); } else { if (strDoc == "") { XmlDocument xmlConfigT = new XmlDocument(); xmlConfigT.Load("MConfig.xml"); nodeView = xmlConfigT.SelectNodes("//Config/Views/View"); } else { XmlDocument xmlConfigT = new XmlDocument(); xmlConfigT.LoadXml(strDoc); nodeView = xmlConfigT.SelectNodes("//Views/View"); } } xmlConfig.Load("MConfig.xml"); taskPane1.Controls.Clear(); for (int i = 0; i < nodeView.Count; i++) { string Name = nodeView[i].Attributes["Name"].Value; string PathTitle = ""; try { PathTitle = xmlImage.SelectSingleNode("//Image[@ID='" + nodeView[i].Attributes["IconID"].Value + "']").Attributes["Path"].Value; } catch { } string PathWaterMark = ""; try { PathWaterMark = xmlImage.SelectSingleNode("//Image[@ID='" + nodeView[i].Attributes["WaterMarkID"].Value + "']").Attributes["Path"].Value; } catch { } if (nodeView[i].Attributes["Enable"].Value.ToString() == "T") { XPExplorerBar.Expando expTemp = funExpando("" + nodeView[i].Attributes["Name"].Value, PathTitle, PathWaterMark); XmlNodeList listItem = nodeView[i].SelectNodes("./Item"); for (int j = 0; j < listItem.Count; j++) { string IconPath = ""; try { IconPath = "" + xmlImage.SelectSingleNode("//Image[@ID='" + listItem[j].Attributes["IconID"].Value + "']").Attributes["Path"].Value; } catch { } if (listItem[j].Attributes["Enable"].Value.ToString() == "T") { XmlNode nodeMap = xmlConfig.SelectSingleNode("//Config/Mappings/Mapping[@ID='" + listItem[j].Attributes["MappingID"].Value + "']"); XPExplorerBar.TaskItem xItem = new XPExplorerBar.TaskItem(); xItem.Text = "" + nodeMap.Attributes["Name"].Value; xItem.Tag = nodeMap; try { xItem.Image = Image.FromFile(IconPath); } catch { } try { xItem.Image.Tag = IconPath; } catch { } xItem.Click += new EventHandler(xItem_Click); expTemp.Items.Add(xItem); } } //expTemp.Collapse(); taskPane1.Controls.Add(expTemp); } } }
public bool editPosition(string iConnection, string iUserName, string iOfficeSpaceId, DataTable dt, int currentIndex, string Database) { Connection = iConnection; UserName = iUserName; OfficeSpaceId = iOfficeSpaceId; DatabaseName = Database; if (dt.Rows.Count == 0) { return(false); } string DOC_ID = dt.Rows[currentIndex]["ID"].ToString(); string CREATE_BY = ""; try { CREATE_BY = dt.Rows[currentIndex]["CREATE_BY"].ToString(); } catch { } ACL.cMain cACL = new ACL.cMain(); bool bNext = false; if (CREATE_BY == UserName) { bNext = true; } else { bNext = cACL.checkACL(iConnection, iOfficeSpaceId, Database, "position", DOC_ID, iUserName, ACL.Function.EDIT); } if (bNext) { string PARENT_CODE = dt.Rows[currentIndex]["PARENT_CODE"].ToString(); frmPosition frm = new frmPosition(); frm.Command = "Edit"; frm.ID_TEMP = dt.Rows[currentIndex]["ID"].ToString(); if (PARENT_CODE != "") { ConnectServer.cConection cConn = new ConnectServer.cConection(cMain.UserName); NextwaverDB.NColumns NCS = new NextwaverDB.NColumns(); NCS.Add(new NextwaverDB.NColumn("POSITION_NAME")); NextwaverDB.NWheres NWS = new NextwaverDB.NWheres(); NWS.Add(new NextwaverDB.NWhere("POSITION_CODE", PARENT_CODE)); DataTable dtTemp = cConn.Retreive(cMain.Connection, cMain.OfficeSpaceId, cMain.DatabaseName, "position", NCS, NWS); frm._PARENT_CODE = PARENT_CODE; frm._PARENT_NAME = dtTemp.Rows[0][0].ToString(); } frm._POSITION_CODE = dt.Rows[currentIndex]["POSITION_CODE"].ToString();; frm._POSITION_NAME = dt.Rows[currentIndex]["POSITION_NAME"].ToString(); bool bOutput = false; if (frm.ShowDialog() == DialogResult.OK) { bOutput = true; } if (!frm.IsDisposed) { frm.Close(); frm.Dispose(); } return(bOutput); } else { return(false); } }
private void fnProcess(object sender, DoWorkEventArgs e) { this.Invoke( (MethodInvoker) delegate() { XmlDocument xConfig = getXmlConfig(); ConnectServer.cConection cConn = new ConnectServer.cConection("system"); rtbError.Text = "[" + DateTime.Now.ToShortTimeString() + "] Start Loop Process"; for (int i = 0; i < dgvProcess.SelectedRows.Count; i++) { List <string> Sql_List = new List <string>(); string ID = "" + dgvProcess.SelectedRows[i].Cells["ID"].Value; string WSConnectionID = "" + dgvProcess.SelectedRows[i].Cells["WSConnectionID"].Value; string DBConnectionID = "" + dgvProcess.SelectedRows[i].Cells["DBConnectionID"].Value; string ProcessName = "" + dgvProcess.SelectedRows[i].Cells["Name"].Value; rtbError.Text += Environment.NewLine + "[" + DateTime.Now.ToShortTimeString() + "] Start Process " + ProcessName; //<Item ID="NEXWS01" Type="NEXWS" Connection="NextwaverDatabase" Database="system" /> XmlNode nodeWSConnection = xConfig.SelectSingleNode("//Config/Connection/Item[@ID='" + WSConnectionID + "']"); string WSConnection = nodeWSConnection.Attributes["Connection"].Value; string WSDatabase = nodeWSConnection.Attributes["Database"].Value; string OfficeSpaceId = nodeWSConnection.Attributes["OfficeSpaceId"].Value; XmlNode nodeProcess = xConfig.SelectSingleNode("//Process[@ID='" + ID + "']"); string Sql_Insert = nodeProcess.SelectSingleNode("./Query/Insert").InnerText; string Sql_Delete = nodeProcess.SelectSingleNode("./Query/Delete").InnerText; string WSTable = nodeProcess.Attributes["WSTable"].Value; DataTable dt = cConn.Retreive(WSConnection, OfficeSpaceId, WSDatabase, WSTable); XmlNodeList listColumn = nodeProcess.SelectNodes("./Columns/Column"); for (int k = 0; k < dt.Rows.Count; k++) { string TempInsert = Sql_Insert; string TempDelete = Sql_Delete; DataRow DR = dt.Rows[k]; for (int j = 0; j < listColumn.Count; j++) { //<Column Type="STR" Name="ID" Parameter="@ID@" /> string TempType = "" + listColumn[j].Attributes["Type"].Value; string TempName = "" + listColumn[j].Attributes["Name"].Value; string TempParameter = "" + listColumn[j].Attributes["Parameter"].Value; string TempValue = ""; try { TempValue = "" + DR[TempName]; } catch { } TempDelete = TempDelete.Replace(TempParameter, TempValue); switch (TempType) { case "STR": TempInsert = TempInsert.Replace(TempParameter, "" + DR[TempName]); break; case "XML": string strXML = cConn.getLastDoc(WSConnection, OfficeSpaceId, WSDatabase, WSTable, int.Parse("" + DR["ID"])); TempInsert = TempInsert.Replace(TempParameter, strXML); break; } } Sql_List.Add(TempDelete); Sql_List.Add(TempInsert); } //<Item ID="MSSQL01" Type="MSSQL" Server="localhost" Database="TestProcess" Login="******" Password="******" /> XmlNode nodeDBConnection = xConfig.SelectSingleNode("//Config/Connection/Item[@ID='" + DBConnectionID + "']"); string DBServer = nodeDBConnection.Attributes["Server"].Value; string DBDatabase = nodeDBConnection.Attributes["Database"].Value; string DBLogin = nodeDBConnection.Attributes["Login"].Value; string DBPassword = nodeDBConnection.Attributes["Password"].Value; string ConnectoinString = "Data Source=" + DBServer + "; uid=" + DBLogin + "; pwd=" + DBPassword + "; Initial Catalog=" + DBDatabase + ";"; string ErrMsg = ""; if (!cConn.Execute(Sql_List.ToArray(), ConnectoinString, out ErrMsg)) { rtbError.Text += Environment.NewLine + "[" + DateTime.Now.ToShortTimeString() + "] ประมวลผล " + ProcessName + " ไม่สำเร็จ"; rtbError.Text += Environment.NewLine + " ข้อผิดพลาด : " + ErrMsg; } else { rtbError.Text += Environment.NewLine + "[" + DateTime.Now.ToShortTimeString() + "] ประมวลผล " + ProcessName + " สำเร็จ"; } nodeProcess.Attributes["UpdateDate"].Value = DateTime.Now.ToString("dd/MM/yyyy hh:mm"); rtbError.Text += Environment.NewLine + "[" + DateTime.Now.ToShortTimeString() + "] End Process " + ProcessName; } rtbError.Text += Environment.NewLine + "[" + DateTime.Now.ToShortTimeString() + "] End Loop Process"; xConfig.Save(Application.StartupPath + "/Config_Process.xml"); fnLoadConfig(); } ); }