Пример #1
0
        protected void btnGrantSubmit_Click(object sender, EventArgs e)
        {
            try
            {
                lblErrorMsg.Text = "";
                int?     nullable         = null;
                DateTime?nullableDateTime = null;
                if (ViewState["SelectedFundId"] != null && ViewState["SelectedFundId"].ToString() != "")
                {
                    if (txtBeginDate.Text != "")
                    {
                        if (txtEndDate.Text != "")
                        {
                            if (Convert.ToDateTime(txtBeginDate.Text) > Convert.ToDateTime(txtEndDate.Text))
                            {
                                lblErrorMsg.Text = "Grant end date can't be less than begin date.";
                                txtEndDate.Focus();
                                return;
                            }
                        }
                    }
                    if (txtVHCBGrantName.Text == "")
                    {
                        lblErrorMsg.Text = "Enter VHCB Name to add the Grant Info details for the fund ";
                        txtVHCBGrantName.Focus();
                        return;
                    }
                    //if (ddlGrantSource.SelectedIndex == 0 || ddlContact.SelectedIndex==0 || ddlStaff.SelectedIndex==0)
                    //{
                    //    lblErrorMsg.Text = "Source of Grant, Contact and Staff were required to add Grant information. ";
                    //    return;
                    //}
                    if (ddlGrantor.SelectedIndex != 0)
                    {
                        if (hfGIUpdateMode.Value == "false")
                        {
                            FinancialTransactions.AddGrantInfo(Convert.ToInt32(ViewState["SelectedFundId"]),
                                                               txtGrantName.Text,
                                                               txtVHCBGrantName.Text,
                                                               Convert.ToInt32(ddlGrantor.SelectedValue.ToString()),
                                                               ddlGrantSource.SelectedIndex != 0 ? Convert.ToInt32(ddlGrantSource.SelectedValue.ToString()) : nullable,
                                                               txtAwardNum.Text,
                                                               txtAwdAmt.Text == "" ? 0 : Convert.ToDecimal(txtAwdAmt.Text),
                                                               txtBeginDate.Text == "" ? nullableDateTime : Convert.ToDateTime(txtBeginDate.Text),
                                                               txtEndDate.Text == "" ? nullableDateTime : Convert.ToDateTime(txtEndDate.Text),
                                                               ddlStaff.SelectedIndex != 0 ? Convert.ToInt32(ddlStaff.SelectedValue.ToString()) : nullable,
                                                               ddlContact.SelectedIndex != 0 ? Convert.ToInt32(ddlContact.SelectedValue.ToString()) : nullable,
                                                               txtCGDANum.Text,
                                                               rdbtnSignedGrant.SelectedIndex == 0 ? true : false,
                                                               rdBtnFedFunds.SelectedIndex == 0 ? true : false,
                                                               rdBtnMatch.SelectedIndex == 0 ? true : false,
                                                               rdBtnFundsRec.SelectedIndex == 0 ? true : false,
                                                               rdBtnAdmin.SelectedIndex == 0 ? true : false
                                                               );
                        }
                        else
                        {
                            FinancialTransactions.UpdateGrantInfo(Convert.ToInt32(hfGInfoId.Value),
                                                                  txtGrantName.Text,
                                                                  txtVHCBGrantName.Text,
                                                                  Convert.ToInt32(ddlGrantor.SelectedValue.ToString()),
                                                                  ddlGrantSource.SelectedIndex != 0 ? Convert.ToInt32(ddlGrantSource.SelectedValue.ToString()) : nullable,
                                                                  txtAwardNum.Text,
                                                                  txtAwdAmt.Text == "" ? 0 : decimal.Parse(txtAwdAmt.Text, NumberStyles.Currency),// Convert.ToDecimal(txtAwdAmt.Text),
                                                                  txtBeginDate.Text == "" ? nullableDateTime : Convert.ToDateTime(txtBeginDate.Text),
                                                                  txtEndDate.Text == "" ? nullableDateTime : Convert.ToDateTime(txtEndDate.Text),
                                                                  ddlStaff.SelectedIndex != 0 ? Convert.ToInt32(ddlStaff.SelectedValue.ToString()) : nullable,
                                                                  ddlContact.SelectedIndex != 0 ? Convert.ToInt32(ddlContact.SelectedValue.ToString()) : nullable,
                                                                  txtCGDANum.Text,
                                                                  rdbtnSignedGrant.SelectedIndex == 0 ? true : false,
                                                                  rdBtnFedFunds.SelectedIndex == 0 ? true : false,
                                                                  rdBtnMatch.SelectedIndex == 0 ? true : false,
                                                                  rdBtnFundsRec.SelectedIndex == 0 ? true : false,
                                                                  rdBtnAdmin.SelectedIndex == 0 ? true : false
                                                                  );
                            hfGIUpdateMode.Value = "false";
                            gvGranInfo.EditIndex = -1;
                        }
                        ClearGrantInfo();
                    }
                    else
                    {
                        lblErrorMsg.Text = "Select Grantor to add Grant Information.";
                    }
                }
                else
                {
                    lblErrorMsg.Text = "Select Fund to add associated Grant information.";
                }

                BindFundGrantInfo();
            }
            catch (Exception ex)
            {
                lblErrorMsg.Text = ex.Message;
            }
        }