示例#1
0
        private void cSaveButton_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("Are you sure that you want to save changes to database?", "WARNING!", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
            {
                List <DataGridViewRow> rows = cTpGrid.Rows.Cast <DataGridViewRow>().ToList();
                _ = rows.Concat(RemovedRows).ToList();

                rows.ForEach(row =>
                {
                    COptionalTeleport tp = new COptionalTeleport();

                    tp.m_Service       = bool.Parse(row.Cells[0].Value.ToString()) ? (byte)1 : (byte)0;
                    tp.m_ID            = Convert.ToInt32(row.Cells[1].Value);
                    tp.m_ObjName128    = row.Cells[2].Value.ToString();
                    tp.m_ZoneName128   = row.Cells[3].Value.ToString();
                    tp.m_GenRegionID   = Convert.ToInt16(row.Cells[4].Value);
                    tp.m_GenPos_X      = Convert.ToInt16(row.Cells[5].Value);
                    tp.m_GenPos_Y      = Convert.ToInt16(row.Cells[6].Value);
                    tp.m_GenPos_Z      = Convert.ToInt16(row.Cells[7].Value);
                    tp.m_GenWorldID    = (short)Globals.GameWorldIDList[row.Cells[8].Value.ToString()];
                    tp.m_RegionIDGroup = Convert.ToInt32(row.Cells[9].Value);
                    tp.m_MapPoint      = bool.Parse(row.Cells[10].Value.ToString()) ? (byte)1 : (byte)0;
                    tp.m_LevelMin      = Convert.ToInt16(row.Cells[11].Value);
                    tp.m_LevelMax      = Convert.ToInt16(row.Cells[12].Value);
                    tp.m_Status        = (EditStatus)row.Tag;

                    if (tp.m_Status == EditStatus.New)
                    {
                        tp.m_ID = row.Index;
                    }

                    tp.SaveToDatabase();

                    if ((EditStatus)row.Tag != EditStatus.Removed)
                    {
                        row.Tag            = EditStatus.Notr;
                        row.Cells[1].Value = tp.m_ID;
                    }
                });
                RemovedRows.Clear();
                CTeleportBase.SaveToClient("refoptionalteleport.txt");
                MessageBox.Show("Your changes is successfully saved!", "NOTICE", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
示例#2
0
 public bool HasRemovedRows(String table)
 {
     return(RemovedRows.ContainsKey(table) && RemovedRows[table].Count > 0);
 }