示例#1
0
        public static int updateYctMode(YctMode m)
        {
            LogMode l = new LogMode(m.getModeStr());
            int     i = -1;

            try
            {
                conn = DbUtil.getConn();
                conn.Open();

                string sql = "update yct set [shop] = '" + m.shop
                             + "', [phone] = '" + m.phone + "', [money] = '" + m.money
                             + "', [time] = '" + m.time + "', [mark] = '" + m.mark
                             + "' where id = " + m.id;
                l          = new LogMode(sql);
                cmd        = new OleDbCommand(sql, conn);
                i          = cmd.ExecuteNonQuery();
                Const.info = "更新:" + i;
                l.act      = "ok\t" + l.act;
            }
            catch (Exception e)
            {
                Const.info = e.Message;
                l.act      = "fail:" + e.Message + "\t" + l.act;
            }
            finally
            {
                if (conn != null)
                {
                    conn.Close();
                }
            }
            insertLogMode(l);
            return(i);
        }
示例#2
0
        public static int insertYctMode(YctMode m)
        {
            LogMode l = new LogMode(m.getModeStr());
            int     i = -1;

            try
            {
                conn = DbUtil.getConn();
                conn.Open();

                string sql = "insert into yct([shop], [phone], [money], [time], [mark]) values('" + m.shop
                             + "','" + m.phone + "','" + m.money + "','" + m.time + "','" + m.mark + "')";
                l          = new LogMode(sql);
                cmd        = new OleDbCommand(sql, conn);
                i          = cmd.ExecuteNonQuery();
                Const.info = "插入:1";
                l.act      = "ok\t" + l.act;
            }
            catch (Exception e)
            {
                Const.info = e.Message;
                l.act      = "fail:" + e.Message + "\t" + l.act;
            }
            finally
            {
                if (conn != null)
                {
                    conn.Close();
                }
            }
            insertLogMode(l);
            return(i);
        }
示例#3
0
 private void addToolStripMenuItem_Click(object sender, EventArgs e)
 {
     YctMode mode = new YctMode();
     mode.shop = Const.userName;
     YctForm yf = new YctForm("新增", mode);
     yf.ShowDialog();
     showStatus(Const.info);
     searchBtn_Click(sender, e);
 }
示例#4
0
        private void addToolStripMenuItem_Click(object sender, EventArgs e)
        {
            YctMode mode = new YctMode();

            mode.shop = Const.userName;
            YctForm yf = new YctForm("新增", mode);

            yf.ShowDialog();
            showStatus(Const.info);
            searchBtn_Click(sender, e);
        }
示例#5
0
        private YctMode getModeFromNowRow()
        {
            YctMode         mode = new YctMode();
            DataGridViewRow r    = dataGridView.SelectedRows[0];

            mode.id    = int.Parse(r.Cells[0].Value.ToString());
            mode.shop  = r.Cells[1].Value.ToString();
            mode.phone = r.Cells[2].Value.ToString();
            mode.money = r.Cells[3].Value.ToString();
            mode.time  = Convert.ToDateTime(r.Cells[4].Value);
            mode.mark  = r.Cells[5].Value.ToString();

            return(mode);
        }
示例#6
0
        public static List <YctMode> getYctModes(string sql)
        {
            LogMode        l     = new LogMode(sql);
            List <YctMode> modes = new List <YctMode>();

            try
            {
                conn = DbUtil.getConn();
                cmd  = new OleDbCommand(sql, conn);
                conn.Open();
                reader = cmd.ExecuteReader();

                while (reader.Read())
                {
                    YctMode m = new YctMode();

                    m.id    = (int)reader["id"];
                    m.shop  = reader["shop"].ToString();
                    m.money = reader["money"].ToString();
                    m.phone = reader["phone"].ToString();
                    m.time  = (DateTime)reader["time"];
                    m.mark  = reader["mark"].ToString();

                    modes.Add(m);
                }
                l.act = "ok\t" + l.act;
                reader.Close();
                Const.info = "查询:" + modes.Count;
            }
            catch (Exception e)
            {
                Const.info = e.Message;
                l.act      = "fail:" + e.Message + "\t" + l.act;
            }
            finally
            {
                if (reader != null)
                {
                    reader.Close();
                }
                if (conn != null)
                {
                    conn.Close();
                }
            }
            insertLogMode(l);
            return(modes);
        }
