Esempio n. 1
0
        /// <summary>
        /// 删除用户数据,同时删除其相关数据
        /// 提示:此功能,可能会根据不同的项目重写
        /// </summary>
        /// <param name="AreaCode"></param>
        public bool DeleteData(String UserID)
        {
            bool succ = false;

            if (String.IsNullOrEmpty(UserID) == false)
            {
                List <SearchField> condition = new List <SearchField>();
                condition.Add(new SearchField("UserID", UserID, SearchOperator.Collection));

                JConnect conn1 = JConnect.GetConnect();
                conn1.BeginTrans();
                try
                {
                    //JRoleUsersDA da1 = new JRoleUsersDA(conn1);
                    //da1.DeleteData(condition);

                    //JOrgUsersDA da2 = new JOrgUsersDA(conn1);
                    //da2.DeleteData(condition);

                    JUserDA da3 = new JUserDA();
                    da3.DeleteData(condition);

                    //删除其他的相关业务表
                    conn1.CommitTrans();
                    succ = true;
                }
                catch (Exception err)
                {
                    JTool.WriteErrorLog(err.Message);
                    conn1.RollBackTrans();
                }
            }
            return(succ);
        }
Esempio n. 2
0
        //合并担担车收入
        public static int MergeData_SHOUROU()
        {
            JConnect conn1 = JConnect.GetConnect();

            conn1.BeginTrans();
            int    count = 0;
            JTable tab1  = null;

            try
            {
                tab1           = new JTable(conn1, "");
                tab1.TableName = "NEWTRAINSHOUROU";
                tab1.OrderBy   = "byear,bmonth,trainname,astation,bstation";
                DataTable dt1 = tab1.SearchData(null, -1, "*").Tables[0];

                for (int i = dt1.Rows.Count - 1; i > 0; i--)
                {
                    DataRow dr1 = dt1.Rows[i];
                    DataRow dr0 = dt1.Rows[i - 1];
                    if (dr1["byear"].ToString() == dr0["byear"].ToString() &&
                        dr1["bmonth"].ToString() == dr0["bmonth"].ToString() &&
                        dr1["trainname"].ToString() == dr0["trainname"].ToString() &&
                        dr1["astation"].ToString() == dr0["astation"].ToString() &&
                        dr1["bstation"].ToString() == dr0["bstation"].ToString()
                        )
                    {
                        for (int k = 1; k <= 6; k++)
                        {
                            dr0["SHOUROU" + k] = double.Parse(dr0["SHOUROU" + k].ToString())
                                                 + double.Parse(dr1["SHOUROU" + k].ToString());
                        }
                        dr1.Delete();
                        count++;
                    }
                }
                if (count > 0)
                {
                    tab1.Update(dt1);
                }
                conn1.CommitTrans();
            }
            catch (Exception err)
            {
                conn1.RollBackTrans();
                count = 0;
            }
            if (tab1 != null)
            {
                tab1.Close();
            }

            return(count);
        }
