コード例 #1
0
    protected void GridViewRevenue_RowEditing(object sender, GridViewEditEventArgs e)
    {
        logger.Info(HttpContext.Current.Request.Cookies["User_ID"].Value + " " + System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString() + " " + System.Reflection.MethodBase.GetCurrentMethod().Name);

        try
        {
            string        User_ID    = HttpContext.Current.Request.Cookies["User_ID"].Value;
            dbo_UserClass user_class = dbo_UserDataClass.Select_Record(User_ID);

            DateTime?Begin = null;
            if (!string.IsNullOrEmpty(txtPost_Date.Text))
            {
                Begin = DateTime.Parse(txtPost_Date.Text);
            }
            List <dbo_RevenueExpenseClass> item = dbo_RevenueExpenseDataClass.Search(txtPost_No.Text, Begin, null, user_class.CV_CODE);

            item = item.Where(f => f.Account_No.Substring(6, 2) == "RV").ToList();

            GridViewRevenue.ShowFooter = false;
            GridViewRevenue.EditIndex  = e.NewEditIndex;
            GridViewRevenue.DataSource = item;
            GridViewRevenue.DataBind();
        }
        catch (Exception ex)
        {
            logger.Error(ex.Message);
        }
    }
コード例 #2
0
    protected void btnCreateNew_Click(object sender, EventArgs e)
    {
        logger.Info(HttpContext.Current.Request.Cookies["User_ID"].Value + " " + System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString() + " " + System.Reflection.MethodBase.GetCurrentMethod().Name);
        try
        {
            string        User_ID    = HttpContext.Current.Request.Cookies["User_ID"].Value;
            dbo_UserClass user_class = dbo_UserDataClass.Select_Record(User_ID);

            DateTime?Begin = null;
            DateTime?End   = null;


            if (!string.IsNullOrEmpty(txtStartDate.Text))
            {
                Begin = DateTime.Parse(txtStartDate.Text);
            }
            if (!string.IsNullOrEmpty(txtEndDate.Text))
            {
                End = DateTime.Parse(txtEndDate.Text);
            }

            GridViewRevenue.ShowFooter = true;
            List <dbo_RevenueExpenseClass> item = dbo_RevenueExpenseDataClass.Search(txtPost_No.Text, Begin, End, user_class.CV_CODE);

            item = item.Where(f => f.Account_No.Substring(6, 2) == "RV").ToList();

            if (item.Count == 0)
            {
                item.Add(new dbo_RevenueExpenseClass());
                GridViewRevenue.DataSource = item;
                GridViewRevenue.DataBind();
                GridViewRevenue.Rows[0].Visible = false;
            }
            else
            {
                GridViewRevenue.DataSource = item;
                GridViewRevenue.DataBind();
            }

            DropDownList ddl = (DropDownList)GridViewRevenue.FooterRow.FindControl("ddlFooterDetail");

            List <dbo_AccountCodeClass> account = dbo_AccountTypeDataClass.GetAccountRevenue();

            ddl.DataSource     = account;
            ddl.DataTextField  = "Account_Name";
            ddl.DataValueField = "Account_Code";
            ddl.DataBind();

            TextBox txtFooterRevenue_Amount = (TextBox)GridViewRevenue.FooterRow.FindControl("txtFooterRevenue_Amount");
            txtFooterRevenue_Amount.Attributes.Add("onkeypress", "javascript:return validateFloatKeyPress(this, event);");

            System.Threading.Thread.Sleep(500);
            ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "SAMWAIT", "myApp.hidePleaseWait();", true);
        }
        catch (Exception ex)
        {
            logger.Error(ex.Message);
        }
    }
コード例 #3
0
    protected void ButtonAddNew_Click(object sender, EventArgs e)
    {
        logger.Info(HttpContext.Current.Request.Cookies["User_ID"].Value + " " + System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString() + " " + System.Reflection.MethodBase.GetCurrentMethod().Name);


        try
        {
            string        User_ID    = HttpContext.Current.Request.Cookies["User_ID"].Value;
            dbo_UserClass user_class = dbo_UserDataClass.Select_Record(User_ID);

            string Post_No = GenerateID.Post_No(user_class.CV_CODE);

            List <dbo_RevenueExpenseClass> item_rev = dbo_RevenueExpenseDataClass.Search(Post_No, null, null, user_class.CV_CODE);

            if (item_rev.Count == 0)
            {
                pnlForm.Visible = true;
                pnlGrid.Visible = false;

                Textbox1.Text     = "0";
                Textbox2.Text     = "0";
                txtPost_Date.Text = DateTime.Now.ToShortDateString();
                txtPost_No.Text   = GenerateID.Post_No(user_class.CV_CODE);

                List <dbo_RevenueExpenseClass> item = dbo_RevenueExpenseDataClass.Search(txtPost_No.Text, null, null, user_class.CV_CODE);

                List <dbo_RevenueExpenseClass> item_rv = item.Where(f => f.Account_No.Substring(6, 2) == "RV").ToList(); //รายรับ
                List <dbo_RevenueExpenseClass> item_ep = item.Where(f => f.Account_No.Substring(6, 2) == "EP").ToList(); //รายจ่าย

                GridViewRevenue.DataSource = item_rv;
                GridViewRevenue.DataBind();

                GridViewExpense.DataSource = item_ep;
                GridViewExpense.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.Message);
        }
    }
コード例 #4
0
    protected void GridViewRevenue_Expense_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        logger.Info(HttpContext.Current.Request.Cookies["User_ID"].Value + " " + System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString() + " " + System.Reflection.MethodBase.GetCurrentMethod().Name);

        if (e.CommandName == "_Delete")
        {
            LinkButton lnkView = (LinkButton)e.CommandSource;
            string     Post_No = lnkView.CommandArgument;

            dbo_RevenueExpenseDataClass.DeletebyPostNo(Post_No);

            System.Threading.Thread.Sleep(500);
            ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "SAMWAIT", "myApp.hidePleaseWait();", true);
            Show("ลบข้อมูลสำเร็จ");
            btnSearchSubmit_Click(null, null);
        }
        else if (e.CommandName == "View")
        {
            LinkButton lnkView = (LinkButton)e.CommandSource;
            string     Post_No = lnkView.CommandArgument;

            pnlForm.Visible = true;
            pnlGrid.Visible = false;

            string        User_ID    = HttpContext.Current.Request.Cookies["User_ID"].Value;
            dbo_UserClass user_class = dbo_UserDataClass.Select_Record(User_ID);

            List <dbo_RevenueExpenseClass> item = dbo_RevenueExpenseDataClass.Search(Post_No, null, null, user_class.CV_CODE);

            List <dbo_RevenueExpenseClass> item_rv = item.Where(f => f.Account_No.Substring(6, 2) == "RV").ToList();
            List <dbo_RevenueExpenseClass> item_ep = item.Where(f => f.Account_No.Substring(6, 2) == "EP").ToList();

            dbo_RevenueExpenseClass it = item.FirstOrDefault();
            txtPost_Date.Text = Convert.ToDateTime(it.Post_Date).ToString("dd/MM/yyyy");
            //txtPost_Date.Text = Convert.ToString(it.Post_Date);
            txtPost_No.Text = Post_No;
            Textbox1.Text   = item_rv.Sum(f => f.Amount).Value.ToString("#,##0.##");
            Textbox2.Text   = item_ep.Sum(f => f.Amount).Value.ToString("#,##0.##");

            GridViewRevenue.DataSource = item_rv;
            GridViewRevenue.DataBind();

            GridViewExpense.DataSource = item_ep;
            GridViewExpense.DataBind();
        }
    }