示例#7
0
        private void delToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("删除后不可恢复,确定删除?", "删除提醒", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == DialogResult.OK)
            {
                YctMode mode = getModeFromNowRow();
                if (mode == null)
                {
                    MessageBox.Show("请选中一行进行删除操作。");
                    return;
                }

                string sql = "delete * from yct where id = " + mode.id;
                YctOrm.exeSql(sql);
                showStatus(Const.info);
            }
        }
示例#8
0
        private void updateToolStripMenuItem_Click(object sender, EventArgs e)
        {
            YctMode mode = getModeFromNowRow();

            if (mode == null)
            {
                MessageBox.Show("请选中一行进行修改操作。");
                return;
            }

            YctForm yf = new YctForm("修改", mode);

            yf.ShowDialog();
            showStatus(Const.info);
            searchBtn_Click(sender, e);
        }
示例#9
0
 public YctForm(string act, YctMode mode)
 {
     this.act  = act;
     this.mode = mode;
     InitializeComponent();
 }
示例#10
0
        private YctMode getModeFromNowRow()
        {
            YctMode mode = new YctMode();
            DataGridViewRow r = dataGridView.SelectedRows[0];

            mode.id = int.Parse( r.Cells[0].Value.ToString());
            mode.shop = r.Cells[1].Value.ToString();
            mode.phone = r.Cells[2].Value.ToString();
            mode.money = r.Cells[3].Value.ToString();
            mode.time = Convert.ToDateTime(r.Cells[4].Value);
            mode.mark = r.Cells[5].Value.ToString();

            return mode;
        }
示例#11
0
        public static int updateYctMode(YctMode m)
        {
            LogMode l = new LogMode(m.getModeStr());
            int i = -1;
            try
            {
                conn = DbUtil.getConn();
                conn.Open();

                string sql = "update yct set [shop] = '" + m.shop
                    + "', [phone] = '" + m.phone + "', [money] = '" + m.money
                    + "', [time] = '" + m.time + "', [mark] = '" + m.mark
                    + "' where id = " + m.id;
                l = new LogMode(sql);
                cmd = new OleDbCommand(sql, conn);
                i = cmd.ExecuteNonQuery();
                Const.info = "更新:" + i;
                l.act = "ok\t" + l.act;
            }
            catch (Exception e)
            {
                Const.info = e.Message;
                l.act = "fail:" + e.Message + "\t" + l.act;
            }
            finally
            {
                if (conn != null)
                {
                    conn.Close();
                }
            }
            insertLogMode(l);
            return i;
        }
示例#12
0
        public static int insertYctMode(YctMode m)
        {
            LogMode l = new LogMode(m.getModeStr());
            int i = -1;
            try
            {
                conn = DbUtil.getConn();
                conn.Open();

                string sql = "insert into yct([shop], [phone], [money], [time], [mark]) values('" + m.shop
                    + "','" + m.phone + "','" + m.money + "','" + m.time + "','" + m.mark + "')";
                l = new LogMode(sql);
                cmd = new OleDbCommand(sql, conn);
                i = cmd.ExecuteNonQuery();
                Const.info = "插入:1";
                l.act = "ok\t" + l.act;
            }
            catch (Exception e)
            {
                Const.info = e.Message;
                l.act = "fail:" + e.Message + "\t" + l.act;
            }
            finally
            {
                if (conn != null)
                {
                    conn.Close();
                }
            }
            insertLogMode(l);
            return i;
        }
示例#13
0
        public static List<YctMode> getYctModes(string sql)
        {
            LogMode l = new LogMode(sql);
            List<YctMode> modes = new List<YctMode>();
            try
            {
                conn = DbUtil.getConn();
                cmd = new OleDbCommand(sql, conn);
                conn.Open();
                reader = cmd.ExecuteReader();

                while (reader.Read())
                {
                    YctMode m = new YctMode();

                    m.id = (int)reader["id"];
                    m.shop = reader["shop"].ToString();
                    m.money = reader["money"].ToString();
                    m.phone = reader["phone"].ToString();
                    m.time = (DateTime)reader["time"];
                    m.mark = reader["mark"].ToString();

                    modes.Add(m);
                }
                l.act = "ok\t" + l.act;
                reader.Close();
                Const.info = "查询:" + modes.Count;
            }
            catch (Exception e)
            {
                Const.info = e.Message;
                l.act = "fail:" + e.Message + "\t" + l.act;
            }
            finally
            {
                if (reader != null)
                {
                    reader.Close();
                }
                if (conn != null)
                {
                    conn.Close();
                }
            }
            insertLogMode(l);
            return modes;
        }
示例#14
0
 public YctForm(string act, YctMode mode)
 {
     this.act = act;
     this.mode = mode;
     InitializeComponent();
 }