Beispiel #1
0
    protected void gdvAccountCode_RowUpdating(object sender, GridViewUpdateEventArgs e)
    {
        try
        {
            int      current_index     = int.Parse(ViewState["current_index"].ToString());
            GridView gv                = (GridView)gdvAccountType.Rows[current_index + 1].FindControl("gdvAccountCode");
            Label    lblAccountType_ID = (Label)gdvAccountType.Rows[current_index].FindControl("lblAccountType_ID");

            TextBox txtEditAccountCode_Name = (TextBox)gv.Rows[e.RowIndex].FindControl("txtEditAccountCode_Name");
            Label   lblAccountCode_ID       = (Label)gv.Rows[e.RowIndex].FindControl("lblAccountCode_ID");
            if (!string.IsNullOrEmpty(txtEditAccountCode_Name.Text))
            {
                dbo_AccountCodeClass cycle = new dbo_AccountCodeClass()
                {
                    Account_Type_ID = lblAccountType_ID.Text,
                    Account_Name    = txtEditAccountCode_Name.Text,
                    Account_Code    = lblAccountCode_ID.Text
                };

                bool   success = false;
                string User_ID = HttpContext.Current.Request.Cookies["User_ID"].Value;
                success = dbo_AccountTypeDataClass.UpdateAccountCode_New(cycle, User_ID);

                if (success)
                {
                    gv.ShowFooter = false;
                    gv.EditIndex  = -1;

                    List <dbo_AccountCodeClass> item_value = dbo_AccountTypeDataClass.GetAccountCode_New(lblAccountType_ID.Text);
                    gv.DataSource = item_value;
                    gv.DataBind();
                }

                System.Threading.Thread.Sleep(500);
                ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "SAMWAIT", "myApp.hidePleaseWait();", true);
            }
            else
            {
                System.Threading.Thread.Sleep(500);
                ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "SAMWAIT", "myApp.hidePleaseWait();", true);

                Show("กรุณากรอกข้อมูลที่จำเป็นให้ครบถ้วน");
            }
        }
        catch (Exception ex)
        {
            logger.Error(ex);
        }
    }
Beispiel #2
0
    public static Boolean InsertAccountCode_New(dbo_AccountCodeClass clsAccountCode, string userName, string Account_ID)
    {
        /// Account_Type_ID	Account_Code	Account_Name
        /// 01	            0101	        11223344556677
        /// 01	            0102	        11223344556677
        /// 02	            0202	        11223344556677

        SqlConnection connection      = SAMDataClass.GetConnection();
        string        insertProcedure = "InsertAccountType";
        SqlCommand    insertCommand   = new SqlCommand(insertProcedure, connection);

        insertCommand.CommandType = CommandType.StoredProcedure;
        insertCommand.Parameters.AddWithValue("@Mode", "InsAccountCode");
        insertCommand.Parameters.AddWithValue("@Account_Type_ID", clsAccountCode.Account_Type_ID);
        insertCommand.Parameters.AddWithValue("@InsertParam", clsAccountCode.Account_Name);
        insertCommand.Parameters.AddWithValue("@InsertBy", userName);
        insertCommand.Parameters.AddWithValue("@Account_ID", Account_ID);
        try
        {
            connection.Open();
            int count = insertCommand.ExecuteNonQuery();
            if (count > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
        catch (SqlException ex)
        {
            logger.Error(ex.Message);
            return(false);
        }
        finally
        {
            connection.Close();
        }
    }