Пример #1
0
        public static int Update(PaymentEntity paymentEntity)
        {
            if (paymentEntity.PaymentDBEntity.Count == 0)
            {
                return 0;
            }

            if (paymentEntity.LogMessages == null)
            {
                return 0;
            }

            if (CheckUpdate(paymentEntity) > 0)
            {
                return 2;
            }

            List<CommandInfo> sqlList = new List<CommandInfo>();

            bool iflag = true;
            string PaymentID = "";
            foreach(PaymentDBEntity paymentDBEntity in paymentEntity.PaymentDBEntity)
            {
                if (iflag)
                {
                    PaymentEntity commonEntity = new PaymentEntity();
                    commonEntity.PaymentDBEntity = new List<PaymentDBEntity>();
                    PaymentDBEntity commonpaycodeDBEntity = new PaymentDBEntity();
                    commonpaycodeDBEntity.PaymentNo = paymentDBEntity.PaymentNo.ToString();
                    commonEntity.PaymentDBEntity.Add(commonpaycodeDBEntity);
                    DataSet dsResult = Select(commonEntity).QueryResult;
                    PaymentID = (dsResult.Tables.Count > 0 && dsResult.Tables[0].Rows.Count > 0) ? dsResult.Tables[0].Rows[0]["paymentcode"].ToString() : "";
                    iflag = false;
                }
                if (paymentDBEntity.UpdatType.Equals("1"))
                {
                    CommandInfo InsertCsMainPaymentInfo = new CommandInfo();
                    OracleParameter[] lmParm ={
                                    new OracleParameter("ID",OracleType.Number),
                                    new OracleParameter("PAYMENTNM",OracleType.VarChar)
                                };

                    lmParm[0].Value = int.Parse(paymentDBEntity.PaymentNo.ToString());
                    lmParm[1].Value = paymentDBEntity.Name_CN;

                    InsertCsMainPaymentInfo.SqlName = "Payment";
                    InsertCsMainPaymentInfo.SqlId = "t_lm_b_payment_update";
                    InsertCsMainPaymentInfo.Parameters = lmParm;
                    sqlList.Add(InsertCsMainPaymentInfo);
                }
                else
                {
                    CommandInfo InsertCsPaymentInfo = new CommandInfo();
                    OracleParameter[] csParm ={
                                    new OracleParameter("ID",OracleType.Number),
                                    new OracleParameter("PAYMENTID",OracleType.VarChar),
                                    new OracleParameter("PLATFORM_ID",OracleType.VarChar),
                                    new OracleParameter("ONLINESTATUS",OracleType.VarChar)
                                };

                    csParm[0].Value = (string.IsNullOrEmpty(paymentDBEntity.PaymentNo)) ? getMaxIDfromSeq("T_LM_B_PAYMENT_PLAT_SEQ") : int.Parse(paymentDBEntity.PaymentNo.ToString());
                    csParm[1].Value = PaymentID;
                    csParm[2].Value = paymentDBEntity.PaymFormID;
                    csParm[3].Value = paymentDBEntity.OnlineStatus;
                    InsertCsPaymentInfo.SqlName = "Payment";
                    InsertCsPaymentInfo.SqlId = "t_lm_b_payment_plat_update";
                    InsertCsPaymentInfo.Parameters = csParm;
                    sqlList.Add(InsertCsPaymentInfo);
                }
            }

            DbManager.ExecuteSqlTran(sqlList);

            //OracleParameter[] parm ={
            //                        new OracleParameter("ID",OracleType.Number),
            //                        new OracleParameter("ONLINESTATUS",OracleType.VarChar)

            //                    };

            //PaymentDBEntity dbParm = (paymentEntity.PaymentDBEntity.Count > 0) ? paymentEntity.PaymentDBEntity[0] : new PaymentDBEntity();

            //parm[0].Value = dbParm.PaymentID;
            //parm[1].Value = dbParm.OnlineStatus;
            //DbManager.ExecuteSql("Payment", "t_cs_payment_update", parm);
            //DataCommand cmd = DataCommandManager.GetDataCommand("UpdateCityList");
            //foreach (PaymentDBEntity dbParm in paymentEntity.PaymentDBEntity)
            //{
            //    cmd.SetParameterValue("@ChannelNo", dbParm.ChannelNo);
            //    cmd.SetParameterValue("@ChannelID", dbParm.ChannelID);
            //    cmd.SetParameterValue("@NameCN", dbParm.Name_CN);
            //    cmd.SetParameterValue("@NameEN", PinyinHelper.GetPinyin(dbParm.Name_CN));
            //    cmd.SetParameterValue("@OnlineStatus", dbParm.OnlineStatus);
            //    cmd.SetParameterValue("@Remark", dbParm.Remark);
            //    cmd.SetParameterValue("@UpdateUser", (paymentEntity.LogMessages != null) ? paymentEntity.LogMessages.Userid : "");
            //    cmd.ExecuteNonQuery();
            //}
            return 1;
        }
    ////清除控件中的数据
    //private void clearValue()
    //{
    //}
    ////发放渠道
    private void BindPaymentDetailListGrid(string PaymentID)
    {
        _paymentEntity.LogMessages = new HotelVp.Common.Logger.LogMessage();
        _paymentEntity.LogMessages.Userid = UserSession.Current.UserAccount;
        _paymentEntity.LogMessages.Username = UserSession.Current.UserDspName;
        _paymentEntity.LogMessages.IpAddress = UserSession.Current.UserIP;
        _paymentEntity.PaymentDBEntity = new List<PaymentDBEntity>();
        PaymentDBEntity paymentDBEntity = new PaymentDBEntity();

        paymentDBEntity.PaymentNo = PaymentID;

        //    //if (chkAll.Checked)
        //    //{
        //    //    paymentDBEntity.OnlineStatus = null;
        //    //}
        //    //else if (chkOnL.Checked && chkOff.Checked)
        //    //{
        //    //    paymentDBEntity.OnlineStatus = null;
        //    //}
        //    //else if (chkOff.Checked)
        //    //{
        //    //    paymentDBEntity.OnlineStatus = "0";
        //    //}
        //    //else if (chkOnL.Checked)
        //    //{
        //    //    paymentDBEntity.OnlineStatus = "1";
        //    //}
        //    //else
        //    //{
        //    //    paymentDBEntity.OnlineStatus = null;
        //    //}

        //    if (chkUnTime.Checked)
        //    {
        //        paymentDBEntity.StartDTime = null;
        //        paymentDBEntity.EndDTime = null;
        //    }
        //    else
        //    {
        //        paymentDBEntity.StartDTime = dpStart.Value;
        //        paymentDBEntity.EndDTime = dpEnd.Value;
        //    }

        _paymentEntity.PaymentDBEntity.Add(paymentDBEntity);

        DataSet dsResult = PaymentBP.PlatFormSelect(_paymentEntity).QueryResult;

        DataSet dsMainResult = PaymentBP.Select(_paymentEntity).QueryResult;
        if (dsMainResult.Tables.Count > 0 && dsMainResult.Tables[0].Rows.Count > 0)
        {
            txtPaymentName.Value = dsMainResult.Tables[0].Rows[0]["paymentnm"].ToString();
            txtPaymentID.Value = dsMainResult.Tables[0].Rows[0]["paymentcode"].ToString();
        }

        gridViewCSPaymentDetailList.DataSource = dsResult.Tables[0].DefaultView;
        gridViewCSPaymentDetailList.DataKeyNames = new string[] { "PLATMENTID" };//主键
        gridViewCSPaymentDetailList.DataBind();

        CheckBox chk;
        for (int i = 0; i <= gridViewCSPaymentDetailList.Rows.Count - 1; i++)
        {
            DataRowView drvtemp = dsResult.Tables[0].DefaultView[i];
            chk = (CheckBox)gridViewCSPaymentDetailList.Rows[i].FindControl("chkOnline");
            chk.Checked = (drvtemp["ONLINESTATUS"].ToString().Equals("1")) ? true : false;
        }
    }
    public void btnAddPayment()
    {
        messageContent.InnerHtml = "";

        if (String.IsNullOrEmpty(txtPaymentName.Value.ToString().Trim()) || String.IsNullOrEmpty(txtPaymentID.Value.ToString().Trim()))
        {
            messageContent.InnerHtml = GetLocalResourceObject("Error3").ToString();
            return;
        }

        _paymentEntity.LogMessages = new HotelVp.Common.Logger.LogMessage();
        _commonEntity.LogMessages = new HotelVp.Common.Logger.LogMessage();
        _paymentEntity.LogMessages.Userid = UserSession.Current.UserAccount;
        _paymentEntity.LogMessages.Username = UserSession.Current.UserDspName;
        _paymentEntity.LogMessages.IpAddress = UserSession.Current.UserIP;
        _paymentEntity.PaymentDBEntity = new List<PaymentDBEntity>();
        PaymentDBEntity paymentDBEntity = new PaymentDBEntity();
        paymentDBEntity.Name_CN = txtPaymentName.Value;
        paymentDBEntity.PaymentID = txtPaymentID.Value;
        _paymentEntity.PaymentDBEntity.Add(paymentDBEntity);
        int iResult = PaymentBP.Insert(_paymentEntity);

        _commonEntity.LogMessages = _paymentEntity.LogMessages;
        _commonEntity.CommonDBEntity = new List<CommonDBEntity>();
        CommonDBEntity commonDBEntity = new CommonDBEntity();

        commonDBEntity.Event_Type = "支付方式管理-添加";
        commonDBEntity.Event_ID = txtPaymentID.Value;

        string conTent = GetLocalResourceObject("EventInsertMessage").ToString();
        conTent = string.Format(conTent, txtPaymentID.Value, txtPaymentName.Value);
        commonDBEntity.Event_Content = conTent;

        if (iResult == 1)
        {
            commonDBEntity.Event_Result = GetLocalResourceObject("InsertSuccess").ToString();
            messageContent.InnerHtml = GetLocalResourceObject("InsertSuccess").ToString();
        }
        else if (iResult == 2)
        {
            commonDBEntity.Event_Result = GetLocalResourceObject("Error1").ToString();
            messageContent.InnerHtml = GetLocalResourceObject("Error1").ToString();
        }
        else
        {
            commonDBEntity.Event_Result = GetLocalResourceObject("Error2").ToString();
            messageContent.InnerHtml = GetLocalResourceObject("Error2").ToString();
        }

        _commonEntity.CommonDBEntity.Add(commonDBEntity);
        CommonBP.InsertEventHistory(_commonEntity);
    }
    protected void btnUpdate_Click(object sender, EventArgs e)
    {
        //((DropDownList)gridViewCSPaymentList.Rows[2].Cells[0].FindControl("ddlOnline")).SelectedValue

        detailMessageContent.InnerHtml = "";

        if (String.IsNullOrEmpty(txtPaymentName.Value.ToString().Trim()))
        {
            detailMessageContent.InnerHtml = GetLocalResourceObject("UpdateError1").ToString();
            return;
        }

        if (txtPaymentName.Value.ToString().Trim().Length > 32)
        {
            detailMessageContent.InnerHtml = GetLocalResourceObject("UpdateError3").ToString();
            return;
        }

        _paymentEntity.PaymentDBEntity = new List<PaymentDBEntity>();

        _paymentEntity.LogMessages = new HotelVp.Common.Logger.LogMessage();
        _commonEntity.LogMessages = new HotelVp.Common.Logger.LogMessage();
        _paymentEntity.LogMessages.Userid = UserSession.Current.UserAccount;
        _paymentEntity.LogMessages.Username = UserSession.Current.UserDspName;
        _paymentEntity.LogMessages.IpAddress = UserSession.Current.UserIP;
        _paymentEntity.PaymentDBEntity = new List<PaymentDBEntity>();

        PaymentDBEntity paymentMainDBEntity = new PaymentDBEntity();
        paymentMainDBEntity.PaymentNo = hidPaymentNo.Value;
        paymentMainDBEntity.Name_CN = txtPaymentName.Value;
        paymentMainDBEntity.UpdatType = "1";
        _paymentEntity.PaymentDBEntity.Add(paymentMainDBEntity);
        string strPayformIDS = "";
        for (int i = 0; i <= gridViewCSPaymentDetailList.Rows.Count - 1; i++)
        {
            PaymentDBEntity paymentDBEntity = new PaymentDBEntity();
            paymentDBEntity.PaymentNo = gridViewCSPaymentDetailList.Rows[i].Cells[0].Text;
            paymentDBEntity.Name_CN = txtPaymentName.Value;
            paymentDBEntity.PaymentID = gridViewCSPaymentDetailList.Rows[i].Cells[2].Text;// gridViewCSPaymentDetailList.DataKeys[i].Value.ToString(); //hidPaymentNo.Value;
            paymentDBEntity.PaymFormID = gridViewCSPaymentDetailList.DataKeys[i].Value.ToString();
            paymentDBEntity.OnlineStatus = (((CheckBox)gridViewCSPaymentDetailList.Rows[i].Cells[7].FindControl("chkOnline")).Checked) ? "1" : "0";
            paymentDBEntity.UpdatType = "0";

            strPayformIDS = strPayformIDS + paymentDBEntity.PaymFormID + "("+ (paymentDBEntity.OnlineStatus.Equals("1") ? "上线" : "下线") +") ";

            _paymentEntity.PaymentDBEntity.Add(paymentDBEntity);
        }

        int iResult = PaymentBP.Update(_paymentEntity);
        _commonEntity.LogMessages = _paymentEntity.LogMessages;
        _commonEntity.CommonDBEntity = new List<CommonDBEntity>();
        CommonDBEntity commonDBEntity = new CommonDBEntity();

        //detailMessageContent.InnerHtml = "支付方式更新成功!";
        string conTent = "";
        conTent = GetLocalResourceObject("EventInsertMessage").ToString();
        conTent = string.Format(conTent, hidPaymentNo.Value, txtPaymentName.Value, strPayformIDS);
        commonDBEntity.Event_Type = "支付方式管理-更新";
        commonDBEntity.Event_ID = hidPaymentNo.Value;
        commonDBEntity.Event_Content = conTent;

        if (iResult == 1)
        {
            Response.Write("<script>window.returnValue=true;window.opener = null;window.close();</script>");
            commonDBEntity.Event_Result = GetLocalResourceObject("UpdateSuccess").ToString();
        }
        else if (iResult == 2)
        {
            detailMessageContent.InnerHtml = GetLocalResourceObject("UpdateError2").ToString();
            commonDBEntity.Event_Result = GetLocalResourceObject("UpdateError2").ToString();
        }
        else
        {
            detailMessageContent.InnerHtml = GetLocalResourceObject("UpdateError").ToString();
            commonDBEntity.Event_Result = GetLocalResourceObject("UpdateError").ToString();
        }

        //Response.Write("<script>window.returnValue=false;window.opener='anyone';window.close();</script>");

        //string conTent = GetLocalResourceObject("EventUpdateMessage").ToString();
        //conTent = string.Format(conTent, paymentDBEntity.PaymentID, paymentDBEntity.Name_CN, paymentDBEntity.OnlineStatus);
        //commonDBEntity.Event_Content = conTent;

        //if (iResult == 1)
        //{
        //    commonDBEntity.Event_Result = GetLocalResourceObject("UpdateSuccess").ToString();
        //    messageContent.InnerHtml = GetLocalResourceObject("UpdateSuccess").ToString();
        //}
        //else
        //{
        //    commonDBEntity.Event_Result = GetLocalResourceObject("UpdateError").ToString();
        //    messageContent.InnerHtml = GetLocalResourceObject("UpdateError").ToString();
        //}

        _commonEntity.CommonDBEntity.Add(commonDBEntity);
        CommonBP.InsertEventHistory(_commonEntity);

        //messageContent.InnerHtml = "渠道添加失败!";
    }
    //发放渠道
    public void BindPaymentListGrid()
    {
        //messageContent.InnerHtml = "";
        _paymentEntity.LogMessages = new HotelVp.Common.Logger.LogMessage();
        _paymentEntity.LogMessages.Userid = UserSession.Current.UserAccount;
        _paymentEntity.LogMessages.Username = UserSession.Current.UserDspName;
        _paymentEntity.LogMessages.IpAddress = UserSession.Current.UserIP;
        _paymentEntity.PaymentDBEntity = new List<PaymentDBEntity>();
        PaymentDBEntity paymentDBEntity = new PaymentDBEntity();

        paymentDBEntity.Name_CN = (ViewState.Count == 0 || String.IsNullOrEmpty(ViewState["Name_CN"].ToString())) ? null : ViewState["Name_CN"].ToString();
        paymentDBEntity.StartDTime = (ViewState.Count == 0 || String.IsNullOrEmpty(ViewState["StartDTime"].ToString())) ? null : ViewState["StartDTime"].ToString();
        paymentDBEntity.EndDTime = (ViewState.Count == 0 || String.IsNullOrEmpty(ViewState["EndDTime"].ToString())) ? null : ViewState["EndDTime"].ToString();

        //paymentDBEntity.Name_CN = txtSelPaymentName.Value;

        ////if (chkAll.Checked)
        ////{
        ////    paymentDBEntity.OnlineStatus = null;
        ////}
        ////else if (chkOnL.Checked && chkOff.Checked)
        ////{
        ////    paymentDBEntity.OnlineStatus = null;
        ////}
        ////else if (chkOff.Checked)
        ////{
        ////    paymentDBEntity.OnlineStatus = "0";
        ////}
        ////else if (chkOnL.Checked)
        ////{
        ////    paymentDBEntity.OnlineStatus = "1";
        ////}
        ////else
        ////{
        ////    paymentDBEntity.OnlineStatus = null;
        ////}

        //if (chkUnTime.Checked)
        //{
        //    paymentDBEntity.StartDTime = null;
        //    paymentDBEntity.EndDTime = null;
        //}
        //else
        //{
        //    paymentDBEntity.StartDTime = dpStart.Value;
        //    paymentDBEntity.EndDTime = dpEnd.Value;
        //}

        _paymentEntity.PaymentDBEntity.Add(paymentDBEntity);

        DataSet dsResult = PaymentBP.Select(_paymentEntity).QueryResult;

        gridViewCSPaymentList.DataSource = dsResult.Tables[0].DefaultView;
        gridViewCSPaymentList.DataKeyNames = new string[] { "PAYMENTID" };//主键
        gridViewCSPaymentList.DataBind();

        //DropDownList ddl;
        //for (int i = 0; i <= gridViewCSPaymentList.Rows.Count - 1; i++)
        //{
        //    DataRowView drvtemp = dsResult.Tables[0].DefaultView[i];
        //    ddl = (DropDownList)gridViewCSPaymentList.Rows[i].FindControl("ddlOnline");
        //    ddl.SelectedValue = drvtemp["ONLINESTATUS"].ToString();
        //}

        if (!String.IsNullOrEmpty(refushFlag.Value))
        {
            messageContent.InnerHtml = GetLocalResourceObject("UpdateSuccess").ToString();
            refushFlag.Value = "";
        }
    }