protected void lnkbtnEdit_Click(object sender, EventArgs e)
    {
        string strKey = this.gdvList.DataKeys[Convert.ToInt32(this.hdKey.Value)].Value.ToString();
        try
        {
            string strRandom = CommonMethod.getRandom(4);
            //更改随机码并下发
            ControlBindHelper.ChangeRandom("TT_CarInfo", "CarCode", strKey);

            //插入二次打印日志
            string strSql = "insert TT_TwoPrintLog(LogID,Operator,PrintDate,PrintTable,PrintWeightCode,LogType)"
                        + " Values('" +Guid.NewGuid().ToString().Replace("-", "") + "','"
                        + CookieManager.GetCookieValue("UserName") + "',getdate(),'TT_CarInfo','" + strKey + "','车辆信息登记')";
            if (DbHelperSQL.ExecuteSql(strSql)>0)
            {
                MsmqManage msm = new MsmqManage();
                string strMq = msm.AllStation + msm.Prefix + "TT_TwoPrintLog" + msm.Prefix + msm.AddFlg + msm.Prefix + DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss") + msm.Prefix + strSql;
                msm.AddMsmq(strMq);
            }
        }
        catch
        { }
        string strTitle = ConfigurationManager.AppSettings["Customer"] + "";
        ScriptManager.RegisterStartupScript(this.UpdatePanel1, Page.GetType(), "", "Print('" + strKey + "','"+strTitle+"');", true);
    }
    protected void btnSave_Click(object sender, ImageClickEventArgs e)
    {
        string strMsg = "";
        if (this.ddlCoalKind.SelectedValue == "")
            strMsg += "请选择煤种!\\r\\n";
        if (this.ddlColl.SelectedValue == "")
            strMsg += "请选择煤矿!\\r\\n";
        if (strMsg != "")
        {
            MessageBox.Show(this.UpdatePanel1, this, strMsg);
            return;
        }

        string strSql = "Update TT_MarkedCard Set CollCode='" + this.ddlColl.SelectedValue + "',CoalKindCode='" + this.ddlCoalKind.SelectedValue + "' where MarkedCardCode in(" + hdKeys.Value + ")";
        if (DbHelperSQL.ExecuteSql(strSql) > 0)
        {
            #region 数据同步
            MsmqManage mq = new MsmqManage();
            string strMq = mq.AllStation + mq.Prefix + "TT_MarkedCard" + mq.Prefix + mq.EditFlg + mq.Prefix + DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss") + mq.Prefix + strSql.ToString();
            mq.AddMsmq(strMq.ToString());
            #endregion

            Sys_OperateLog.Add("修改标识卡记录",CookieManager.GetCookieValue("UserName"), "TT_MarkedCard", this.txtRemark.Text.Trim(), this.lblMarkedCard.Text);
            ScriptManager.RegisterStartupScript(this.UpdatePanel1, Page.GetType(), "", "alert('标识卡修改成功!');this.top.currForm.close();", true);
        }
        else
            MessageBox.Show(this.UpdatePanel1, this, "标识卡修改失败!");
    }
 public static int ChangeRandom(string strTable,string strField,string strKey)
 {
     string strRandom = CommonMethod.getRandom(4);
     //��������벢�·�
     string strSql = "Update " + strTable + " Set RandomCode='" + strRandom + "' where " + strField + "='" + strKey + "'";
     int i=DbHelperSQL.ExecuteSql(strSql);
     if ( i> 0)
     {
         MsmqManage msm = new MsmqManage();
         string strMq = msm.AllStation + msm.Prefix + strTable + msm.Prefix + msm.EditFlg + msm.Prefix + DateTime.Now.ToString("yyyy-MM-dd hh:mm;ss") + msm.Prefix + strSql;
         msm.AddMsmq(strMq);
     }
     return i;
 }
    protected void btnSave_Click(object sender, ImageClickEventArgs e)
    {
        string strMsg = "";
        if (Convert.ToDecimal(this.txtMoney.Text.Trim()) == 0)
            strMsg += "转账金额不能为零!\\r\\n";
        else if(Convert.ToDecimal(this.txtMoney.Text.Trim()) > dAccount)
            strMsg += "转账金额大于转出煤矿的余额!\\r\\n";
        if (this.txtToCollCode.Text.Trim() == this.txtFromCollCode.Text.Trim())
            strMsg += "转出煤矿跟转入煤矿不能是同一个煤矿!\\r\\n";
        if (strMsg != "")
        {
            MessageBox.Show(this.up, this, strMsg);
            return;
        }
        SqlParameter[] parameters = {
                    new SqlParameter("@FromCollCode", SqlDbType.VarChar,10),
                    new SqlParameter("@ToCollCode", SqlDbType.VarChar,10),
                    new SqlParameter("@TransferMoney", SqlDbType.Decimal),
                    new SqlParameter("@Operator", SqlDbType.VarChar,10),
                    new SqlParameter("@OperateTime", SqlDbType.DateTime)};

        parameters[0].Value = this.txtFromCollCode.Text.Trim();
        parameters[1].Value = this.txtToCollCode.Text.Trim(); ;
        parameters[2].Value = this.txtMoney.Text.Trim();
        parameters[3].Value = CookieManager.GetCookieValue("UserName");
        parameters[4].Value =  DateTime.Now;

        DataTable dt = DbHelperSQL.TRunProcedure("PT_TransferAccounts", parameters);
        if (dt == null)
            MessageBox.Show(this.up, this, "添加失败!");
        else
        {
            string strSql = "Update TT_ColieryAccount Set Account=isnull(Account,0)+" + this.txtMoney.Text.Trim() + " where CollCode='" + this.txtToCollCode.Text.Trim() + "';"
                            + "Update TT_ColieryAccount Set Account=isnull(Account,0)-"+this.txtMoney.Text.Trim()+" where CollCode='" + this.txtFromCollCode.Text.Trim() + "'";
            TDTK.IndustryPlatform.CoalTraffic.DBUtility.MsmqManage mq = new TDTK.IndustryPlatform.CoalTraffic.DBUtility.MsmqManage();
            string strMq = mq.AllStation + mq.Prefix + "TT_WaterBook" + mq.Prefix + mq.AddFlg + mq.Prefix + DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss") + mq.Prefix + strSql.ToString();
            mq.AddMsmq(strMq);
            ClearText();
            string strTransferID = dt.Rows[0][0].ToString();
            string strTitle = ConfigurationManager.AppSettings["Customer"] + "煤矿转账凭证";
            ScriptManager.RegisterStartupScript(this.up, Page.GetType(), "", "Print('" + strTransferID + "','" + strTitle + "')", true);
        }
    }
 protected void lnkbtnForbid_Click(object sender, EventArgs e)
 {
     string strKeys = this.gdvList.DataKeys[Convert.ToInt32(this.hdKey.Value)].Value.ToString();
     try
     {
         string strSql = "insert TT_TwoPrintLog(LogID,Operator,PrintDate,PrintTable,PrintWeightCode,LogType)"
                         + " Values('" + Guid.NewGuid().ToString().Replace("-", "") + "','"
                         + CookieManager.GetCookieValue("UserName") + "',getdate(),'TT_Navicert','" + strKeys + "','准运卡打印')";
         if (DbHelperSQL.ExecuteSql(strSql) > 0)
         {
             MsmqManage msm = new MsmqManage();
             string strMq = msm.AllStation + msm.Prefix + "TT_TwoPrintLog" + msm.Prefix + msm.AddFlg + msm.Prefix + DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss") + msm.Prefix + strSql;
             msm.AddMsmq(strMq);
         }
     }
     catch
     { }
     string strTitle = ConfigurationManager.AppSettings["Customer"] + "";
     string strJs = "Print('" + strKeys + "','" + strTitle + "');";
     ScriptManager.RegisterStartupScript(this.UpdatePanel1, this.GetType(), "", strJs, true);
 }
    protected void lnkbtnPrint_Click(object sender, EventArgs e)
    {
        string strKey = this.gdv_OutLoadWeight.DataKeys[Convert.ToInt32(this.hdKey.Value)].Value.ToString();
        string strTrafficCode = this.gdv_OutLoadWeight.Rows[Convert.ToInt32(this.hdKey.Value)].Cells[2].Text;
        string strLogType = "过境煤过磅";
        if (strTrafficCode == strKey)
        {
            this.hdIsFirst.Value = "1";
            //strLogType = "过境煤过磅";
        }
        else
        {
            this.hdIsFirst.Value = "0";
            //strLogType = "过境煤验票";
        }

        try
        {
            //更改随机码并下发
            ControlBindHelper.ChangeRandom("TT_OutLoadWeight", "OutWeightCode", strKey);
            //添加打印日志并下发
            string strSql = "insert TT_TwoPrintLog(LogID,Operator,PrintDate,PrintTable,PrintWeightCode,LogType)"
                        + " Values('" + Guid.NewGuid().ToString().Replace("-", "") + "','"
                        + CookieManager.GetCookieValue("UserName") + "',getdate(),'TT_OutLoadWeight','" + strKey + "','" + strLogType + "')";
            if (DbHelperSQL.ExecuteSql(strSql) > 0)
            {
                MsmqManage msm = new MsmqManage();
                string strMq = msm.AllStation + msm.Prefix + "TT_TwoPrintLog" + msm.Prefix + msm.AddFlg + msm.Prefix + DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss") + msm.Prefix + strSql;
                msm.AddMsmq(strMq);
            }
        }
        catch
        { }
        string strTitle = ConfigurationManager.AppSettings["Customer"] + "煤炭管理过境煤过磅放行单";
        ScriptManager.RegisterStartupScript(this.UpdatePanel1, Page.GetType(), "", "Print('" + strKey + "','" + strTitle + "');", true);
    }
    protected void btn_Save_Click(object sender, ImageClickEventArgs e)
    {
        if (Request.QueryString["strCoalKindCode"] == null)
        {
            model.IsForbid = "0";
            if (bll.ExistsCoalKindName(this.txtCoalKindName.Text.Trim(), ""))
            {
                MessageBox.Show(this.upDepartAdd, this, "您输入的煤种名称已经存在,请重新输入");
                return;
            }
        }
        else
        {
            model = bll.GetModel(Request.QueryString["strCoalKindCode"].ToString());
            if (bll.ExistsCoalKindName(this.txtCoalKindName.Text.Trim(), Request.QueryString["strCoalKindCode"].ToString()))
            {
                MessageBox.Show(this.upDepartAdd, this, "您输入的煤种名称已经存在,请重新输入");
                return;
            }
        }
        //绑定数据
        model.CoalKindName = txtCoalKindName.Text.Trim();
        if (txtProportion.Text.Trim() == "")
            txtProportion.Text = "0";
        model.Proportion = Convert.ToDecimal(txtProportion.Text.Trim().Replace(" ",""));
        model.TypeCode = ddlInOut.SelectedValue;
        model.Remark = txtRemark.Text.Trim();
        model.TaxPercent = Convert.ToDecimal(txtTaxPercent.Text.Trim().Replace(" ", ""));
        TDTK.IndustryPlatform.CoalTraffic.DBUtility.MsmqManage msm = new TDTK.IndustryPlatform.CoalTraffic.DBUtility.MsmqManage();

        //执行语句
        if (Request.QueryString["strCoalKindCode"] != null)
        {
            if (bll.Update(model) == 1) //修改成功不用提示,直接关闭
            {
                #region 数据同步
                StringBuilder strSql = new StringBuilder();
                strSql.Append("update TT_CoalKind set ");
                strSql.Append("CoalKindName='"+model.CoalKindName+"',");
                strSql.Append("Proportion='"+model.Proportion+"',");
                strSql.Append("TypeCode='" + model.TypeCode + "',");
                strSql.Append("Remark='"+model.Remark+"',");
                strSql.Append("TaxPercent='"+model.TaxPercent+"',");
                strSql.Append("IsForbid='"+model.IsForbid+"'");
                strSql.Append(" where CoalKindCode='"+model.CoalKindCode+"' ");

                string strMq = msm.AllStation + msm.Prefix + "TT_CoalKind" + msm.Prefix + msm.EditFlg + msm.Prefix + DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss") + msm.Prefix + strSql.ToString();
                msm.AddMsmq(strMq);
                #endregion

                ScriptManager.RegisterStartupScript(this, this.GetType(), "myscript", "top.currForm.close();", true);
            }
            else
            {
                ScriptManager.RegisterStartupScript(this, this.GetType(), "myscript", "alert('修改失败!');", true);
            }
        }
        else//新增保存
        {
            lock (this)
            {
                string strSQL = "Select Max(CoalKindCode) From TT_CoalKind Where CoalKindCode Like '" + ddlInOut.SelectedValue + "%'";
                string strCode = ddlInOut.SelectedValue + "001";
                object objID= DbHelperSQL.GetSingle(strSQL);
                if (objID != null)
                {
                    strCode = (Convert.ToInt32(objID)+1).ToString();
                }
                model.CoalKindCode = strCode;
               // model.CoalKindCode = DbHelperSQL.GetBaseMaxID("CoalKindCode", "TT_CoalKind");
                if (bll.Add(model) == 1)
                {
                    ShowInfo();
                    #region 数据同步
                    //添加成功,数据同步到各个磅房
                    string strSql = "insert into TT_CoalKind(CoalKindCode,CoalKindName,Proportion,TypeCode,Remark,IsForbid,TaxPercent)"
                            + "Values('" + model.CoalKindCode + "','" + model.CoalKindName + "','" + model.Proportion + "','" + model.TypeCode + "','" + model.Remark + "','" + model.IsForbid + "','"+model.TaxPercent+"')";
                    string strMq = msm.AllStation + msm.Prefix + "TT_CoalKind" + msm.Prefix + msm.AddFlg + msm.Prefix + DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss") + msm.Prefix + strSql.ToString();
                    msm.AddMsmq(strMq);
                    #endregion
                }
                else
                {
                    ScriptManager.RegisterStartupScript(this, this.GetType(), "myscript", "alert('添加失败!');", true);
                }
            }
        }
    }
    protected void btnSave_Click(object sender, ImageClickEventArgs e)
    {
        string strMsg = "";
        if (this.txtEmptyCode.Text.Trim() == "")
            strMsg += "请输入或选择车辆编号!\\r\\n";
        if (this.txtNavicertCode.Text.Trim() == "")
            strMsg += "请输入准运卡号!";
        else
        {
            if (DbHelperSQL.Exists("Select Count(0) from TT_MarkedCard where MarkedCardCode='" + this.txtNavicertCode.Text.Trim().Replace("'", "''") + "'"))
                strMsg += "您输入的卡号在标识卡中已经使用";
        }
        if (strMsg != "")
        {
            MessageBox.Show(this, strMsg);
            return;
        }

        SqlParameter[] parameters =
        {
            new SqlParameter("@CarNo", SqlDbType.NVarChar,20),
            new SqlParameter("@NavicertCode", SqlDbType.VarChar,20)
        };
        parameters[0].Value = txtCarNo.Text.Trim();
        parameters[1].Value = txtNavicertCode.Text.Trim();
        DataTable dt = DbHelperSQL.TRunProcedure("PT_NavicertCardJudge", parameters);

        if (dt.Rows.Count > 0)
        {
            string strNavicertJudge = dt.Rows[0]["ReturnValue"].ToString();
                try
                {
                    TDTK.IndustryPlatform.CoalTraffic.Model.TT_CarInfo modelCarInfo = new TDTK.IndustryPlatform.CoalTraffic.BLL.TT_CarInfo().GetModel(txtEmptyCode.Text.Trim().Replace("'", "''"));
                    #region 禁用准运卡表里该条记录
                    bool Success = false;
                    TDTK.IndustryPlatform.CoalTraffic.Model.TT_Navicert model = new TDTK.IndustryPlatform.CoalTraffic.Model.TT_Navicert();
                    string strSql = "Select NavicertCode from TT_Navicert where CarNo='" + modelCarInfo.CarNo.Replace("'", "''") + "' and NavicertState='1'";
                    string strID = DbHelperSQL.GetSingle(strSql).ToString();
                    model = bllNavic.GetModel(strID);
                    model.IsForbid = "1";
                    model.Remark = "因补办被禁用";
                    Success = bllNavic.Update(model);
                    #region 数据同步到各磅房
                    if (Success)
                    {
                        StringBuilder strUpdate = new StringBuilder();
                        strUpdate.Append("update TT_Navicert set RoomCode='" + model.RoomCode + "',CarCode='" + model.CarCode + "',");
                        strUpdate.Append("CarNo='" + model.CarNo + "',CarType='" + model.CarType + "',");
                        strUpdate.Append("CarOwnerName='" + model.CarOwnerName + "',NavicertState='" + model.NavicertState + "',");
                        strUpdate.Append("CardType='" + model.CardType + "',StartTime='" + model.StartTime + "',");
                        strUpdate.Append("EndTime='" + model.EndTime + "',SendPerson='" + model.SendPerson + "',");
                        strUpdate.Append("ClaimPersonName='" + model.ClaimPersonName + "',CarOwnerPhone='" + model.CarOwnerPhone + "',");
                        strUpdate.Append("CarOwnerIDCard='" + model.CarOwnerIDCard + "',MostWeight='" + model.MostWeight + "',");
                        strUpdate.Append("EmptyWeight='" + model.EmptyWeight + "',IsForbid='" + model.IsForbid + "',");
                        strUpdate.Append("Remark='" + model.Remark + "' where NavicertNo='" + model.NavicertCode + "';");
                        if (model.RemoteCardCode != "")
                            strUpdate.Append("Update TT_CarInfo Set RemoteCardCode='" + model.RemoteCardCode + "' where CarCode='" + tt_navic.CarCode + "'");
                        MsmqManage mq = new MsmqManage();
                        string strMq = mq.AllStation + mq.Prefix + "TT_Navicert" + mq.Prefix + mq.EditFlg + mq.Prefix + DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss") + mq.Prefix + strUpdate.ToString();
                        mq.AddMsmq(strMq.ToString());
                    }
                    #endregion
                    #endregion
                    decimal dDiff = Convert.ToDecimal(DbHelperSQL.GetSingle("Select BusinName from Sys_Dictionary where BusinID='2' and BusinTypeID='1017'"));
                    tt_navic.NavicertCode = this.txtNavicertCode.Text.Trim();
                    tt_navic.NavicertNo = (Convert.ToDecimal(tt_navic.NavicertCode) + dDiff).ToString();
                    tt_navic.ClaimPersonName = this.txtClaimPersonName.Text.Trim();
                    tt_navic.CarCode = txtEmptyCode.Text.Trim();
                    tt_navic.Remark = txtRemark.Text.Trim() + "原准运卡号:" + model.NavicertCode;
                    tt_navic.CarNo = modelCarInfo.CarNo;
                    tt_navic.CarType = modelCarInfo.CarType;
                    tt_navic.EmptyWeight = modelCarInfo.EmptyWeight;
                    tt_navic.MostWeight = modelCarInfo.MostWeight;
                    tt_navic.RoomCode = "0";
                    tt_navic.CarOwnerIDCard = modelCarInfo.CarOwnerIDCard;
                    tt_navic.CarOwnerName = modelCarInfo.CarOwnerName;
                    tt_navic.CarOwnerPhone = modelCarInfo.CarOwnerPhone;
                    tt_navic.StartTime = DateTime.Now;
                    tt_navic.EndTime = DateTime.MaxValue;
                    tt_navic.NavicertState = "1";
                    tt_navic.CardType = "1";
                    tt_navic.SendPerson = "";// CookieManager.GetCookieValue("UserName");
                    tt_navic.IsForbid = "0";
                    tt_navic.RemoteCardCode = "";
                    bool bolSuccess = false;
                    #region 插入一条新信息
                    bolSuccess = bllNavic.Add(tt_navic);
                    #region 数据同步到各磅房
                    if (bolSuccess)
                    {
                        StringBuilder sbInsert = new StringBuilder();
                        sbInsert.Append("insert into TT_Navicert(NavicertCode,RoomCode,CarCode,CarNo,CarType,CarOwnerName,NavicertState,");
                        sbInsert.Append("CardType,StartTime,EndTime,SendPerson,ClaimPersonName,CarOwnerPhone,CarOwnerIDCard,MostWeight,");
                        sbInsert.Append("EmptyWeight,IsForbid,Remark,NavicertNo) values ('" + tt_navic.NavicertCode + "','" + tt_navic.RoomCode + "',");
                        sbInsert.Append("'" + tt_navic.CarCode + "','" + tt_navic.CarNo + "','" + tt_navic.CarType + "','" + tt_navic.CarOwnerName + "',");
                        sbInsert.Append("'" + tt_navic.NavicertState + "','" + tt_navic.CardType + "','" + tt_navic.StartTime + "','" + tt_navic.EndTime + "',");
                        sbInsert.Append("'" + tt_navic.SendPerson + "','" + tt_navic.ClaimPersonName + "','" + tt_navic.CarOwnerPhone + "',");
                        sbInsert.Append("'" + tt_navic.CarOwnerIDCard + "','" + tt_navic.MostWeight + "','" + tt_navic.EmptyWeight + "',");
                        sbInsert.Append("'" + tt_navic.IsForbid + "','" + tt_navic.Remark + "','" + tt_navic.NavicertNo + "');");
                        if (tt_navic.RemoteCardCode != "")
                            sbInsert.Append("Update TT_CarInfo Set RemoteCardCode='" + tt_navic.RemoteCardCode + "' where CarCode='" + tt_navic.CarCode + "'");
                        MsmqManage mq = new MsmqManage();
                        string strMq = mq.AllStation + mq.Prefix + "TT_Navicert" + mq.Prefix + mq.AddFlg + mq.Prefix + DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss") + mq.Prefix + sbInsert.ToString();
                        mq.AddMsmq(strMq.ToString());
                    }
                    #endregion
                    #endregion
                    if (bolSuccess && Success)
                    {
                        ClearText();
                        string strTitle = ConfigurationManager.AppSettings["Customer"] + "";
                        string strJs = "Print('" + tt_navic.NavicertCode + "','" + strTitle + "');";
                        ClientScript.RegisterStartupScript(this.GetType(), "", strJs, true);
                    }
                    else
                    {
                        MessageBox.Show(this, "准运卡办理失败");
                    }

                }
                catch (Exception ex)
                {
                    MessageBox.Show(this, ex.ToString());
                }

        }
    }
    protected void btnSave_Click(object sender, ImageClickEventArgs e)
    {
        string strMsg = "";
        if (this.ddlColl.SelectedValue == "")
            strMsg += "请选择您要充值的煤矿!\\r\\n";
        if (this.txtACCOUNTEXCHANGE.Text.Trim() == "")
            strMsg += "请输入充值金额!";
        if (strMsg != "")
        {
            MessageBox.Show(this, strMsg);
            return;
        }

        TDTK.IndustryPlatform.CoalTraffic.Model.TT_WaterBook model = new TDTK.IndustryPlatform.CoalTraffic.Model.TT_WaterBook();
        lock (this)
        {
            model.CollCode = this.ddlColl.SelectedValue;
            model.Operator = CookieManager.GetCookieValue("UserName");
            model.TradeKind = this.rblTradeKind.SelectedItem.Text;
            model.Remark = this.txtRemark.Text.Trim();
            model.TradeDate = DateTime.Now;
            model.WeightCode = "";
            model.TradeCode = DbHelperSQL.GetSingle("Select IsNull(Max(TradeCode)+1,1000000001) From TT_WaterBook").ToString();
            model.JournalCode = Convert.ToInt32(DbHelperSQL.GetSingle("Select IsNull(Max(JournalCode)+1,1) From TT_WaterBook Where CollCode=" + model.CollCode + " And JournalCode Is Not Null"));
            decimal dStartMoney = Convert.ToDecimal(DbHelperSQL.GetSingle("Select IsNull(Account,0) from TT_ColieryAccount where CollCode='" + model.CollCode + "'"));
            model.StartMoney = dStartMoney;

            if (this.rblTradeKind.SelectedValue == "1")
                model.TradeMoney = Convert.ToDecimal(this.txtACCOUNTEXCHANGE.Text.Trim());
            else
                model.TradeMoney = -Convert.ToDecimal(this.txtACCOUNTEXCHANGE.Text.Trim());
            model.EndMoney = dStartMoney + model.TradeMoney;

            string strTradeCode = bll.Add(model);
            if (strTradeCode != "")
            {
                #region 数据同步
                TDTK.IndustryPlatform.CoalTraffic.DBUtility.MsmqManage mq = new TDTK.IndustryPlatform.CoalTraffic.DBUtility.MsmqManage();

                StringBuilder strSql=new StringBuilder();

                if (ExistsCollAcount(model.CollCode))
                    strSql.Append("Update TT_ColieryAccount set Account=isnull(Account,0)+" + model.TradeMoney + " where CollCode=" + model.CollCode);
                else
                    strSql.Append("Insert TT_ColieryAccount(CollCode,Account) Values(" + model.CollCode + "," + model.TradeMoney + ")");
                string strMq = mq.AllStation + mq.Prefix + "TT_WaterBook" + mq.Prefix + mq.AddFlg + mq.Prefix + DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss") + mq.Prefix + strSql.ToString();
                mq.AddMsmq(strMq.ToString());
                #endregion

                string strTitle = System.Configuration.ConfigurationManager.AppSettings["Customer"] + "煤矿账户平衡凭证";
                this.ClientScript.RegisterStartupScript(Page.GetType(), "", "PrintFrom('" + strTradeCode + "','"+strTitle+"');", true);
                ClearText();
            }
            else
                MessageBox.Show(this, "充值失败!");
        }
    }
    //禁用煤种
    protected void lkForbid_Click(object sender, EventArgs e)
    {
        string strselect = GetSelect("1");
        if ("" != strselect)
        {
            ////判断标识卡中是否已使用了该煤种,如果已使用,则不可禁用。
            string strsql = "Select distinct(CollName) from VT_CollRunCoalKind where CoalKindCode in(" + strselect + ")";
            DataTable dtColl = DbHelperSQL.TQuery(strsql);
            if (dtColl.Rows.Count > 0)
            {
                string strColl="";
                foreach (DataRow dr in dtColl.Rows)
                {
                    strColl += dr[0] + ",";
                }
                strColl = strColl.Remove(strColl.Length - 1);
                MessageBox.Show(this.UpdatePanel1, this, strColl + "\\r\\n还经营您选中的煤种,不能禁用");
                return;
            }

            if (Coalkind.Forbid(strselect,"1") == 1)
            {
                #region 同步数据
                TDTK.IndustryPlatform.CoalTraffic.DBUtility.MsmqManage msm = new MsmqManage();
                string strSql = "Update TT_CoalKind set IsForbid='1' where CoalKindCode in (" + strselect + ")";
                strSql = msm.AllStation + msm.Prefix + "TT_CoalKind" + msm.Prefix + msm.DelFlg + msm.Prefix + DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss") + msm.Prefix + strSql;
                msm.AddMsmq(strSql);
                #endregion
                DBind();
                ScriptManager.RegisterStartupScript(this, Page.GetType(), "", "alert('禁用成功!');", true);
            }
            else
            {
                ScriptManager.RegisterStartupScript(this, Page.GetType(), "", "alert('禁用失败!');", true);
            }
        }
        else
        {
            ScriptManager.RegisterStartupScript(this, this.GetType(), "myscript", "alert('您选择的记录已经是禁用状态!');", true);
        }
    }
    //启用煤种
    protected void LkEmbargoor_Click(object sender, EventArgs e)
    {
        string strselect = GetSelect("0");
        if ("" != strselect)
        {

            if (Coalkind.Forbid(strselect,"0") == 1)
            {
                #region 同步数据

                TDTK.IndustryPlatform.CoalTraffic.DBUtility.MsmqManage msm = new MsmqManage();
                //添加成功,数据同步到各个磅房
                string strSql = "Update TT_CoalKind set IsForbid='0' where CoalKindCode in (" + strselect + ")";
                strSql = msm.AllStation + msm.Prefix + "TT_CoalKind" + msm.Prefix + msm.DelFlg + msm.Prefix + DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss") + msm.Prefix + strSql;
                msm.AddMsmq(strSql);

                #endregion

                DBind();
                ScriptManager.RegisterStartupScript(this, Page.GetType(), "", "alert('启用成功!');", true);

            }
            else
            {
                ScriptManager.RegisterStartupScript(this, Page.GetType(), "", "alert('启用失败!');", true);
            }
        }
        else
        {
            ScriptManager.RegisterStartupScript(this, this.GetType(), "myscript", "alert('您选中的煤种已是启用状态!');", true);
        }
    }
    protected void btnSave_Click(object sender, ImageClickEventArgs e)
    {
        string strMsg="";
        if (this.txbAmount.Text == "0")
            strMsg += "发卡数据不能为0!\\r\\n";
        if (this.ddlColl.SelectedValue == "")
            strMsg += "请选择煤矿\\r\\n";
        if (this.Items.Count == 0)
            strMsg += "请选择煤种\\r\\n";
        else if (this.ddlCoalKind.SelectedValue == "")
            strMsg += "请选择煤种\\r\\n";
        if (this.rbType.SelectedValue == "1")
        {
            if (this.txbMarkedCard.Text.Trim() == "")
                strMsg += "请输入卡号\\r\\n";
        }

        if (this.rbType.SelectedValue == "2")
        {
            if (this.txbMarkedCardBegin.Text.Trim() == "")
                strMsg += "请输入标识卡起始卡号!\\r\\n";
            if (this.txbMarkedCardEnd.Text.Trim() == "")
                strMsg += "请输入标识卡终止卡号!\\r\\n";
        }
        if (strMsg != "")
        {
            MessageBox.Show(this.UpdatePanel1, this, strMsg);
            return;
        }

        SqlParameter[] parameters = {
                    new SqlParameter("@MarkCardStart", SqlDbType.VarChar,20),
                    new SqlParameter("@MarkCardEnd", SqlDbType.VarChar,20),
                    new SqlParameter("@CollCode", SqlDbType.VarChar,10),
                    new SqlParameter("@CoalKindCode", SqlDbType.VarChar,10),
                    new SqlParameter("@SendCardDate", SqlDbType.DateTime),
                    new SqlParameter("@Operator", SqlDbType.NVarChar,20),
                    new SqlParameter("@DepartName", SqlDbType.NVarChar,20)};
        if (this.rbType.SelectedValue == "1")
        {
            parameters[0].Value = this.txbMarkedCard.Text.Trim();
            parameters[1].Value = this.txbMarkedCard.Text.Trim();
        }
        else if (this.rbType.SelectedValue == "2")
        {
            parameters[0].Value = this.txbMarkedCardBegin.Text.Trim();
            parameters[1].Value = this.txbMarkedCardEnd.Text.Trim();
        }
        parameters[2].Value = this.ddlColl.SelectedValue;
        parameters[3].Value = this.ddlCoalKind.SelectedValue;
        parameters[4].Value = DateTime.Now;
        parameters[5].Value = CookieManager.GetCookieValue("UserName");
        parameters[6].Value = DbHelperSQL.GetSingle("Select isnull(OrgName,'') from VSys_Operator where UserCode='" + CookieManager.GetCookieValue("uid")+ "'").ToString();

        DataTable dt = DbHelperSQL.TRunProcedure("[PT_SendMarkedCard]", parameters);
        string strExistCard = dt.Rows[0][0].ToString();
        if (dt.Rows[0][0].ToString() != "")
            MessageBox.Show(this.UpdatePanel1, this, "发卡失败," + dt.Rows[0][0].ToString());
        else
        {
            #region 数据同步
            string strSql = "[PT_SendMarkedCard] '" + parameters[0].Value.ToString() + "','"
                + parameters[1].Value.ToString() + "','" + parameters[2].Value.ToString() + "','"
                + parameters[3].Value.ToString() + "','" + parameters[4].Value.ToString() + "','"
                + parameters[5].Value.ToString() + "','" + parameters[6].Value.ToString() + "'";
            MsmqManage mq = new MsmqManage();
            string strMq = mq.AllStation + mq.Prefix + "TT_MarkedCard" + mq.Prefix + mq.AddFlg + mq.Prefix + DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss") + mq.Prefix + strSql.ToString();
            mq.AddMsmq(strMq.ToString());
            #endregion

            MessageBox.Show(this.UpdatePanel1, this, "发卡成功!");
            this.txbAmount.Text = "";
            this.txbMarkedCard.Text = "";
            this.txbMarkedCardBegin.Text = "";
            this.txbMarkedCardEnd.Text = "";
            if (ConfigurationManager.AppSettings["ProName"] == "WanSheng")
            {
                this.dpl_villages.SelectedIndex = 0;
                this.ddlColl.SelectedIndex = 0;
                this.ddlCoalKind.SelectedIndex = 0;
                this.txtCollCode.Text = "";
            }
        }
    }