Esempio n. 1
0
        protected void btnOk_Click(object sender, EventArgs e)
        {
            int index = int.Parse(btnOk.CommandArgument);

            int       dataIndex = subContractGV.Rows[index].DataItemIndex;
            DataTable dt        = (DataTable)Session["dtSources"];

            GridViewRow  row            = subContractGV.Rows[index];
            DropDownList ddlReceipt     = row.FindControl("ddlReceipt") as DropDownList;
            float        receiptPercent = float.Parse(ddlReceipt.SelectedValue.ToString());

            int    subContractId     = int.Parse(dt.DefaultView[dataIndex].Row["subContractId"].ToString());
            string strMainContractId = dt.DefaultView[dataIndex].Row["mainContractId"].ToString();
            string strFilter         =
                " mainContractId = " + "'" + strMainContractId + "'";

            //subContractProcess scp = Session["subContractProcess"] as subContractProcess;

            //scp.SubContractReceiptPercentUpdate(subContractId, receiptPercent);


            //string strUsrId = Session["usrId"] as string;

            //int usrId = int.Parse(strUsrId);
            int    mainContractId = int.Parse(strMainContractId);
            string num            = receiptPercent.ToString("p");

            Xm_db xmDataCont = Xm_db.GetInstance();

            try
            {
                xmDataCont.SubContract_receiptPercent_update(subContractId, receiptPercent);

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

                reflash(mainContractId, xmDataCont);

                sendMail(mainContractId, xmDataCont, num);
            }
            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.SubContract_receiptPercent_update(subContractId, receiptPercent);

                xmDataCont.SubmitChanges();

                reflash(mainContractId, xmDataCont);

                sendMail(mainContractId, xmDataCont, num);
            }

            //xmDataCont.SubContract_receiptPercent_update(subContractId, receiptPercent);

            //var ViewsSubContract_supplier =
            //    from subContract_supplier in xmDataCont.View_subContract_supplier
            //    where subContract_supplier.MainContractId == mainContractId &&
            //          subContract_supplier.EndTime > DateTime.Now
            //    select subContract_supplier;

            //var emailDetail =
            //    from mainContract in xmDataCont.Tbl_mainContract
            //    join project in xmDataCont.Tbl_projectTagInfo on mainContract.ProjectTagId equals project.ProjectTagId
            //    join applyment_user in xmDataCont.Tbl_applyment_user on project.ProjectTagId equals applyment_user.ProjectTagId
            //    join user in xmDataCont.Tbl_usr on applyment_user.UsrId equals user.UsrId
            //    where mainContract.MainContractId == mainContractId
            //    select new { user.UsrEmail };

            //string usrEmail = emailDetail.First().UsrEmail;
            //string num = ViewsSubContract_supplier.First(elm => elm.SubContractId == subContractId).ReceiptPercent.ToString("p");

            //DataTable dtSources = projectStepEdit.Distinct().ToDataTable();

            //BeckSendMail.getMM().NewMail(usrEmail, "mis系统票务通知", "总共收到客户票款额" + num);

            //DataTable taskTable = ViewsSubContract_supplier.ToDataTable();

            //taskTable.DefaultView.RowFilter = strFilter;
            //scp.RealSubContractSupplierView();


            //DataTable taskTable = scp.MyDst.Tables["view_subContract_supplier"];
            //dt_modify(taskTable, strFilter);

            //Session["dtSources"] = taskTable;

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

            Button btn = null;

            btn         = sender as Button;
            btn.Visible = false;
            btn         = btnNo;
            btn.Visible = false;
            subContractGV.Columns[6].Visible = true;
            subContractGV.Columns[8].Visible = true;

            btnRtn.Visible = true;
        }