void funSave() { XmlNode nodeView = xDoc.SelectSingleNode("//Views"); string strDoc = nodeView.OuterXml; string POSITION_CODE = txbPOSITION_CODE.Text; string POSITION_NAME = txbPOSITION_NAME.Text; string PARENT_CODE = "" + txbPARENT_CODE.Tag; if (!funValidation()) { MessageBox.Show("โปรดระบุชื่อตำแหน่ง", "ข้อผิดพลาด", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (Command == "New") { NextwaverDB.NColumns NCS = new NextwaverDB.NColumns(); NCS.Add(new NextwaverDB.NColumn("POSITION_CODE", PARENT_CODE + getNewPOSITION_CODE(PARENT_CODE))); NCS.Add(new NextwaverDB.NColumn("POSITION_NAME", POSITION_NAME)); NCS.Add(new NextwaverDB.NColumn("PARENT_CODE", PARENT_CODE)); NCS.Add(new NextwaverDB.NColumn("CREATE_DATE", DateTime.Now.ToString("dd/MM/yyyy"))); NCS.Add(new NextwaverDB.NColumn("CREATE_BY", cMain.UserName)); NCS.Add(new NextwaverDB.NColumn("UPDATE_DATE", DateTime.Now.ToString("dd/MM/yyyy"))); NCS.Add(new NextwaverDB.NColumn("UPDATE_BY", cMain.UserName)); if (cConn.InsertData(cMain.Connection, cMain.OfficeSpaceId, cMain.DatabaseName, "position", NCS, strDoc)) { this.DialogResult = DialogResult.OK; this.Hide(); } else { MessageBox.Show("ไม่สามารถเพิ่มข้อมูลได้เนื่องจาก:" + cConn.ErrorMsg(), "ข้อผิดพลาด", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { NextwaverDB.NColumns NCS = new NextwaverDB.NColumns(); NCS.Add(new NextwaverDB.NColumn("POSITION_NAME", POSITION_NAME)); NCS.Add(new NextwaverDB.NColumn("UPDATE_DATE", DateTime.Now.ToString("dd/MM/yyyy"))); NCS.Add(new NextwaverDB.NColumn("UPDATE_BY", cMain.UserName)); NextwaverDB.NWheres NWS = new NextwaverDB.NWheres(); NWS.Add("ID", ID_TEMP); if (cConn.UpdateData(cMain.Connection, cMain.OfficeSpaceId, cMain.DatabaseName, "position", NCS, NWS, strDoc)) { this.DialogResult = DialogResult.OK; this.Hide(); } else { MessageBox.Show("ไม่สามารถแก้ไขข้อมูลได้เนื่องจาก:" + cConn.ErrorMsg(), "ข้อผิดพลาด", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
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(); }
string getNewPOSITION_CODE(string PARENT_CODE) { NextwaverDB.NXPath NXP = new NextwaverDB.NXPath(); NextwaverDB.NWheres NWS = new NextwaverDB.NWheres(); NWS.whereType = true; NWS.Where = "[" + NXP.getMaxValue("@POSITION_CODE@") + "]"; NWS.Where += "[@PARENT_CODE@ = '" + PARENT_CODE + "']"; NextwaverDB.NColumns NCS_S = new NextwaverDB.NColumns(); NCS_S.Add(new NextwaverDB.NColumn("POSITION_CODE")); DataTable dt = cConn.Retreive(cMain.Connection, cMain.OfficeSpaceId, cMain.DatabaseName, "position", NCS_S, NWS); int MaxID = 0; try { string PC = dt.Rows[0][0].ToString(); if (PARENT_CODE != "") { PC = PC.Replace(PARENT_CODE, ""); } MaxID = int.Parse(PC); } catch { } string NewID = "" + (MaxID + 1); for (int i = NewID.Length; i < 3; i++) { NewID = "0" + NewID; } return(NewID); }
private void btnSave_Click(object sender, EventArgs e) { if (cbxFunction.SelectedValue == "") { MessageBox.Show("ข้อผิดพลาด", "โปรดเลือก Function", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (!dataGridView1.Enabled) //รายการใหม่ { NextwaverDB.NColumns NCS = new NextwaverDB.NColumns(); NCS.Add(new NextwaverDB.NColumn("CLASS", DatabaseName)); NCS.Add(new NextwaverDB.NColumn("OBJECT", TableName)); NCS.Add(new NextwaverDB.NColumn("DOC_ID", DocId)); NCS.Add(new NextwaverDB.NColumn("USERNAME", "" + cbxUser.SelectedValue)); NCS.Add(new NextwaverDB.NColumn("FUNCTION", "" + cbxFunction.SelectedValue)); if (cConn.InsertData(Connection, OfficeSpaceId, "system", "acl_users", NCS)) { dataGridView1.Enabled = true; fnLoadGrid(); } else { MessageBox.Show("ไม่สามารถเพิ่มข้อมูลได้เนื่องจาก:" + cConn.ErrorMsg(), "ข้อผิดพลาด", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else //รายการแก้ไข { NextwaverDB.NColumns NCS = new NextwaverDB.NColumns(); NCS.Add(new NextwaverDB.NColumn("FUNCTION", "" + cbxFunction.SelectedValue)); NCS.Add(new NextwaverDB.NColumn("USERNAME", "" + cbxUser.SelectedValue)); NextwaverDB.NWheres NWS = new NextwaverDB.NWheres(); NWS.Add("ID", labID.Text); if (cConn.UpdateData(Connection, OfficeSpaceId, "system", "acl_users", NCS, NWS)) { dataGridView1.Enabled = true; fnLoadGrid(); } else { MessageBox.Show("ไม่สามารถแก้ไขข้อมูลได้เนื่องจาก:" + cConn.ErrorMsg(), "ข้อผิดพลาด", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
public void fnLoad() { NextwaverDB.NColumns NCS = new NextwaverDB.NColumns(); NCS.Add(new NextwaverDB.NColumn("ID")); NCS.Add(new NextwaverDB.NColumn("USERNAME")); DataTable dtTemp = cConn.Retreive(cMain.Connection, cMain.OfficeSpaceId, "system", "users", NCS); if (_Command == "New") { lbUsed.DataSource = createTable(); lbUsed.DisplayMember = "USERNAME"; lbUsed.ValueMember = "ID"; } else { string strDoc = cConn.getLastDoc(cMain.Connection, cMain.OfficeSpaceId, "system", "user_group", int.Parse(_ID)); XmlDocument xDoc = new XmlDocument(); xDoc.LoadXml(strDoc); DataTable dtUsed = createTable(); XmlNodeList listItem = xDoc.SelectNodes("//Item"); for (int i = 0; i < listItem.Count; i++) { string ID = listItem[i].Attributes["C00"].Value; DataRow dr = dtUsed.NewRow(); dr.BeginEdit(); dr["ID"] = ID; dr["USERNAME"] = listItem[i].Attributes["C01"].Value; dr.EndEdit(); dtUsed.Rows.Add(dr); DataRow[] dr_list = dtTemp.Select("ID = '" + ID + "'"); dtTemp.Rows.Remove(dr_list[0]); } lbUsed.DataSource = dtUsed; lbUsed.DisplayMember = "USERNAME"; lbUsed.ValueMember = "ID"; } lbAll.DataSource = dtTemp; lbAll.DisplayMember = "USERNAME"; lbAll.ValueMember = "ID"; }
private void funSave() { if (funValidation()) { DocID = tbxDocID.Text; DocName = tbxDocName.Text; xmlDoc.SelectSingleNode("//Document").Attributes["ID"].Value = tbxDocID.Text; xmlDoc.SelectSingleNode("//Document").Attributes["Name"].Value = tbxDocName.Text; NextwaverDB.NColumns NCS = new NextwaverDB.NColumns(); NCS.Add(new NextwaverDB.NColumn("NAME", tbxDocName.Text)); NCS.Add(new NextwaverDB.NColumn("CREATE_DATE", DateTime.Now.ToString("dd/MM/yyyy"))); NCS.Add(new NextwaverDB.NColumn("CREATE_BY", cMain.UserName)); NCS.Add(new NextwaverDB.NColumn("UPDATE_DATE", DateTime.Now.ToString("dd/MM/yyyy"))); NCS.Add(new NextwaverDB.NColumn("UPDATE_BY", cMain.UserName)); if (Command == "New") { if (cConn.InsertData(cMain.Connection, cMain.OfficeSpaceId, cMain.DatabaseName, "document", NCS, xmlDoc.OuterXml)) { this.DialogResult = DialogResult.OK; this.Hide(); } else { MSG.Error("äÁèÊÒÁÒöà¾ÔèÁ¢éÍÁÙÅä´éà¹×èͧ¨Ò¡:" + cConn.ErrorMsg(), "¢éͼԴ¾ÅÒ´"); } } else { NextwaverDB.NWheres NWS = new NextwaverDB.NWheres(); NWS.Add(new NextwaverDB.NWhere("ID", LogDocumentID)); if (cConn.UpdateData(cMain.Connection, cMain.OfficeSpaceId, cMain.DatabaseName, "document", NCS, NWS, xmlDoc.OuterXml)) { this.DialogResult = DialogResult.OK; this.Hide(); } else { MSG.Error("äÁèÊÒÁÒöá¡é䢢éÍÁÙÅä´éà¹×èͧ¨Ò¡:" + cConn.ErrorMsg(), "¢éͼԴ¾ÅÒ´"); } } } }
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 Start() { GRB_WebService.GRB_WebService GRBS = new GRB_WebService.GRB_WebService(); DataTable dt = GRBS.getDestroryBook(); WorkSpaceService.Service WS = new WorkSpaceService.Service(); for (int i = 0; i < dt.Rows.Count; i++) { string ID = "" + dt.Rows[i]["ID"]; String strDoc = WS.SelectLastDocument(Connection, OfficeSpaceId, DatabaseName, "Book", int.Parse(ID), "system"); xDoc = new XmlDocument(); xDoc.LoadXml(strDoc);//Recycle string RootPathBook = "//Document/Data/Section[@ID='1']/Items[@Name='GunBook']"; AddDataXmlNode(RootPathBook + "/Item[@Name='BookStatus']", "Destrory"); AddDataXmlNode(RootPathBook + "/Item[@Name='UpdateDate']", convertDatetime(DateTime.Now)); AddDataXmlNode(RootPathBook + "/Item[@Name='UpdateBy']", "system"); NextwaverDB.NColumns NCS = new NextwaverDB.NColumns(); NCS.Add(new NextwaverDB.NColumn("BOOKSTATUS", "Destrory")); NCS.Add(new NextwaverDB.NColumn("UPDATEDATE", DateTime.Now.ToString("dd/MM/yyyy"))); NCS.Add(new NextwaverDB.NColumn("UPDATEBY", "system")); NextwaverDB.NWheres NWS = new NextwaverDB.NWheres(); NWS.Add("ID", ID); strDoc = xDoc.OuterXml; string[] OP = WS.UpdateData(Connection, OfficeSpaceId, DatabaseName, "Book", NCS.ExportString(), NWS.ExportString(), strDoc, "system"); try { GRB_WebService.GRB_WebService GRB_ws = new GRB_WebService.GRB_WebService(); GRB_ws.DeleteDestroryByID(int.Parse(ID), "Expired"); } catch (Exception ex) { System.Console.WriteLine("ERROR:" + ex.Message); } } }
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); }
private bool Validation() { if (txbUSERNAME.Text == "") { MessageBox.Show("โปรดระบุ ชื่อผู้ใช้งาน", "ข้อผิดพลาด", MessageBoxButtons.OK, MessageBoxIcon.Error); return(false); } if (txbPASSWORD.Text == "") { MessageBox.Show("โปรดระบุ รหัสผ่าน", "ข้อผิดพลาด", MessageBoxButtons.OK, MessageBoxIcon.Error); return(false); } if (txbPASSWORD2.Text == "") { MessageBox.Show("โปรดระบุ ยืนยันรหัสผ่าน", "ข้อผิดพลาด", MessageBoxButtons.OK, MessageBoxIcon.Error); return(false); } if (txbPASSWORD.Text != txbPASSWORD2.Text) { MessageBox.Show("โปรดระบุ รหัสผ่าน และ ยืนยันรหัสผ่าน ให้เหมือนกัน", "ข้อผิดพลาด", MessageBoxButtons.OK, MessageBoxIcon.Error); return(false); } if (txbPOSITION_CODE.Text == "") { MessageBox.Show("โปรดระบุ ตำแหน่ง", "ข้อผิดพลาด", MessageBoxButtons.OK, MessageBoxIcon.Error); return(false); } NextwaverDB.NWheres NWS = new NextwaverDB.NWheres(); NWS.whereType = true; NWS.Where = "[@USERNAME@ = '" + txbUSERNAME.Text + "']"; if (Command != "New") { NWS.Where += "[@USERNAME@ != '" + USERNAME_TEMP + "']"; } NextwaverDB.NColumns NCS_S = new NextwaverDB.NColumns(); NCS_S.Add(new NextwaverDB.NColumn("USERNAME")); DataTable dt = cConn.Retreive(cMain.Connection, cMain.OfficeSpaceId, cMain.DatabaseName, "users", NCS_S, NWS); if (dt.Rows.Count > 0) { MessageBox.Show("ชื่อผู้ใช้งานนี้มีอยู่แล้วในระบบโปรดระบุใหม่", "ข้อผิดพลาด", MessageBoxButtons.OK, MessageBoxIcon.Error); return(false); } return(true); }
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 bool CheckDocumentName() { NextwaverDB.NWheres NWS = new NextwaverDB.NWheres(); NWS.whereType = true; NWS.Where = "[@NAME@ = '" + tbxDocName.Text + "']"; if (Command != "New") { NWS.Where += "[@ID@ != '" + LogDocumentID + "']"; } NextwaverDB.NColumns NCS_S = new NextwaverDB.NColumns(); NCS_S.Add(new NextwaverDB.NColumn("NAME")); DataTable dt = cConn.Retreive(cMain.Connection, cMain.OfficeSpaceId, cMain.DatabaseName, "document", NCS_S, NWS); if (dt.Rows.Count > 0) { MessageBox.Show("ª×èͼÙéãªé§Ò¹¹ÕéÁÕÍÂÙèáÅéÇã¹Ãкºâ»Ã´ÃкØãËÁè", "¢éͼԴ¾ÅÒ´", MessageBoxButtons.OK, MessageBoxIcon.Error); return(false); } return(true); }
void funSave() { if (Validation()) { string USERNAME = txbUSERNAME.Text; string PASSWORD = txbPASSWORD.Text; string TITLE = txbTITLE.Text; string FIRSTNAME = txbFIRSTNAME.Text; string LASTNAME = txbLASTNAME.Text; string POSITION_CODE = "" + txbPOSITION_CODE.Tag; if (Command == "New") { NextwaverDB.NColumns NCS = new NextwaverDB.NColumns(); NCS.Add(new NextwaverDB.NColumn("USERNAME", USERNAME)); NCS.Add(new NextwaverDB.NColumn("PASSWORD", PASSWORD)); NCS.Add(new NextwaverDB.NColumn("TITLE", TITLE)); NCS.Add(new NextwaverDB.NColumn("FIRSTNAME", FIRSTNAME)); NCS.Add(new NextwaverDB.NColumn("LASTNAME", LASTNAME)); NCS.Add(new NextwaverDB.NColumn("POSITION_CODE", POSITION_CODE)); NCS.Add(new NextwaverDB.NColumn("CREATE_DATE", DateTime.Now.ToString("dd/MM/yyyy"))); NCS.Add(new NextwaverDB.NColumn("CREATE_BY", cMain.UserName)); NCS.Add(new NextwaverDB.NColumn("UPDATE_DATE", DateTime.Now.ToString("dd/MM/yyyy"))); NCS.Add(new NextwaverDB.NColumn("UPDATE_BY", cMain.UserName)); if (cConn.InsertData(cMain.Connection, cMain.OfficeSpaceId, cMain.DatabaseName, "users", NCS)) { this.DialogResult = DialogResult.OK; this.Hide(); } else { MessageBox.Show("ไม่สามารถเพิ่มข้อมูลได้เนื่องจาก:" + cConn.ErrorMsg(), "ข้อผิดพลาด", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { NextwaverDB.NColumns NCS = new NextwaverDB.NColumns(); NCS.Add(new NextwaverDB.NColumn("PASSWORD", PASSWORD)); NCS.Add(new NextwaverDB.NColumn("TITLE", TITLE)); NCS.Add(new NextwaverDB.NColumn("FIRSTNAME", FIRSTNAME)); NCS.Add(new NextwaverDB.NColumn("LASTNAME", LASTNAME)); NCS.Add(new NextwaverDB.NColumn("POSITION_CODE", POSITION_CODE)); NCS.Add(new NextwaverDB.NColumn("UPDATE_DATE", DateTime.Now.ToString("dd/MM/yyyy"))); NCS.Add(new NextwaverDB.NColumn("UPDATE_BY", cMain.UserName)); NextwaverDB.NWheres NWS = new NextwaverDB.NWheres(); NWS.Add("ID", ID_TEMP); if (cConn.UpdateData(cMain.Connection, cMain.OfficeSpaceId, cMain.DatabaseName, "users", NCS, NWS)) { this.DialogResult = DialogResult.OK; this.Hide(); } else { MessageBox.Show("ไม่สามารถแก้ไขข้อมูลได้เนื่องจาก:" + cConn.ErrorMsg(), "ข้อผิดพลาด", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } }
static void Main(string[] args) { string Connection = "NextwaverDatabase"; string OfficeSpaceId = "OF.0001"; string DatabaseName = "GunBook"; System.Collections.Generic.IEnumerable <String> lines = File.ReadLines("file.txt"); int sIndex = 0; foreach (var item in lines) { try { if (item.Trim() != "") { sIndex++; WorkSpace.Service WS = new WorkSpace.Service(); NextwaverDB.NWheres NWS = new NextwaverDB.NWheres(); NWS.Add(new NextwaverDB.NWhere("NAME", item)); NextwaverDB.NColumns NCS_S = new NextwaverDB.NColumns(); NCS_S.Add(new NextwaverDB.NColumn("NAME")); string NCS_Encrypt = new EncryptDecrypt.CryptorEngine().Encrypt(NCS_S.ExportString(), true); string NWS_Encrypt = new EncryptDecrypt.CryptorEngine().Encrypt(NWS.ExportString(), true); DataTable dt = WS.SelectByColumnAndWhere(Connection, OfficeSpaceId, DatabaseName, "GunOwner", NCS_Encrypt, NWS_Encrypt, "System"); if (dt.Rows.Count == 0) { try { NextwaverDB.NColumns NCS = new NextwaverDB.NColumns(); NCS.Add(new NextwaverDB.NColumn("NAME", item)); NCS.Add(new NextwaverDB.NColumn("DESCRIPTION", "")); NCS.Add(new NextwaverDB.NColumn("UPDATEDATE", convertDatetime(DateTime.Now))); NCS.Add(new NextwaverDB.NColumn("DELETE", "0")); string[] OP = WS.InsertData(Connection, OfficeSpaceId, DatabaseName, "GunOwner", NCS.ExportString(), "", "System"); if (OP[0].ToUpper() == "OK") { System.Console.WriteLine(sIndex + " :: Add :: " + item); } else { System.Console.WriteLine("Add :: " + item + " fail"); } } catch (Exception ex) { } } else { System.Console.WriteLine("Have :: " + item); } } } catch (Exception ex) { } } }
static void Main(string[] args) { System.Collections.Generic.IEnumerable <String> lines = File.ReadLines("file.txt"); foreach (var item in lines) { string Connection = "NextwaverDatabase"; string OfficeSpaceId = "OF.0001"; string DatabaseName = "GunBook"; string RootPath = "//Document/Data/Section[@ID='1']/Items[@Name='GunBook']"; string RootPathPage = "//Document/Data/Section[@ID='1']/Items[@Name='Page']"; System.Diagnostics.Process.GetCurrentProcess().PriorityClass = System.Diagnostics.ProcessPriorityClass.RealTime; string bookno = getParam(item, "bookno"); string bookyear = getParam(item, "bookyear"); string gunregidstart = getParam(item, "gunregidstart"); string gunregidend = getParam(item, "gunregidend"); string pagetotal = getParam(item, "pagetotal"); string gunregidprefix = getParam(item, "gunregidprefix"); string dual = getParam(item, "dual"); int n; if (bookno.Trim() != "" && pagetotal.Trim() != "" && int.TryParse(bookno, out n) && int.TryParse(bookyear, out n) && int.TryParse(pagetotal, out n)) { System.Console.WriteLine("Create Book " + bookno); Boolean isSuccess = false; for (int iindex = 0; iindex < 10; iindex++) { if (iindex > 1) { System.Console.WriteLine("Rerun Book :: " + bookno); } try { string NCS_Encrypt; string NWS_Encrypt; NextwaverDB.NColumns NCS_S; DataTable dt; WorkSpace.Service WS = new WorkSpace.Service(); NextwaverDB.NWheres NWS = new NextwaverDB.NWheres(); NWS.Add(new NextwaverDB.NWhere("BOOKNO", bookno)); NCS_S = new NextwaverDB.NColumns(); NCS_S.Add(new NextwaverDB.NColumn("BOOKNO")); NCS_Encrypt = new EncryptDecrypt.CryptorEngine().Encrypt(NCS_S.ExportString(), true); NWS_Encrypt = new EncryptDecrypt.CryptorEngine().Encrypt(NWS.ExportString(), true); dt = WS.SelectByColumnAndWhere(Connection, OfficeSpaceId, DatabaseName, "Book", NCS_Encrypt, NWS_Encrypt, "System"); if (dt.Rows.Count == 0) { XmlDocument xDoc = new XmlDocument(); xDoc.Load(@"tempdoc\Book.xml"); NextwaverDB.NColumns NCS = new NextwaverDB.NColumns(); NCS.Add(new NextwaverDB.NColumn("BOOKNO", bookno)); NCS.Add(new NextwaverDB.NColumn("BOOKYEAR", bookyear)); NCS.Add(new NextwaverDB.NColumn("GUNREGIDSTART", gunregidstart)); NCS.Add(new NextwaverDB.NColumn("GUNREGIDEND", gunregidend)); NCS.Add(new NextwaverDB.NColumn("PAGETOTAL", pagetotal)); NCS.Add(new NextwaverDB.NColumn("GUNREGIDPREFIX", gunregidprefix)); NCS.Add(new NextwaverDB.NColumn("BOOKSTATUS", "Create")); NCS.Add(new NextwaverDB.NColumn("CREATEDATE", convertDatetime(DateTime.Now))); NCS.Add(new NextwaverDB.NColumn("CREATEBY", "System")); NCS.Add(new NextwaverDB.NColumn("UPDATEDATE", convertDatetime(DateTime.Now))); NCS.Add(new NextwaverDB.NColumn("UPDATEBY", "System")); AddDataXmlNode(xDoc, RootPath + "/Item[@Name='BookNo']", bookno); AddDataXmlNode(xDoc, RootPath + "/Item[@Name='BookYear']", bookyear); AddDataXmlNode(xDoc, RootPath + "/Item[@Name='GunRegIDStart']", gunregidstart); AddDataXmlNode(xDoc, RootPath + "/Item[@Name='GunRegIDEnd']", gunregidend); AddDataXmlNode(xDoc, RootPath + "/Item[@Name='PageTotal']", pagetotal); AddDataXmlNode(xDoc, RootPath + "/Item[@Name='GunRegIDPrefix']", gunregidprefix); AddDataXmlNode(xDoc, RootPath + "/Item[@Name='BookStatus']", "Create"); AddDataXmlNode(xDoc, RootPath + "/Item[@Name='CreateDate']", convertDatetime(DateTime.Now)); AddDataXmlNode(xDoc, RootPath + "/Item[@Name='CreateBy']", "System"); AddDataXmlNode(xDoc, RootPath + "/Item[@Name='UpdateDate']", convertDatetime(DateTime.Now)); AddDataXmlNode(xDoc, RootPath + "/Item[@Name='UpdateBy']", "System"); string strDoc = xDoc.OuterXml; string[] OP = WS.InsertData(Connection, OfficeSpaceId, DatabaseName, "Book", NCS.ExportString(), strDoc, "System"); if (OP[0].ToUpper() == "OK") { } else { File.AppendAllText("log.txt", Environment.NewLine + Environment.NewLine + DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss") + " :: " + OP[1]); System.Console.WriteLine(OP[1]); //isSuccess = false; break; } } NWS = new NextwaverDB.NWheres(); NWS.Add(new NextwaverDB.NWhere("BOOKNO", bookno)); NWS.Add(new NextwaverDB.NWhere("PAGEVERSION", "1")); NCS_S = new NextwaverDB.NColumns(); NCS_S.Add(new NextwaverDB.NColumn("BOOKNO")); NCS_S.Add(new NextwaverDB.NColumn("PAGENO")); NCS_Encrypt = new EncryptDecrypt.CryptorEngine().Encrypt(NCS_S.ExportString(), true); NWS_Encrypt = new EncryptDecrypt.CryptorEngine().Encrypt(NWS.ExportString(), true); XmlDocument xDocPage = new XmlDocument(); xDocPage.Load(@"tempdoc\Page.xml"); AddDataXmlNode(xDocPage, RootPathPage + "/Item[@Name='BookNo']", bookno); AddDataXmlNode(xDocPage, RootPathPage + "/Item[@Name='PageVersion']", "1"); AddDataXmlNode(xDocPage, RootPathPage + "/Item[@Name='PageStatus']", "Create"); AddDataXmlNode(xDocPage, RootPathPage + "/Item[@Name='CreateDate']", convertDatetime(DateTime.Now)); AddDataXmlNode(xDocPage, RootPathPage + "/Item[@Name='CreateBy']", "System"); AddDataXmlNode(xDocPage, RootPathPage + "/Item[@Name='UpdateDate']", convertDatetime(DateTime.Now)); AddDataXmlNode(xDocPage, RootPathPage + "/Item[@Name='UpdateBy']", "System"); DataTable dtp; dtp = WS.SelectByColumnAndWhere(Connection, OfficeSpaceId, DatabaseName, "Page", NCS_Encrypt, NWS_Encrypt, "System"); int MaxPageTotal = dtp.Rows.Count; bool isuccess = true; if (MaxPageTotal < int.Parse(pagetotal)) { for (int i = (MaxPageTotal + 1); i <= int.Parse(pagetotal); i++) { NextwaverDB.NColumns NCSPage = new NextwaverDB.NColumns(); NCSPage.Add(new NextwaverDB.NColumn("BOOKNO", bookno)); NCSPage.Add(new NextwaverDB.NColumn("PAGEVERSION", "1")); NCSPage.Add(new NextwaverDB.NColumn("PAGESTATUS", "Create")); NCSPage.Add(new NextwaverDB.NColumn("CREATEDATE", convertDatetime(DateTime.Now))); NCSPage.Add(new NextwaverDB.NColumn("CREATEBY", "System")); NCSPage.Add(new NextwaverDB.NColumn("UPDATEDATE", convertDatetime(DateTime.Now))); NCSPage.Add(new NextwaverDB.NColumn("UPDATEBY", "System")); NCSPage.Add(new NextwaverDB.NColumn("PAGENO", i.ToString())); AddDataXmlNode(xDocPage, RootPathPage + "/Item[@Name='PageNo']", i.ToString()); string strDocPage = xDocPage.OuterXml; string[] OPPage = WS.InsertData(Connection, OfficeSpaceId, DatabaseName, "Page", NCSPage.ExportString(), strDocPage, "System"); if (OPPage[0].ToUpper() == "OK") { System.Console.WriteLine("Create Book " + bookno + " Page " + i.ToString()); } else { File.AppendAllText("log.txt", Environment.NewLine + Environment.NewLine + DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss") + " :: " + OPPage[1]); System.Console.WriteLine(OPPage[1]); isuccess = false; break; } } } System.Console.WriteLine("Create Book " + bookno + " Success"); isSuccess = isuccess; } catch (Exception ex) { File.AppendAllText("log.txt", Environment.NewLine + Environment.NewLine + DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss") + " :: Book:" + bookno + " --> " + ex.Message); break; } if (isSuccess) { break; } else { System.Threading.Thread.Sleep(500); } } } // } }
static void Main(string[] args) { string ResultTableName = "TableData"; SqlConnection DBConnect = DBConnection.GetDBConnection(); SqlCommand DBCommand = new SqlCommand(); DBCommand.Connection = DBConnect; //DBCommand.CommandType = CommandType.Text; //DBCommand.CommandText = "select ID, BookNo, PageNo from [Page] P with(nolock)" // + " where not exists(select BookNo, PageNo from Record with(nolock)" // + " where BookNo = P.BookNo and PageNo = P.PageNo" // + " group by BookNo, PageNo)" // + " And BookNo in (select BookNo from Record with(nolock)" // + " group by BookNo)" // + " and BookNo>290" // //+ " and PageNo<152" // + " order by BookNo, PageNo"; DBCommand.CommandType = CommandType.Text; DBCommand.CommandText = "SELECT BB.ID,BB.BookNo,BB.PageNo,AA.PageNo FROM" + " (SELECT [BookNo]" + " ,[PageNo]" + " FROM [GunRegBook].[dbo].[Record] With(nolock)" + " Group By [BookNo]" + " ,[PageNo]) AA" + " RIGHT JOIN" + " (SELECT [ID],[BookNo],[PageNo] FROM [dbo].[Page]" + " WHERE [BookNo] in" + " (Select distinct([BookNo])" + " FROM [GunRegBook].[dbo].[Record] With(nolock))) BB ON AA.BookNo = BB.BookNo and AA.PageNo = BB.PageNo" + " Where AA.PageNo is null" + " ORDER BY BB.BookNo,BB.PageNo"; //DBCommand.CommandText = "SELECT *" + // " INTO #tmpData" + // " FROM (" + // " SELECT [BookNo],[GunRegID]" + // " , row_number() OVER(PARTITION BY [BookNo],[PageNo] ORDER BY [GunRegID]) AS [RowNo] FROM [GunRegBook].[dbo].[Record] With(nolock)" + // " WHERE [PageNo] = 1) C" + // " WHERE [RowNo] = 1" + // " SELECT BB.ID,BB.BookNo,BB.PageNo" + // " INTO #tmpData2" + // " FROM" + // " (SELECT [BookNo]" + // " ,[PageNo]" + // " FROM [GunRegBook].[dbo].[Record] With(nolock)" + // " Group By[BookNo]" + // " ,[PageNo]) AA" + // " RIGHT JOIN" + // " (SELECT [ID],[BookNo],[PageNo] FROM [dbo].[Page]" + // " WHERE [BookNo] in" + // " (Select distinct([BookNo])" + // " FROM [GunRegBook].[dbo].[Record] With(nolock))) BB ON AA.BookNo = BB.BookNo and AA.PageNo = BB.PageNo" + // " Where AA.PageNo is null" + // " ORDER BY BB.BookNo,BB.PageNo" + // " SELECT BB.*,AA.GunRegID FROM #tmpData AA" + // " right join #tmpData2 BB ON AA.BookNo=BB.BookNo" + // " Order By BB.BookNo,BB.PageNo" + // " DROP TABLE #tmpData" + // " DROP TABLE #tmpData2"; //DBCommand.Parameters.Add(new SqlParameter("@DateBegin", "0")); //DBCommand.Parameters.Add(new SqlParameter("@DateEnd", "2560071415")); //DBCommand.Parameters.Add(new SqlParameter("@Status", "Save")); DBCommand.CommandTimeout = 7200; SqlDataReader DBReader = default(SqlDataReader); DataTable TableResult = default(DataTable); try { DBConnect.Open(); DBReader = DBCommand.ExecuteReader(); if (DBReader.HasRows) { TableResult = new DataTable(); TableResult.Load(DBReader); TableResult.TableName = ResultTableName; } else { TableResult = new DataTable(); TableResult.Load(DBReader); TableResult.TableName = ResultTableName; } string Connection = "NextwaverDatabase"; string OfficeSpaceId = "OF.0001"; string DatabaseName = "GunBook"; string RootPathPage = "//Document/Data/Section[@ID='1']/Items[@Name='Page']"; XmlDocument xDoc; foreach (DataRow item in TableResult.Rows) { string ID = item["ID"].ToString(); WorkSpace.Service WS = new WorkSpace.Service(); xDoc = new XmlDocument(); String strDoc = WS.SelectLastDocument(Connection, OfficeSpaceId, DatabaseName, "Page", int.Parse(ID), "System"); strDoc = strDoc.Replace("null", ""); xDoc.LoadXml(strDoc); string BOOKNO = "" + GetDataXmlNode(xDoc, RootPathPage + "/Item[@Name='BookNo']"); string PAGENO = "" + GetDataXmlNode(xDoc, RootPathPage + "/Item[@Name='PageNo']"); string STATUS = "" + GetDataXmlNode(xDoc, RootPathPage + "/Item[@Name='PageStatus']"); string IMGURL = "" + GetDataXmlNode(xDoc, RootPathPage + "/Item[@Name='ImgUrl']"); if (BOOKNO == item["BookNo"].ToString() && PAGENO == item["PageNo"].ToString()) { string XPathDataRecord = "//Document/Data/Section[@ID='2']/Items[@Name='RecordInfo']"; XmlNode nodeDataGrid = xDoc.SelectSingleNode(XPathDataRecord); XmlNodeList listItem = nodeDataGrid.SelectNodes("./Item"); if (listItem.Count > 0 && listItem.Count <= 20) { NextwaverDB.NColumns NCS = new NextwaverDB.NColumns(); NCS.Add(new NextwaverDB.NColumn("PAGESTATUS", STATUS)); NextwaverDB.NWheres NWS = new NextwaverDB.NWheres(); NWS.Add(new NextwaverDB.NWhere("ID", ID)); strDoc = xDoc.OuterXml; string[] OP = WS.UpdateData(Connection, OfficeSpaceId, DatabaseName, "Page", NCS.ExportString(), NWS.ExportString(), strDoc, "System"); if (OP[0].ToUpper() == "OK") { Console.WriteLine(ID + "Book " + BOOKNO + " Page " + PAGENO + " ::Success"); } else { Console.WriteLine(ID + "Book " + BOOKNO + " Page " + PAGENO + " ::Fail"); } } } } } catch (Exception exDb) { } finally { DBConnect.Close(); } }
private void btnOK_Click(object sender, EventArgs e) { if (txbGroupName.Text == "") { MessageBox.Show("โปรดระบุชื่อกลุ่ม", "ข้อผิดพลาด", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (lbUsed.Items.Count == 0) { MessageBox.Show("โปรดเลือกผู้ใช้งาน", "ข้อผิดพลาด", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } DataTable dtUsed = (DataTable)lbUsed.DataSource; string Items = ""; for (int i = 0; i < dtUsed.Rows.Count; i++) { string ID = "" + dtUsed.Rows[i]["ID"]; string USERNAME = "" + dtUsed.Rows[i]["USERNAME"]; Items += "<Item C00='" + ID + "' C01='" + USERNAME + "' />"; } string strDoc = @"<Document ID='' Name=''> <Data> <Section ID='1' Name='' Type='STR'> <Items Name='' Type='SEQ'> <Means Name='Item'> <Mean ID='C00' Name='ID' Type='STR' /> <Mean ID='C01' Name='USERNAME' Type='STR' /> </Means> @Item </Items> </Section> </Data> </Document>"; strDoc = strDoc.Replace("@Item", Items); NextwaverDB.NColumns NCS = new NextwaverDB.NColumns(); NCS.Add(new NextwaverDB.NColumn("GROUP_NAME", txbGroupName.Text)); NCS.Add(new NextwaverDB.NColumn("CREATE_DATE", DateTime.Now.ToString("dd/MM/yyyy"))); NCS.Add(new NextwaverDB.NColumn("CREATE_BY", cMain.UserName)); NCS.Add(new NextwaverDB.NColumn("UPDATE_DATE", DateTime.Now.ToString("dd/MM/yyyy"))); NCS.Add(new NextwaverDB.NColumn("UPDATE_BY", cMain.UserName)); if (_Command == "New") { if (cConn.InsertData(cMain.Connection, cMain.OfficeSpaceId, "system", "user_group", NCS, strDoc)) { this.DialogResult = DialogResult.OK; this.Hide(); } else { MessageBox.Show("ไม่สามารถเพิ่มข้อมูลได้เนื่องจาก:" + cConn.ErrorMsg(), "ข้อผิดพลาด", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { NextwaverDB.NWheres NWS = new NextwaverDB.NWheres(); NWS.Add(new NextwaverDB.NWhere("ID", _ID)); if (cConn.UpdateData(cMain.Connection, cMain.OfficeSpaceId, "system", "user_group", NCS, NWS, strDoc)) { this.DialogResult = DialogResult.OK; this.Hide(); } else { MessageBox.Show("ไม่สามารถแก้ไขข้อมูลได้เนื่องจาก:" + cConn.ErrorMsg(), "ข้อผิดพลาด", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
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); } }
static void Main(string[] args) { string Connection = "NextwaverDatabase"; string OfficeSpaceId = "OF.0001"; string DatabaseName = "GunBook"; string UserName = "******"; string strHostName = System.Net.Dns.GetHostName(); string pathImgGun = System.Configuration.ConfigurationSettings.AppSettings["pathImgGun"]; bool isSuccess = false; String[] EditImageTemplate = System.IO.File.ReadAllLines("BookEdit.txt"); //NextwaverDB.NWheres NWSTest = new NextwaverDB.NWheres(); //NWSTest.Add(new NextwaverDB.NWhere("PAGESTATUS", "Create")); //DataTable dttest = WS.SelectAllColumnByWhere(Connection, OfficeSpaceId, DatabaseName, "Page", NWSTest.ExportString(), UserName); for (int index = 0; index < 20; index++) { try { WorkSpace.Service WS = new WorkSpace.Service(); string RootPathPage = "//Document/Data/Section[@ID='1']/Items[@Name='Page']"; foreach (string item in EditImageTemplate) { string Bookno = getParam(item, "BOOKNO"); NextwaverDB.NWheres NWS = new NextwaverDB.NWheres(); NWS.Add(new NextwaverDB.NWhere("BOOKNO", Bookno)); NextwaverDB.NColumns NCS_S = new NextwaverDB.NColumns(); NCS_S.Add(new NextwaverDB.NColumn("ID")); NCS_S.Add(new NextwaverDB.NColumn("BOOKNO")); NCS_S.Add(new NextwaverDB.NColumn("PAGENO")); NCS_S.Add(new NextwaverDB.NColumn("IMGURL")); string NCS_Encrypt = new EncryptDecrypt.CryptorEngine().Encrypt(NCS_S.ExportString(), true); string NWS_Encrypt = new EncryptDecrypt.CryptorEngine().Encrypt(NWS.ExportString(), true); DataTable dt = WS.SelectByColumnAndWhere(Connection, OfficeSpaceId, DatabaseName, "Page", NCS_Encrypt, NWS_Encrypt, UserName); int intPageNo = 0; int intRowInPage = 20; int intBegin = 0; int.TryParse(getParam(item, "BEGINID"), out intBegin); int.TryParse(getParam(item, "ROWINPAGE"), out intRowInPage); if (intRowInPage == 0) { intRowInPage = 20; } foreach (DataRow itemData in dt.Rows) { intPageNo = Convert.ToInt16(itemData["PAGENO"]); if (itemData["IMGURL"].ToString().Trim() != "") { XmlDocument xDocPage = new XmlDocument(); String strDoc = WS.SelectLastDocument(Connection, OfficeSpaceId, DatabaseName, "Page", int.Parse(itemData["ID"].ToString()), UserName); xDocPage.LoadXml(strDoc); string XPathDataRecord = "//Document/Data/Section[@ID='2']/Items[@Name='RecordInfo']"; XmlNode nodeDataGrid = xDocPage.SelectSingleNode(XPathDataRecord); XmlNodeList listItem = nodeDataGrid.SelectNodes("./Item"); if (listItem.Count == 0) { NextwaverDB.NColumns NColumns = new NextwaverDB.NColumns(); NColumns.Add(new NextwaverDB.NColumn("UPDATEDATE", convertDatetime(DateTime.Now))); NColumns.Add(new NextwaverDB.NColumn("UPDATEBY", UserName)); AddDataXmlNode(xDocPage, RootPathPage + "/Item[@Name='UpdateDate']", convertDatetime(DateTime.Now)); AddDataXmlNode(xDocPage, RootPathPage + "/Item[@Name='UpdateBy']", UserName); XmlAttribute att; XmlNode nodeItem; for (int i = intBegin + ((intPageNo - 1) * intRowInPage); i < (intPageNo * intRowInPage) + intBegin; i++) { nodeItem = xDocPage.CreateElement("Item"); att = xDocPage.CreateAttribute("C00"); att.Value = i.ToString(); nodeItem.Attributes.Append(att); att = xDocPage.CreateAttribute("C01"); att.Value = ""; nodeItem.Attributes.Append(att); att = xDocPage.CreateAttribute("C02"); att.Value = ""; nodeItem.Attributes.Append(att); att = xDocPage.CreateAttribute("C03"); att.Value = ""; nodeItem.Attributes.Append(att); att = xDocPage.CreateAttribute("C04"); att.Value = ""; nodeItem.Attributes.Append(att); att = xDocPage.CreateAttribute("C05"); att.Value = ""; nodeItem.Attributes.Append(att); att = xDocPage.CreateAttribute("C06"); att.Value = ""; nodeItem.Attributes.Append(att); att = xDocPage.CreateAttribute("C07"); att.Value = ""; nodeItem.Attributes.Append(att); att = xDocPage.CreateAttribute("C08"); att.Value = ""; nodeItem.Attributes.Append(att); att = xDocPage.CreateAttribute("C09"); att.Value = ""; nodeItem.Attributes.Append(att); att = xDocPage.CreateAttribute("C10"); att.Value = ""; nodeItem.Attributes.Append(att); att = xDocPage.CreateAttribute("C11"); att.Value = ""; nodeItem.Attributes.Append(att); att = xDocPage.CreateAttribute("C12"); att.Value = ""; nodeItem.Attributes.Append(att); att = xDocPage.CreateAttribute("C13"); att.Value = ""; nodeItem.Attributes.Append(att); att = xDocPage.CreateAttribute("C14"); att.Value = ""; nodeItem.Attributes.Append(att); att = xDocPage.CreateAttribute("C15"); att.Value = ""; nodeItem.Attributes.Append(att); att = xDocPage.CreateAttribute("C16"); att.Value = ""; nodeItem.Attributes.Append(att); att = xDocPage.CreateAttribute("C17"); att.Value = ""; nodeItem.Attributes.Append(att); nodeDataGrid.AppendChild(nodeItem); } string strDocPage = xDocPage.OuterXml; NextwaverDB.NWheres NWheres = new NextwaverDB.NWheres(); NWheres.Add(new NextwaverDB.NWhere("ID", itemData["ID"].ToString())); string[] msgOutput = WS.UpdateData(Connection, OfficeSpaceId, DatabaseName, "Page", NColumns.ExportString(), NWheres.ExportString(), strDocPage, UserName); if (msgOutput[0].ToUpper() == "OK") { System.Console.WriteLine("Update ID -->> BookNo " + itemData["BOOKNO"] + " PageNo " + itemData["PAGENO"]); } else { File.AppendAllText("Log.txt", Environment.NewLine + Environment.NewLine + DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss") + " :: Book:" + itemData["BOOKNO"] + " :: Page:" + itemData["PAGENO"] + " --> " + msgOutput[1]); } } } } } isSuccess = true; } catch (Exception ex) { File.AppendAllText("Log.txt", Environment.NewLine + Environment.NewLine + DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss") + " --> " + ex.Message); } if (isSuccess) { break; } else { System.Threading.Thread.Sleep(500); } } }