Esempio n. 3
0
        //合并数据
        /// <summary>
        /// kind=0 --- 担担车收入
        /// kind=1 --- 线路使用费
        /// kind=2 --- 机车牵引费
        /// kind=3 --- 电网和接触网费
        /// kind=4 --- 列车运输人数
        /// </summary>
        /// <param name="kind"></param>
        /// <returns></returns>
        public static int MergeData(int kind)
        {
            JConnect conn1 = JConnect.GetConnect();

            conn1.BeginTrans();
            int    count     = 0;
            JTable tab1      = null;
            String tableName = String.Empty;

            String[] fs = null;

            if (kind == 0)
            {
                tableName = "NEWTRAINSHOUROU";
                fs        = new String[] { "SHOUROU1", "SHOUROU2", "SHOUROU3", "SHOUROU4", "SHOUROU5", "SHOUROU6" };
            }
            else if (kind == 1)
            {
                tableName = "NEWTRAINXIANLUFEE";
                fs        = new String[] { "GONGLI1", "GONGLI2", "GONGLI3", "FEE1", "FEE2", "FEE3" };
            }
            else if (kind == 2)
            {
                tableName = "NEWTRAINQIANYINFEE";
                fs        = new String[] { "ZL1", "ZL2", "ZL3", "FEE1", "FEE2", "FEE3" };
            }
            else if (kind == 3)
            {
                tableName = "NEWTRAINSERVERPEOPLE";
                fs        = new String[] { "PC1", "PC2", "PC3", "FEE1", "FEE2", "FEE3" };
            }

            if (String.IsNullOrEmpty(tableName) == false)
            {
                try
                {
                    tab1           = new JTable(conn1, "");
                    tab1.TableName = tableName;
                    tab1.OrderBy   = "byear,bmonth,trainname,astation,bstation";
                    DataTable dt1 = tab1.SearchData(null, -1, "*").Tables[0];

                    for (int i = dt1.Rows.Count - 1; i > 0; i--)
                    {
                        DataRow dr1 = dt1.Rows[i];
                        DataRow dr0 = dt1.Rows[i - 1];
                        if (dr1["byear"].ToString() == dr0["byear"].ToString() &&
                            dr1["bmonth"].ToString() == dr0["bmonth"].ToString() &&
                            dr1["trainname"].ToString() == dr0["trainname"].ToString() &&
                            dr1["astation"].ToString() == dr0["astation"].ToString() &&
                            dr1["bstation"].ToString() == dr0["bstation"].ToString()
                            )
                        {
                            foreach (String m in fs)
                            {
                                dr0[m] = double.Parse(dr0[m].ToString()) + double.Parse(dr1[m].ToString());
                            }
                            dr1.Delete();
                            count++;
                        }
                    }
                    if (count > 0)
                    {
                        tab1.Update(dt1);
                    }
                    conn1.CommitTrans();
                }
                catch (Exception err)
                {
                    conn1.RollBackTrans();
                    count = 0;
                }
                if (tab1 != null)
                {
                    tab1.Close();
                }
            }

            return(count);
        }
Esempio n. 4
0
        /// <summary>
        /// 保存用户数据的修改
        /// </summary>
        /// <returns></returns>
        public int SaveData(String oldUserID, String num, String UserID,
                            String UserName, String trueName, String telephone, String Status, String AuthorityID, String OrgID, String cardID)
        {
            int      succ = 0;
            JConnect conn = JConnect.GetConnect();

            conn.BeginTrans();
            try
            {
                JUserDA     da1 = new JUserDA(conn);
                JOrgUsersDA da2 = new JOrgUsersDA(conn);

                Dictionary <String, object> data1 = new Dictionary <string, object>();
                data1["num"]            = num;
                data1["userid"]         = UserID;
                data1["username"]       = UserName;
                data1["TrueName"]       = trueName;
                data1["status"]         = Status;
                data1["AuthorityID"]    = AuthorityID;
                data1["DepartID"]       = FrameLib.DepartID;
                data1["AuthorityGroup"] = FrameLib.AuthorityGroup;
                if (!string.IsNullOrEmpty(cardID))
                {
                    data1["WbCardID"] = cardID;
                }
                if (!string.IsNullOrEmpty(telephone))
                {
                    data1["Telephone"] = telephone;
                }

                if (String.IsNullOrEmpty(oldUserID) == false)
                {
                    List <SearchField> condition = new List <SearchField>();
                    condition.Add(new SearchField("UserID", UserID));
                    data1.Remove("userid");
                    da1.EditData(condition, data1);
                }
                else
                {
                    data1["[Password]"] = "123456";              //设置默认的口令和密码
                    data1["LastLogin"]  = DateTime.Now;          //设置默认的登陆时间
                    data1["LoginCount"] = 0;                     //设置默认的登陆测试
                    da1.NewData(data1);
                }

                //更新组织用户表
                List <SearchField> condition2 = new List <SearchField>();
                condition2.Add(new SearchField("UserID", UserID));
                if (string.IsNullOrEmpty(OrgID) == false)
                {
                    if (da2.HasData(condition2))
                    {
                        data1.Clear();
                        data1["orgid"] = OrgID;
                        da2.EditData(condition2, data1);
                    }
                    else
                    {
                        data1.Clear();
                        data1["orgid"]  = OrgID;
                        data1["userid"] = UserID;
                        da2.NewData(data1);
                    }
                }
                else
                {
                    da2.DeleteData(condition2);
                }
                conn.CommitTrans();
                succ = 1;
            }
            catch (Exception err)
            {
                conn.RollBackTrans();
            }
            return(succ);
        }
Esempio n. 5
0
        //提交数据,插入站点
        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("提交失败!");
                    }
                }
            }
        }