/// <summary> /// 在linestation中完成插入站点功能 /// </summary> /// <param name="dr"></param> /// <param name="direction"></param> private void InsertLineStation(DataRow dr, string direction) { NewTrainBU bu = new NewTrainBU(); string id = dr["id"].ToString(); int num = Convert.ToInt32(dr["num"]);//得到排序号 Dictionary <string, object> dic = new Dictionary <string, object>(); dic.Add("bstation", this.newstation.Text.Trim()); dic.Add("miles", this.txtbegin.Text.Trim()); bu.EditLineStation(dic, id); //更改Num值 string lineid = dr["lineid"].ToString(); DataTable dtNums = bu.GetNumsLineStation(lineid, num.ToString(), direction); List <SearchField> condition = new List <SearchField>(); foreach (DataRow drNum in dtNums.Rows) { dic.Clear(); condition.Clear(); dic.Add("num", Convert.ToInt32(drNum["num"]) + 1); condition.Add(new SearchField("Id", drNum["id"].ToString())); bu.EditLineStation(dic, condition); } //新增 dic.Clear(); dic.Add("astation", this.newstation.Text.Trim()); dic.Add("bstation", dr["bstation"].ToString()); dic.Add("lineid", dr["lineid"].ToString()); dic.Add("miles", this.txtlast.Text.Trim()); dic.Add("num", (num + 1).ToString()); dic.Add("direction", direction); bu.NewLineStation(dic); }
//删除站点和更新路线 void button2_Click(object sender, EventArgs e) { /// <summary> /// 删除线路中的站点 /// 说明:根据站点的名称,找到合适的线路(同上) /// 根据线路LineStation中Direction=0 和 Direction=1的两种情况分别按num进行排序 /// 将线路中LINESTATION中 的所有站点数据 按下面的规则进行调整 /// 如果首站点的 第一条数据的AStation=StationName,则删除该数据,并重新调整编号num /// 如果是最后一站,则判断BStation ,如果相等,则直接删除 /// 如果中间站点 AStation 不等于 StationName,则只比较BStation中的数据是否和StationName相等 /// 如果相同,则删除该数据,并将下一个数据的AStation改成该条数据的AStation /// 对站点处理完成后,要及时退出循环,避免做无用的循环数据 /// 要分别对Direction=0 和 Direction=1的处理。 /// NEWTRAIN中的数据调整比较简单,只要把Line中的 武汉- 和 -武汉 替换成空字符串就可以了。 /// 此操作比较重要,要使用事务处理。 /// </summary> if (int.Parse(this.scount.Value) > 0) { NewTrainBU bu = new NewTrainBU(); bool flag = bu.DeleteTrainStation(this.txt1.Text.Trim()); if (flag) { JAjax.Alert("删除成功"); } else { JAjax.Alert("删除失败"); } } else { JAjax.Alert("删除的站点不存在!"); } }
//计算车次的理论值 void link1_Click(object sender, EventArgs e) { if (this.msg1.Value.IndexOf("-") > 0) { int year1 = DateTime.Now.Year; int month1 = DateTime.Now.Month; try { String str1 = this.msg1.Value + "-1"; DateTime dt1 = DateTime.Parse(str1); year1 = dt1.Year; month1 = dt1.Month; } catch (Exception err) {; } NewTrainBU.CalLiLunValue(year1, month1); } else { int year1 = DateTime.Now.Year; try { String str1 = this.msg1.Value + "-1-1"; DateTime dt1 = DateTime.Parse(str1); year1 = dt1.Year; } catch (Exception err) {; } for (int i = 1; i <= 12; i++) { NewTrainBU.CalLiLunValue(year1, i); } } this.Repeater1.DataBind(); WebFrame.Util.JAjax.Alert("提示:导入数据操作成功!"); }
private void bind() { NewTrainBU bu = new NewTrainBU(); DataTable dt = bu.GetNextLineList(this.txt1.Text.Trim(), this.txt2.Text.Trim(), "0"); this.Repeater1.DataSource = dt; this.Repeater1.DataBind(); }
protected override void OnPreRenderComplete(EventArgs e) { if (!Page.IsPostBack) { if (this.num.Text.Trim() == String.Empty) { NewTrainBU bu1 = new NewTrainBU(); this.num.Text = bu1.GetNexNum() + ""; } } base.OnPreRenderComplete(e); }
//车船费 private double GetFee15(bool sum) { double result = 0; Train train1 = NewTrainBU.GetTrainObject(this.TrainName); if (train1 != null) { double fee1 = train1.GetFee15(); if (sum == false) { result = fee1 / 12; } else { result = this.Month * (fee1 / 12); } } return(result); }
protected void txtbegin_TextChanged(object sender, EventArgs e) { int temp = 0; this.lblbegin.Text = this.txt1.Text; this.lblmid.Text = this.newstation.Text; this.lblmiddle.Text = this.newstation.Text; this.ldllast.Text = this.txt2.Text; if (this.txtbegin.Text.Trim() == "") { JAjax.Alert(string.Format("{0} 至{1}的距离不能为空!", this.lblbegin.Text, this.lblmid.Text)); return; } if (int.TryParse(this.txtbegin.Text.Trim(), out temp) == false) { JAjax.Alert(string.Format("{0} 至{1}的距离必须是整数!", this.lblbegin.Text, this.lblmid.Text)); return; } NewTrainBU bu = new NewTrainBU(); DataRow dr = bu.GetDataRowFromLineStation(this.txt1.Text.Trim(), this.txt2.Text.Trim(), "0");//在LineStation表中得到Astation ,bstation的值等于选中路线值的lineid,注意方向Directory=0的情况 if (dr == null) { JAjax.Alert(string.Format("不存在{0} 至{1}的直通线路,中间已存在其它站点!", this.txt1.Text.Trim(), this.txt2.Text.Trim())); return; } if (Convert.ToInt32(this.txtbegin.Text.ToString().Trim()) > Convert.ToInt32(dr["Miles"])) { JAjax.Alert(string.Format("{0} 至{1}的距离已大于{2}到{3}的距离!", this.lblbegin.Text, this.lblmid.Text, this.lblbegin.Text, this.ldllast.Text)); return; } if (dr != null) { txtlast.Text = (Convert.ToInt32(dr["Miles"]) - Convert.ToInt32(txtbegin.Text.ToString())).ToString(); } }
//成批更新站点的名称 void button1_Click(object sender, EventArgs e) { if (String.IsNullOrEmpty(txt1.Text.Trim()) == false && String.IsNullOrEmpty(txt2.Text.Trim()) == false) { NewTrainBU bu = new NewTrainBU(); bool flag = bu.ChangeTrainStationName(this.txt1.Text.Trim(), this.txt2.Text.Trim()); if (flag) { JAjax.Alert("更改成功!"); } else { JAjax.Alert("更改失败,请重试!"); } } else { JAjax.Alert("错误:请输入站点的名称!"); } }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { //this.Button1.Attributes.Add("onclick", "ShowWaiting();"); if (String.IsNullOrEmpty(Request.QueryString["byear"]) == false) { this.byear.Text = Request.QueryString["byear"]; } else { this.byear.Text = DateTime.Now.Year + ""; } if (String.IsNullOrEmpty(Request.QueryString["bmonth"]) == false) { this.bmonth.Text = Request.QueryString["bmonth"]; } else { this.bmonth.Text = DateTime.Now.Month + ""; } NewTrainBU.SetListControlTrainType(this.traintype, String.Empty); if (String.IsNullOrEmpty(Request.QueryString["kind"]) == false) { String temp1 = Request.QueryString["kind"]; if (this.traintype.Items.FindByValue(temp1) != null) { this.traintype.SelectedValue = temp1; } } this.SearchInfo.Visible = true; this.SearchData(); } }
/// <summary> /// 根据站点的名称查询合适的线路 /// 说明:在表 LINESTATION中根据AStation或BStation中查询满足条件的线路LineID (Direction=0) /// 根据 LineID 在表TrainLine中查询到合适的线路数据 /// 使用 Exists 查询比较合适 /// select * from TrainLine where exists (select 1 from LINESTATION where lineid=TrainLine.lineid and /// direction=0 and (Astation='wh' or BStation='wh' ) ) /// </summary> /// <param name="StationName">输入的站点名称</param> /// <returns>返回保护该站点名称的线路</returns> private DataTable GetSearchLine(String StationName) { NewTrainBU bu = new NewTrainBU(); return(bu.GetLineList(StationName, "0")); }
//绑定数据计算收入和支出 void repeater1_ItemDataBound(object sender, RepeaterItemEventArgs e) { double SRate = SRateProfileBU.GetRate(int.Parse(this.byear.Text)); Label lab1 = e.Item.FindControl("labtrainType") as Label; String trainType = lab1.Text; if (String.IsNullOrEmpty(trainType) == false) { NewTrainBU bu1 = new NewTrainBU(); List <NewTrainData> list1 = bu1.GetTrainListByType(trainType); int person1 = 0; double zc1 = 0; bu1.GetTrainPersonAndMoney(list1, out person1, out zc1); zc1 = zc1 / 10000; //设置当月的理论人数和理论收入 Label lab2 = e.Item.FindControl("labPerson") as Label; lab2.Text = person1 + ""; Label lab3 = e.Item.FindControl("labShouRou") as Label; lab3.Text = String.Format("{0:n0}", zc1); //计算当月的累计人数和累计收入数 Label lab21 = e.Item.FindControl("labPerson1") as Label; lab21.Text = person1 * int.Parse(this.bmonth.Text) + ""; Label lab31 = e.Item.FindControl("labShouRou1") as Label; lab31.Text = String.Format("{0:n0}", zc1 * int.Parse(this.bmonth.Text)); //计算实际值的当月收入和累计收入 String name1 = bu1.GetTrainNameListByKind(trainType); Label labfactshour = e.Item.FindControl("labShouRou2") as Label; bu1.GetTrainFactPersonAndMoney(name1, int.Parse(this.byear.Text), int.Parse(this.bmonth.Text), out person1, out zc1); zc1 = zc1 / 10000; labfactshour.Text = String.Format("{0:n0}", zc1); Label labPerson2 = e.Item.FindControl("labPerson2") as Label; labPerson2.Text = person1 + ""; //计算累计运输的人数 Label labfactshour2 = e.Item.FindControl("labShouRou3") as Label; bu1.GetTrainFactSumPersonAndMoney(name1, int.Parse(this.byear.Text), int.Parse(this.bmonth.Text), out person1, out zc1); zc1 = zc1 / 10000; labfactshour2.Text = String.Format("{0:n0}", zc1); Label labPerson3 = e.Item.FindControl("labPerson3") as Label; labPerson3.Text = person1 + ""; //计算当月支持和累计支出 int year1 = int.Parse(this.byear.Text); int month1 = int.Parse(this.bmonth.Text); double z1 = 0, z2 = 0; NewTrainZhiChuBU.GetTrainZhiChuByKind(trainType, year1, month1, out z1, out z2); Label labZc1 = e.Item.FindControl("zhichu1") as Label; Label labZc2 = e.Item.FindControl("zhichu2") as Label; labZc1.Text = String.Format("{0:n0}", z1); labZc2.Text = String.Format("{0:n0}", z2); //计算盈亏 double temp1 = double.Parse((e.Item.FindControl("labShouRou2") as Label).Text); double temp2 = double.Parse((e.Item.FindControl("labShouRou3") as Label).Text); double temp3 = double.Parse((e.Item.FindControl("zhichu1") as Label).Text); double temp4 = double.Parse((e.Item.FindControl("zhichu2") as Label).Text); (e.Item.FindControl("yk1") as Label).Text = String.Format("{0:n0}", temp1 * SRate - temp3); (e.Item.FindControl("yk2") as Label).Text = String.Format("{0:n0}", temp2 * SRate - temp4); } }
//提交数据,插入站点 void btnSubmit_Click(object sender, EventArgs e) { //初始化 this.lblbegin.Text = this.txt1.Text; this.lblmid.Text = this.newstation.Text; this.lblmiddle.Text = this.newstation.Text; this.ldllast.Text = this.txt2.Text; int temp = 0; if (this.lblbegin.Text.ToString().Trim() == this.lblmid.Text.ToString().Trim()) { JAjax.Alert(string.Format("新站点{0} 与起始站点{1}同名!", this.lblbegin.Text, this.lblmid.Text)); return; } if (this.lblmiddle.Text.ToString().Trim() == this.ldllast.Text.ToString().Trim()) { JAjax.Alert(string.Format("新站点{0} 与到达站点{1}同名!", this.lblmiddle.Text, this.ldllast.Text)); return; } if (int.TryParse(this.txtbegin.Text.Trim(), out temp) == false) { JAjax.Alert(string.Format("{0} 至{1}的距离必须是整数!", this.lblbegin.Text, this.lblmid.Text)); return; } else if (int.TryParse(this.txtlast.Text.Trim(), out temp) == false) { JAjax.Alert(string.Format("{0} 至{1}的距离必须是整数!", this.lblmiddle.Text, this.ldllast.Text)); return; } else { NewTrainBU bu = new NewTrainBU(); DataRow dr = bu.GetDataRowFromLineStation(this.txt1.Text.Trim(), this.txt2.Text.Trim(), "0");//在LineStation表中得到Astation ,bstation的值等于选中路线值的lineid,注意方向Directory=0的情况 if (dr == null) { JAjax.Alert("该站点路线不存在!"); return; } if (Convert.ToInt32(this.txtbegin.Text) + Convert.ToInt32(txtlast.Text) != Convert.ToInt32(dr["Miles"])) { JAjax.Alert(string.Format("{0} 至{1}的距离与{2}至{3}的距离之和与{4}到{5}的距离不相等!", this.lblbegin.Text, this.lblmid.Text, this.lblmiddle.Text, this.ldllast.Text, this.lblbegin.Text, this.ldllast.Text)); return; } else { JConnect conn = JConnect.GetConnect(); conn.BeginTrans(); try { if (dr != null) { InsertLineStation(dr, "0");//direction=0的插入操作 } DataRow dr1 = bu.GetDataRowFromLineStation(this.txt2.Text.Trim(), this.txt1.Text.Trim(), "1"); if (dr1 != null) { InsertLineStation(dr1, "1");//direction=1的插入操作 } conn.CommitTrans(); JAjax.Alert("提交成功!"); } catch (Exception ex) { conn.RollBackTrans(); JAjax.Alert("提交失败!"); } } } }