Exemplo n.º 1
0
        //2012.5.11本地传到远程的Qskyd_fjrb_temp然后在添加到Qskyd_fjrb表
        //1.如果有相同的lsbh就修改,否者添加。
        //2.最后和Qskyd_fjrb_temp这张表对比,如果Qskyd_fjrb not in(lsbh)的条件就删除
        //这样做是怕本的删除了远程有可能还有这条记录在
        public static string Add_Qskyd_fjrb(DataSet DS_Qskyd_fjrb, string yydh)
        {
            // id,yydh,qymc,lsbh,krxm,sktt,yddj,fjrb,fjbh,ddsj,lksj,lzfs,shqh,fjjg,sjfjjg,yh,yhbl,bz,is_top,
            //is_select,shsc,czy,czsj,cznr,sdcz,fjbm,jcje
            string s = common_file.common_app.get_failure;

            if (DS_Qskyd_fjrb != null && DS_Qskyd_fjrb.Tables[0].Rows.Count > 0)
            {
                Model.Qskyd_fjrb M_Qskyd_fjrb = new Model.Qskyd_fjrb();
                BLL.Qskyd_fjrb   B_Qskyd_fjrb = new BLL.Qskyd_fjrb();
                string           strlsbh_ds   = ""; //记录总的lsbh以“,”号隔开
                foreach (DataRow dr in DS_Qskyd_fjrb.Tables[0].Rows)
                {
                    string strLsbh = dr["lsbh"].ToString();
                    M_Qskyd_fjrb.lsbh      = dr["lsbh"].ToString();
                    M_Qskyd_fjrb.yydh      = dr["yydh"].ToString();
                    M_Qskyd_fjrb.qymc      = dr["qymc"].ToString();
                    M_Qskyd_fjrb.krxm      = dr["krxm"].ToString();
                    M_Qskyd_fjrb.sktt      = dr["sktt"].ToString();
                    M_Qskyd_fjrb.yddj      = dr["yddj"].ToString();
                    M_Qskyd_fjrb.fjrb      = dr["fjrb"].ToString();
                    M_Qskyd_fjrb.fjbh      = dr["fjbh"].ToString();
                    M_Qskyd_fjrb.ddsj      = Convert.ToDateTime(dr["ddsj"].ToString());
                    M_Qskyd_fjrb.lksj      = Convert.ToDateTime(dr["lksj"].ToString());
                    M_Qskyd_fjrb.lzfs      = Convert.ToDecimal(dr["lzfs"].ToString());
                    M_Qskyd_fjrb.shqh      = dr["shqh"].ToString();
                    M_Qskyd_fjrb.fjjg      = Convert.ToDecimal(dr["fjjg"].ToString());
                    M_Qskyd_fjrb.sjfjjg    = Convert.ToDecimal(dr["sjfjjg"].ToString());
                    M_Qskyd_fjrb.yh        = "";
                    M_Qskyd_fjrb.yhbl      = 0;
                    M_Qskyd_fjrb.bz        = "";
                    M_Qskyd_fjrb.is_top    = false;
                    M_Qskyd_fjrb.is_select = false;
                    M_Qskyd_fjrb.shsc      = true;
                    M_Qskyd_fjrb.czy       = dr["czy"].ToString();
                    M_Qskyd_fjrb.czsj      = Convert.ToDateTime(dr["czsj"].ToString());
                    M_Qskyd_fjrb.cznr      = dr["cznr"].ToString();

                    //如果有相同lsbh就修改,,然后添加。
                    DataSet ds = B_Qskyd_fjrb.GetList("lsbh='" + strLsbh + "' and fjrb='" + dr["fjrb"].ToString() + "'");

                    if (ds != null && ds.Tables[0].Rows.Count > 0)
                    {
                        int fid = Convert.ToInt32(ds.Tables[0].Rows[0]["id"].ToString());
                        M_Qskyd_fjrb.id = fid;
                        if (B_Qskyd_fjrb.Update(M_Qskyd_fjrb))
                        {
                            s = common_file.common_app.get_suc;
                        }
                    }
                    else
                    {
                        //添加到Qskyd_fjrb表里
                        if (B_Qskyd_fjrb.Add(M_Qskyd_fjrb) > 0)
                        {
                            s = common_file.common_app.get_suc;
                        }
                    }

                    strlsbh_ds += "'" + strLsbh + "'" + ",";  //累加lsbh以“,”号相隔
                }
                s = common_file.common_app.get_suc;
                //相反不相等的话就删除,防止本地删除中央服务器还没有删除lsbh not in
                if (strlsbh_ds.Length != 0)
                {
                    strlsbh_ds = strlsbh_ds.Remove(strlsbh_ds.Length - 1, 1);//删除最后一个,号
                    string strsql = "delete from Qskyd_fjrb where lsbh not in(" + strlsbh_ds + ") and yydh='" + yydh + "'";

                    DbHelperSQL.Exists(strsql);
                    s = common_file.common_app.get_suc;
                }
            }
            return(s);
        }
Exemplo n.º 2
0
        //2012.5.11本地传到远程的Qskyd_fjrb_temp然后在添加到Qskyd_fjrb表
        //1.如果有相同的lsbh就修改,否者添加。
        //2.最后和Qskyd_fjrb_temp这张表对比,如果Qskyd_fjrb not in(lsbh)的条件就删除
        //这样做是怕本的删除了远程有可能还有这条记录在
        public static string Add_Qskyd_fjrb(DataSet DS_Qskyd_fjrb, string yydh)
        {
            // id,yydh,qymc,lsbh,krxm,sktt,yddj,fjrb,fjbh,ddsj,lksj,lzfs,shqh,fjjg,sjfjjg,yh,yhbl,bz,is_top,
            //is_select,shsc,czy,czsj,cznr,sdcz,fjbm,jcje
            string s = common_file.common_app.get_failure;

            if (DS_Qskyd_fjrb != null && DS_Qskyd_fjrb.Tables[0].Rows.Count > 0)
            {
                string strsql_03 = "delete from Qskyd_fjrb where isok=1 and yydh='" + yydh + "'";
                DbHelperSQL.ExecuteSql(strsql_03);
                Model.Qskyd_fjrb M_Qskyd_fjrb = new Model.Qskyd_fjrb();
                BLL.Qskyd_fjrb   B_Qskyd_fjrb = new BLL.Qskyd_fjrb();
                foreach (DataRow dr in DS_Qskyd_fjrb.Tables[0].Rows)
                {
                    string strLsbh = dr["lsbh"].ToString();
                    M_Qskyd_fjrb.lsbh      = dr["lsbh"].ToString();
                    M_Qskyd_fjrb.yydh      = dr["yydh"].ToString();
                    M_Qskyd_fjrb.qymc      = dr["qymc"].ToString();
                    M_Qskyd_fjrb.krxm      = dr["krxm"].ToString();
                    M_Qskyd_fjrb.sktt      = dr["sktt"].ToString();
                    M_Qskyd_fjrb.yddj      = dr["yddj"].ToString();
                    M_Qskyd_fjrb.fjrb      = dr["fjrb"].ToString();
                    M_Qskyd_fjrb.fjbh      = dr["fjbh"].ToString();
                    M_Qskyd_fjrb.ddsj      = Convert.ToDateTime(dr["ddsj"].ToString());
                    M_Qskyd_fjrb.lksj      = Convert.ToDateTime(dr["lksj"].ToString());
                    M_Qskyd_fjrb.lzfs      = Convert.ToDecimal(dr["lzfs"].ToString());
                    M_Qskyd_fjrb.shqh      = dr["shqh"].ToString();
                    M_Qskyd_fjrb.fjjg      = Convert.ToDecimal(dr["fjjg"].ToString());
                    M_Qskyd_fjrb.sjfjjg    = Convert.ToDecimal(dr["sjfjjg"].ToString());
                    M_Qskyd_fjrb.yh        = "";
                    M_Qskyd_fjrb.yhbl      = 0;
                    M_Qskyd_fjrb.bz        = "";
                    M_Qskyd_fjrb.is_top    = false;
                    M_Qskyd_fjrb.is_select = false;
                    M_Qskyd_fjrb.shsc      = true;
                    M_Qskyd_fjrb.czy       = dr["czy"].ToString();
                    M_Qskyd_fjrb.czsj      = Convert.ToDateTime(dr["czsj"].ToString());
                    M_Qskyd_fjrb.cznr      = dr["cznr"].ToString();


                    M_Qskyd_fjrb.isok = true;
                    //如果有相同lsbh就修改,,然后添加。
                    DataSet ds = B_Qskyd_fjrb.GetList("lsbh='" + strLsbh + "' and fjrb='" + dr["fjrb"].ToString() + "' and fjbh='" + dr["fjbh"].ToString() + "' and lzfs='" + dr["lzfs"].ToString() + "' and ddsj='" + dr["ddsj"] + "' and lksj='" + dr["lksj"] + "' and isok=0 ");
                    if (ds != null && ds.Tables[0].Rows.Count > 0)
                    {
                        int    fid       = Convert.ToInt32(ds.Tables[0].Rows[0]["id"].ToString());
                        string strsql_01 = "update Qskyd_fjrb set isok=1 where id=" + fid + "";
                        if (DbHelperSQL.ExecuteSql(strsql_01) > 0)
                        {
                            M_Qskyd_fjrb.id = fid;
                            B_Qskyd_fjrb.Update(M_Qskyd_fjrb);
                            s = common_file.common_app.get_suc;
                        }
                    }
                    else
                    {
                        //添加到Qskyd_fjrb表里
                        if (B_Qskyd_fjrb.Add(M_Qskyd_fjrb) > 0)
                        {
                            s = common_file.common_app.get_suc;
                        }
                    }
                }
                string strsql = "delete from Qskyd_fjrb where isok=0 and yydh='" + yydh + "'";
                DbHelperSQL.ExecuteSql(strsql);

                string strsql_02 = "update Qskyd_fjrb set isok=0 where yydh='" + yydh + "'";
                DbHelperSQL.ExecuteSql(strsql_02);
                s = common_file.common_app.get_suc;
            }
            return(s);
        }