Ejemplo n.º 1
0
        public void AddHead(mst_acc_head mst)
        {
            try
            {
                using (MySqlConnection con = new MySqlConnection(ConfigurationManager.ConnectionStrings["DefaultConnection"].ToString()))
                {
                    string query = @"INSERT INTO mst_acc_head
                               (session
                                ,acc_id
                                ,acc_name)
                                VALUES
                               (@session
                                ,@acc_id
                                ,@acc_name)";

                    string maxid = "select ifnull(MAX(acc_id),0)+1 from mst_acc_head where session = @session";


                    mst_sessionMain sess = new mst_sessionMain();

                    string ses = sess.findActive_Session();

                    int id = con.ExecuteScalar <int>(maxid, new { session = ses });



                    mst.acc_id  = id;
                    mst.session = ses;

                    con.Execute(query, new
                    {
                        mst.acc_id,
                        mst.acc_name,
                        mst.session
                    });
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Ejemplo n.º 2
0
        public void EditAccount(mst_acc_head mst)
        {
            try
            {
                using (MySqlConnection con = new MySqlConnection(ConfigurationManager.ConnectionStrings["DefaultConnection"].ToString()))
                {
                    mst_sessionMain sess = new mst_sessionMain();

                    string ses = sess.findActive_Session();

                    mst.session = ses;

                    string query = "UPDATE mst_acc_head SET acc_name = @acc_name WHERE acc_id = @acc_id and session = @session";

                    con.Execute(query, mst);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }