Beispiel #1
0
    protected void GridViewExpense_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) == "EP").ToList();

            GridViewExpense.ShowFooter = false;
            GridViewExpense.EditIndex  = e.NewEditIndex;
            GridViewExpense.DataSource = item;
            GridViewExpense.DataBind();
        }
        catch (Exception ex)
        {
            logger.Error(ex.Message);
        }
    }
Beispiel #2
0
    protected void btnAddNewExpense_Click(object sender, EventArgs e)
    {
        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);
            }

            GridViewExpense.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) == "EP").ToList();

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

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

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

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

            TextBox txtFooter_Amount = (TextBox)GridViewExpense.FooterRow.FindControl("txtFooter_Amount");
            txtFooter_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);
        }
    }
Beispiel #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);
        }
    }
Beispiel #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();
        }
    }
Beispiel #5
0
    // Code for Expense view
    void FillGridExpense()
    {
        if ((string)Session["AdminSessionID"] != null)
        {
            SqlDataAdapter GDA = new SqlDataAdapter(" " +

                                                    " select Code, ExpenseType=(select [Name] from fp_ComboDetail where Code=Source), " +
                                                    " ExpenseAmount=ExpenseMonthly, ExpensePeriod " +
                                                    " from fp_Expense where ClientCode=" + ViewState["xClientCode"] + " " +
                                                    "  ", Con);

            DataSet GDS = new DataSet();
            Con.Open();
            GDA.Fill(GDS);
            Con.Close();

            GridViewExpense.DataSource = GDS;
            GridViewExpense.DataBind();
        }
        else
        {
            Response.Redirect("SessionExpired.aspx");
        }
    }