Esempio n. 1
0
        protected void btnOk_Click(object sender, EventArgs e)
        {
            GridViewRow gvr = selfPaymentGV.SelectedRow;

            int index = gvr.DataItemIndex;

            DataTable dt = Session["dtSources"] as DataTable;

            string strPaymentId = dt.Rows[index]["paymentId"].ToString();
            int    usrId        = int.Parse(dt.Rows[index]["usrId"].ToString());
            string strProjetTag = dt.Rows[index]["projectTag"].ToString();
            //string payNum = dt.Rows[index]["payPercent"].ToString();
            string strPayPercent    = dt.Rows[index]["payPercent"].ToString();
            string strSubContractId = dt.Rows[index]["subContractId"].ToString();
            string strProjetTagId   = dt.Rows[index]["projectTagId"].ToString();

            //string strFilter =
            //        " paymentId = " + "'" + strPaymentId + "'";
            //dt.DefaultView.RowFilter = strFilter;

            //DataTable doneTable = dt.DefaultView.ToTable("addTable");
            //dt.Clear();

            PaymentApplyProcess pap = Session["PaymentApplyProcess"] as PaymentApplyProcess;

            //pap.MyDst.Tables.Add(doneTable);
            //pap.SelfPaymentDone();

            Xm_db xmDataCont = Xm_db.GetInstance();

            int    paymentId     = int.Parse(strPaymentId);
            float  payPercent    = float.Parse(strPayPercent);
            int    subContractId = int.Parse(strSubContractId);
            int    projectTagId  = int.Parse(strProjetTagId);
            string payNum        = payPercent.ToString("p");

            xmDataCont.SelfPayment_done(paymentId, payPercent, subContractId, projectTagId);

            try
            {
                xmDataCont.SelfPayment_done(paymentId, payPercent, subContractId, projectTagId);

                xmDataCont.SubmitChanges(System.Data.Linq.ConflictMode.ContinueOnConflict);

                mailDetail(usrId, strProjetTag, payNum, xmDataCont);
            }
            catch (System.Data.Linq.ChangeConflictException cce)
            {
                string strEx = cce.Message;
                foreach (System.Data.Linq.ObjectChangeConflict occ in xmDataCont.ChangeConflicts)
                {
                    occ.Resolve(System.Data.Linq.RefreshMode.KeepChanges);
                }

                xmDataCont.SelfPayment_done(paymentId, payPercent, subContractId, projectTagId);

                xmDataCont.SubmitChanges();

                mailDetail(usrId, strProjetTag, payNum, xmDataCont);
            }

            var viewSubPayment =
                from subPayment in xmDataCont.View_subPayment
                where subPayment.EndTime > DateTime.Now &&
                subPayment.IsAccept.Equals(bool.TrueString) &&
                subPayment.DoneTime > DateTime.Now
                select subPayment;

            DataTable taskTable = viewSubPayment.ToDataTable();
            //pap.RealSelfPaymentView();
            //DataTable taskTable = pap.MyDst.Tables["view_subPayment"].DefaultView.ToTable();

            //string end = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss.fff");
            string strFilter = string.Empty;

            //    " isAccept = " + "'" + bool.TrueString + "'" +
            //    " and doneTime > " + "'" + end + "'";

            dt_modify(taskTable, strFilter);

            Session["dtSources"] = taskTable;

            selfPaymentGV.SelectedIndex       = -1;
            selfPaymentGV.Enabled             = true;
            selfPaymentGV.Columns[12].Visible = true;

            selfPaymentGV.DataSource = Session["dtSources"];
            selfPaymentGV.DataBind();

            btnOk.Visible = false;
            btnNo.Visible = false;
        }