예제 #1
0
 /// <summary>
 /// Set Period
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected void btnSet_Click(object sender, EventArgs e)
 {
     var _psr = new PeriodServiceClient();
     int _yesrValue = int.Parse(yearSet.Text);
     _psr.SetPeriod(_yesrValue);
     loadPeriod();
     Page.ClientScript.RegisterStartupScript(GetType(), "Success string", "Alert('Set Success !');", true);
 }
 protected void btn_Cancel_Click(object sender, EventArgs e)
 {
     PeriodServiceClient _pclient = new PeriodServiceClient();
     Period _period = new PeriodCollection(_pclient.GetCurrentPeriod())[0];
     mp1.Hide();
     GetData(_period);
     //gv_Transaction.BackColor = System.Drawing.ColorTranslator.FromHtml("#FFFFFF");
     up_Edit.Update();
     if (Session["Rowindex"] != null)
         gv_Transaction.Rows[Convert.ToInt32(Session["Rowindex"])].BackColor = System.Drawing.ColorTranslator.FromHtml("#023e91");
 }
예제 #3
0
 /// <summary>
 /// Initial Period repeater
 /// </summary>
 private void loadPeriod()
 {
     var _psr = new PeriodServiceClient();
     rptPeriod.DataSource = _psr.GetPeriods().ToList();
     rptPeriod.DataBind();
 }
        protected void btn_Confirm_Click(object sender, EventArgs e)
        {
            CheckExchange();
            if (tx_FromEntity.Text.Equals("") || tx_ToEntity.Text.Equals(""))
            {
                Alert(" You have to select [ From cloumn ] or [ To Entity ] . ");
                return;
            }
            if (tx_Amount.Text.Equals(""))
            {
                Alert(" You have to key in To Amount . ");
                return;
            }
            if (tx_FromAmount.Text.Equals(""))
            {
                Alert(" You have to key in From Amount . ");
                return;
            }
            string regex = "^[0-9]{0,5}$|^[0-9]{0,5}\\.[0-9]{0,2}$ ";
            System.Text.RegularExpressions.RegexOptions options = ((System.Text.RegularExpressions.RegexOptions.IgnorePatternWhitespace | System.Text.RegularExpressions.RegexOptions.Multiline)
            | System.Text.RegularExpressions.RegexOptions.IgnoreCase);
            System.Text.RegularExpressions.Regex reg = new System.Text.RegularExpressions.Regex(regex, options);
            if (!reg.IsMatch(tx_Amount.Text))
            {
                Alert(" Please check Amount column . ");
                return;
            }
            using (DataEntryServiceClient _client = new DataEntryServiceClient())
            {
                PeriodServiceClient _pclient = new PeriodServiceClient();
                Period _period = new PeriodCollection(_pclient.GetCurrentPeriod())[0];

                int _FromEntityID = Convert.ToInt32(lb_FromEntityID.Text);
                int _ToEntityID = Convert.ToInt32(lb_ToEntityID.Text);
                decimal _Amount = Convert.ToDecimal(tx_Amount.Text);
                decimal _FromAmount = Convert.ToDecimal(tx_FromAmount.Text);
                if ((bool)Session["IsAdd"])
                {
                    Transaction _tran = new Transaction();
                    _tran.Period.ID = _period.ID;
                    _tran.IsPay = IsPay.N;
                    _tran.Creator.UserID = Convert.ToInt32(Session["Userid"]);
                    _tran.Amount = _FromAmount;
                    _tran.FromEntity.EntityID = _FromEntityID;
                    _tran.ToEntity.EntityID = _ToEntityID;
                    _tran.FromCurrency = lb_FromCurrency.Text;
                    _tran.ToCurrency = lb_ToCurrency.Text;
                    _tran.ExchangeRate = Convert.ToDecimal(tx_ExchangeRate.Text);
                    _tran.To_Amount = _Amount;
                    _client.InsertTransaction(_tran);
                    mp1.Hide();
                    GetData(_period);
                }
                else
                {
                    Transaction _tran = new TransactionCollection(_client.LoadTransactionByID(Convert.ToInt32(lb_ID.Text)))[0];
                    _tran.FromEntity.EntityID = _FromEntityID;
                    _tran.ToEntity.EntityID = _ToEntityID;
                    _tran.Amount = _FromAmount;
                    _tran.To_Amount = _Amount;
                    _tran.FromCurrency = lb_FromCurrency.Text;
                    _tran.ToCurrency = lb_ToCurrency.Text;
                    _tran.ExchangeRate = Convert.ToDecimal(tx_ExchangeRate.Text);
                    _client.Updatetransaction(_tran);
                    mp1.Hide();
                    GetData(_period);

                }
            }
            if(Session["Rowindex"]!=null)
                gv_Transaction.Rows[Convert.ToInt32(Session["Rowindex"])].BackColor = System.Drawing.ColorTranslator.FromHtml("#023e91");
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            //ToDo
            CheckLimit.CheckPage(Request["menuid"]);
            tx_FromEntity.Attributes.Add("readonly","true");
            tx_ToEntity.Attributes.Add("readonly", "true");
            tx_Amount.Attributes.Add("OnKeyPress", "txtKeyNumber();");
            if (!IsPostBack)
            {
                Session["IsAdd"] = false;
                Session["Rowindex"] = null;
                //tree
                BindTree();
                PeriodServiceClient _pclient = new PeriodServiceClient();
                Period _period = new PeriodCollection(_pclient.GetCurrentPeriod())[0];
                GetData(_period);

            }
        }
        protected void gv_Transaction_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            GridViewRow row = (GridViewRow)((Control)e.CommandSource).NamingContainer;
            int id = Convert.ToInt32(gv_Transaction.DataKeys[row.RowIndex].Values[0]);
            string _FromEntityID =gv_Transaction.DataKeys[row.RowIndex].Values[1].ToString();
            string _ToEntityID = gv_Transaction.DataKeys[row.RowIndex].Values[2].ToString();

            using (DataEntryServiceClient _client = new DataEntryServiceClient())
            {
                PeriodServiceClient _pclient = new PeriodServiceClient();
                Period _period = new PeriodCollection(_pclient.GetCurrentPeriod())[0];
                if (e.CommandName.Equals("Btn_Notice"))
                {
                    _client.SetNotices(id, Convert.ToInt32(Session["Userid"]));
                    GetData(_period);

                }
                else if (e.CommandName.Equals("Btn_Confirm"))
                {
                    Transaction _tran = new TransactionCollection(_client.LoadTransactionByID(id))[0];
                    _tran.Updater.UserID = Convert.ToInt32(Session["Userid"]);
                    _tran.Period = _period;
                    _client.SetConfirm(_tran);
                    GetData(_period);

                }
                else if (e.CommandName.Equals("Btn_Edit"))
                {
                    Session["IsAdd"] = false;
                    tx_FromEntity.Text = gv_Transaction.Rows[row.RowIndex].Cells[0].Text ;
                    tx_ToEntity.Text = gv_Transaction.Rows[row.RowIndex].Cells[2].Text;
                    tx_Amount.Text = gv_Transaction.Rows[row.RowIndex].Cells[5].Text;
                    lb_FromEntityID.Text = _FromEntityID;
                    lb_ToEntityID.Text = _ToEntityID;
                    lb_FromCurrency.Text = gv_Transaction.Rows[row.RowIndex].Cells[1].Text;
                    lb_ToCurrency.Text = gv_Transaction.Rows[row.RowIndex].Cells[3].Text;
                    tx_ExchangeRate.Text = gv_Transaction.Rows[row.RowIndex].Cells[4].Text;
                    btn_Confirm.Text = "";
                    lb_ID.Text = id.ToString();
                    up_Edit.Update();
                    Session["Rowindex"] = row.RowIndex;
                    mp1.Show();

                }
                gv_Transaction.Rows[row.RowIndex].BackColor = System.Drawing.ColorTranslator.FromHtml("#023e91");
            }
        }
        protected void btn_Search_Click(object sender, EventArgs e)
        {
            Period _period = new Period();
            if(tx_Period.Text.Equals(""))
                GetData(_period);
            else
            {
                PeriodServiceClient _pclient = new PeriodServiceClient();
                try
                {
                    _period = new PeriodCollection(_pclient.DateOfPeriod(tx_Period.Text))[0];
                    GetData(_period);
                }
                catch (Exception)
                {
                    throw;
                }

            }
        }