protected void btnSave_Click(object sender, ImageClickEventArgs e) { string strMsg = ""; if (Convert.ToDateTime(this.txtWeightTime.Text) > DateTime.Now) strMsg += "过磅日期不能大于当前日期!\\r\\n"; if (this.ddlRoom.SelectedIndex == 0) strMsg += "请选择计量站\\r\\n"; else { string strRoomColl = DbHelperSQL.GetSingle("Select isnull(CollCode,'') from TT_Room where RoomCode='" + this.ddlRoom.SelectedValue + "'").ToString(); if (this.ddlColl.SelectedIndex == 0) { strMsg += "请选择煤矿\\r\\n"; } else { if (strRoomColl != strCollCode) strMsg += "您选择的计量站对应的煤矿与您选择的煤矿不一致!\\r\\n"; //else //{ // if (bll.IsCollAcountLacking(strCollCode)) // strMsg += "煤矿余额已不足,充值后才能修改过磅记录!\\r\\n"; //} } } if(Convert.ToDecimal(this.txtLoadWeight.Text.Trim())<=Convert.ToDecimal(this.txtEmptyWeight.Text.Trim())) strMsg += "空车重量不能大于等于车辆总重!\\r\\n"; if (Request.QueryString["key"] != null) { if (this.txtReason.Text.Trim() == "") strMsg += "修改原因不能为空!\\r\\n"; } if (strMsg != "") { MessageBox.Show(this.UpdatePanel1, this, strMsg); return; } TDTK.IndustryPlatform.CoalTraffic.Model.TT_LoadWeight model = new TDTK.IndustryPlatform.CoalTraffic.Model.TT_LoadWeight(); if (Request.QueryString["key"] == null) { model.WeightCode = this.ddlRoom.SelectedValue.PadLeft(4, '0') + DateTime.Now.ToString("yyyyMMddhhmmss"); model.TrafficCode = model.WeightCode; model.FrontImage = ""; model.BackImage = ""; model.UpImage = ""; model.RoomImage = ""; model.BackImageContent = null; model.FrontImageContent = null; model.RoomImageContent = null; model.UpImageContent = null; model.BangType = "散煤人工过磅"; model.TaxType = "散煤正常扣税"; model.IsFirstSite = "1"; model.RandomCode = CommonMethod.getRandom(4); model.Operator = CookieManager.GetCookieValue("UserName"); } else { model = bll.GetModel(Request.QueryString["key"].ToString()); if (model.IsFirstSite != "1") { model.NetWeight = 0; decimal dMax = Convert.ToDecimal(DbHelperSQL.GetSingle("Select isnull(max(LoadWeight),0) from TT_LoadWeight where TrafficCode='" + model.TrafficCode + "' and WeightTime<'" + model.WeightTime.ToString() + "'")); decimal dRange = Convert.ToDecimal(ConfigurationManager.AppSettings["WeightRange"]); decimal dOver = Convert.ToDecimal(this.txtLoadWeight.Text.Trim()) - dMax; if (dOver > dRange) model.OverWeight = dOver; else model.OverWeight = 0; } else { model.NetWeight = Convert.ToDecimal(this.txtLoadWeight.Text.Trim()) - Convert.ToDecimal(this.txtEmptyWeight.Text); model.OverWeight = 0; } } model.WeightTime = Convert.ToDateTime(this.txtWeightTime.Text); model.EmptyCode = this.txtEmptyCode.Text.Trim(); model.CarNo = this.txtCarNo.Text.Trim(); model.CarOwnerName = this.txtCarOwnerName.Text.Trim(); model.CollCode = strCollCode; model.CollName = this.ddlColl.SelectedItem.Text; ; model.EmptyWeight = Convert.ToDecimal(this.txtEmptyWeight.Text); model.CoalKindCode = strKindCode; model.CoalKindName = this.txtKindName.Text.Trim(); model.LoadWeight = Convert.ToDecimal(this.txtLoadWeight.Text.Trim()); model.NetWeight = Convert.ToDecimal(this.txtLoadWeight.Text.Trim()) - Convert.ToDecimal(this.txtEmptyWeight.Text); model.EmptyWeight = Convert.ToDecimal(this.txtEmptyWeight.Text); model.MarkedCardCode = ""; model.NavicertCode = ""; model.NetWeight = Convert.ToDecimal(this.txtLoadWeight.Text.Trim()); model.RoomCode = this.ddlRoom.SelectedValue; model.RoomName = this.ddlRoom.SelectedItem.Text; model.TaxObject= ConfigurationManager.AppSettings["TaxObject"].ToString(); if (Request.QueryString["key"] != null) { string strKey = bll.UpdateLoadWeight(model, this.txtReason.Text.Trim()); if (strKey == "") { MessageBox.Show(this.UpdatePanel1, this, "修改失败!"); ClearText(); } else { if (strKey == "-1") { MessageBox.Show(this.UpdatePanel1, this, "账户余额已不足本车的扣款,请通知" + model.CollName + "速来交费"); return; } #region 数据同步 //string strSql = "PT_LoadWeightUpdate '" + model.WeightCode + "','" + model.NavicertCode + "','" + model.MarkedCardCode + "','" + model.RemoteCardCode + "','" + model.CollCode + "'," // + "'" + model.CollName + "','" + model.CoalKindCode + "','" + model.CoalKindName + "','" + model.CarOwnerName + "','" + model.CarNo + "'," // + "'" + model.CarType + "','" + model.LoadWeight + "','" + model.EmptyWeight + "','" + model.NetWeight + "','" + model.OverWeight + "'," // + "'" + model.RoomCode + "','" + model.RoomName + "','" + model.WeightTime + "','" + model.CustomerName + "','" + model.IsFirstSite + "'," // + "'" + model.Operator + "','" + model.TaxObject + "','" + model.EmptyCode + "'"; //string strMq = mq.AllStation + mq.Prefix + "TT_LoadWeight" + mq.Prefix + mq.AddFlg + mq.Prefix + DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss") + mq.Prefix + strSql.ToString(); //mq.AddMsmq(strMq.ToString());禁用消息队列 #endregion ScriptManager.RegisterStartupScript(this.UpdatePanel1, Page.GetType(), "", "this.top.currForm.close();", true); } } else { string strKey=bll.AddLoadWeight(model); if (strKey == "") MessageBox.Show(this.UpdatePanel1, this, "添加失败!"); else { if (strKey == "-1") { MessageBox.Show(this.UpdatePanel1, this, "账户余额已不足本车的扣款,请通知" + model.CollName + "速来交费"); return; } #region 数据同步 //string strSql = "PT_LoadWeight '" + model.WeightCode + "','" + model.TrafficCode + "','" + model.NavicertCode + "','" + model.MarkedCardCode + "','" + model.RemoteCardCode + "'," // + "'" + model.CollCode + "','" + model.CollName + "','" + model.CoalKindCode + "','" + model.CoalKindName + "','" + model.CarOwnerName + "'," // + "'" + model.CarNo + "','" + model.CarType + "','" + model.LoadWeight + "','" + model.EmptyWeight + "','" + model.NetWeight + "'," // + "'" + model.OverWeight + "','" + model.RoomCode + "','" + model.RoomName + "','" + model.BangType + "','" + model.Operator + "'," // + "'" + model.WeightTime + "','" + model.RandomCode + "','" + model.CustomerName + "','" + model.TaxType + "','" + model.TaxObject + "'," // + "'" + model.IsFirstSite + "'," // + "'','','',''," // + "null,null,null,null,'" + model.EmptyCode + "'"; //string strMq = mq.AllStation + mq.Prefix + "TT_LoadWeight" + 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 strType = "1"; //超重为零 是重车过磅单,非零验票单 if (model.OverWeight == 0) { strType = "0"; } string strTitle = ConfigurationManager.AppSettings["Customer"] + "煤炭管理散煤过磅放行单"; ScriptManager.RegisterStartupScript(this.UpdatePanel1, Page.GetType(), "", "Print('" + strKey + "','" + strTitle + "','" + strType + "');", true); ClearText(); } } }
protected void btnSave_Click(object sender, ImageClickEventArgs e) { string strMsg = ""; //if (Convert.ToDateTime(this.txtWeightTime.Text) > DateTime.Now) //strMsg += "过磅日期不能大于当前日期!\\r\\n"; if (this.ddlColl.SelectedIndex == 0) { strMsg += "请选择煤矿!\\r\\n"; } //else if (bll.IsCollAcountLacking(strCollCode)) //{ // strMsg += "煤矿余额已不足,充值后才能修改过磅记录!\\r\\n"; //} //if (!bll.IsCollRunKind(strKindCode, strCollCode)) // strMsg += this.txtCollName.Text + "不经营" + this.txtKindName.Text + ",才能修改过磅记录!\\r\\n"; if (this.ddlRoom.SelectedIndex == 0) strMsg += "请选择磅房\\r\\n"; if (Request.QueryString["key"] != null ) { if (this.txtReason.Text.Trim() == "") strMsg += "修改原因不能为空!\\r\\n"; } if (strMsg != "") { MessageBox.Show(this.UpdatePanel1, this, strMsg); return; } TDTK.IndustryPlatform.CoalTraffic.Model.TT_LoadWeight model = new TDTK.IndustryPlatform.CoalTraffic.Model.TT_LoadWeight(); if (Request.QueryString["key"] == null) { model.WeightCode = this.ddlRoom.SelectedValue.PadLeft(4, '0') + DateTime.Now.ToString("yyyyMMddhhmmss"); model.TrafficCode = model.WeightCode; model.FrontImage = ""; model.BackImage = ""; model.UpImage = ""; model.RoomImage = ""; model.BackImageContent = null; model.FrontImageContent = null; model.RoomImageContent = null; model.UpImageContent = null; model.BangType = "重车人工过磅"; model.TaxType = "重车正常扣税"; model.IsFirstSite = "1"; model.RandomCode = CommonMethod.getRandom(4); model.Operator = CookieManager.GetCookieValue("UserName"); model.OverWeight = 0; } else { model = bll.GetModel(Request.QueryString["key"].ToString()); model.WeightCode = Request.QueryString["key"].ToString(); if (model.IsFirstSite != "1") { model.NetWeight = 0; decimal dMax = Convert.ToDecimal(DbHelperSQL.GetSingle("Select isnull(max(LoadWeight),0) from TT_LoadWeight where TrafficCode='" + model.TrafficCode + "' and WeightTime<'" + model.WeightTime.ToString() + "'")); decimal dRange = Convert.ToDecimal(ConfigurationManager.AppSettings["WeightRange"]); decimal dOver = Convert.ToDecimal(this.txtLoadWeight.Text.Trim().Replace(" ", "")) - dMax; if (dOver > dRange) model.OverWeight = dOver; else model.OverWeight = 0; } else { model.OverWeight = 0; } } model.WeightTime = Convert.ToDateTime(this.txtWeightTime.Text); model.CarNo = this.txtCarNo.Text.Trim(); model.CarOwnerName = this.txtCarOwnerName.Text; model.CarType = this.txtCarType.Text; model.CollCode = strCollCode; //model.CollName = this.ddlColl.SelectedItem.Text; model.CollName = strCollName; model.EmptyWeight = Convert.ToDecimal(this.txtEmptyWeight.Text); model.EmptyCode = strEmptyCode; model.NetWeight = Convert.ToDecimal(this.txtLoadWeight.Text.Trim().Replace(" ", "")) - model.EmptyWeight; model.CoalKindCode = strKindCode;//煤矿种类编号 model.CoalKindName = strKindName;//煤种名称 //model.CoalKindCode = this.ddlKindName.SelectedValue;//获取选中的煤矿种类编号--暂时注释 //model.CoalKindName = this.txtKindName.Text.Trim();//煤矿种类名称 //model.CoalKindName = this.ddlKindName.SelectedItem.Text.Trim();//获取选中的煤矿种类名称--暂时注释 model.LoadWeight = Convert.ToDecimal(this.txtLoadWeight.Text.Trim().Replace(" ", "")); model.EmptyWeight = Convert.ToDecimal(this.txtEmptyWeight.Text); model.MarkedCardCode = txtMarkedCardCode.Text.Trim(); model.NavicertCode = this.txtNavicertCode.Text.Trim(); model.RoomCode = strRoomCode; model.RoomName = strRoom; //model.RoomCode = this.ddlRoom.SelectedValue; //model.RoomName = this.ddlRoom.SelectedItem.Text; if (model.MarkedCardCode != "")//扣费方式 { model.TaxObject = "2";//煤矿企业扣费 } else { model.TaxObject = "1";//磅房扣费 } #region 将电子标签值赋值给实例对象 //根据车牌号获取远程卡号 object objRemote = DbHelperSQL.TQuery("Select RemoteCardCode from TT_CarInfo where CarNo='" + model.CarNo.Replace("'", "''") + "'"); if (objRemote != null) model.RemoteCardCode = objRemote.ToString(); else model.RemoteCardCode = ""; #endregion if (Request.QueryString["key"] != null ) { string strKey = bll.UpdateLoadWeight(model, this.txtReason.Text.Trim()); if (strKey == "") MessageBox.Show(this.UpdatePanel1, this, "修改失败!"); else { if (strKey == "-1") { MessageBox.Show(this.UpdatePanel1, this, "账户余额已不足本车的扣款,请通知" + model.CollName + "速来交费"); return; } #region 数据同步 //string strSql = "PT_LoadWeightUpdate '" + model.WeightCode + "','" + model.NavicertCode + "','" + model.MarkedCardCode + "','" + model.RemoteCardCode + "','" + model.CollCode + "'," // + "'" + model.CollName + "','" + model.CoalKindCode + "','" + model.CoalKindName + "','" + model.CarOwnerName + "','" + model.CarNo + "'," // + "'" + model.CarType + "','" + model.LoadWeight + "','" + model.EmptyWeight + "','" + model.NetWeight + "','" + model.OverWeight + "'," // + "'" + model.RoomCode + "','" + model.RoomName + "','" + model.WeightTime + "','" + model.CustomerName + "','" + model.IsFirstSite + "'," // + "'" + model.Operator + "','" + model.TaxObject + "','" + model.EmptyCode + "'"; //string strMq = mq.AllStation + mq.Prefix + "TT_LoadWeight" + mq.Prefix + mq.EditFlg + mq.Prefix + DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss") + mq.Prefix + strSql.ToString(); //mq.AddMsmq(strMq.ToString());禁用消息队列 #endregion ScriptManager.RegisterStartupScript(this.UpdatePanel1, Page.GetType(), "", "this.top.currForm.close();", true); } } else { string strKey = bll.AddLoadWeight(model); if (strKey == "") MessageBox.Show(this.UpdatePanel1, this, "添加失败!"); else { if (strKey == "-1") { MessageBox.Show(this.UpdatePanel1, this, "账户余额已不足本车的扣款,请通知" + model.CollName + "速来交费"); return; } #region 数据同步 //string strSql = "PT_LoadWeight '" + model.WeightCode + "','" + model.TrafficCode + "','" + model.NavicertCode + "','" + model.MarkedCardCode + "','" + model.RemoteCardCode + "'," // + "'" + model.CollCode + "','" + model.CollName + "','" + model.CoalKindCode + "','" + model.CoalKindName + "','" + model.CarOwnerName + "'," // + "'" + model.CarNo + "','" + model.CarType + "','" + model.LoadWeight + "','" + model.EmptyWeight + "','" + model.NetWeight + "'," // + "'" + model.OverWeight + "','" + model.RoomCode + "','" + model.RoomName + "','" + model.BangType + "','" + model.Operator + "'," // + "'" + model.WeightTime + "','" + model.RandomCode + "','" + model.CustomerName + "','" + model.TaxType + "','" + model.TaxObject + "'," // + "'" + model.IsFirstSite + "'," // + "'','','',''," // + "null,null,null,null,'" + model.EmptyCode + "'"; //string strMq = mq.AllStation + mq.Prefix + "TT_LoadWeight" + mq.Prefix + mq.AddFlg + mq.Prefix + DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss") + mq.Prefix + strSql.ToString(); //mq.AddMsmq(strMq.ToString());禁用消息队列 #endregion this.txtCarNo.Text = ""; this.txtCarOwnerName.Text = ""; this.txtCarType.Text = ""; this.ddlColl.SelectedValue = ""; this.txtEmptyWeight.Text = ""; //this.txtKindName.Text = ""; //strKindCode = ""; this.txtNavicertCode.Text = ""; this.txtLoadWeight.Text = ""; this.txtNetWeight.Text = ""; this.txtReason.Text = ""; this.txtWeightTime.Text = DateTime.Now.ToString(); ddlRoom.SelectedIndex = 0; this.ddlColl.SelectedValue = ""; strCollCode = ""; this.ddlVillage.SelectedValue = ""; //打印过磅单 string strType = "1"; if (model.OverWeight == 0) { strType = "0"; } string strTitle = ConfigurationManager.AppSettings["Customer"] + "煤炭管理重车过磅放行单"; ScriptManager.RegisterStartupScript(this.UpdatePanel1, Page.GetType(), "", "Print('" + strKey + "','" + strTitle + "','" + strType + "');", true); } } }