Esempio n. 1
0
        public string delForm(string FormCode)
        {
            string    sErr  = "";
            ArrayList aList = new ArrayList();
            string    sSQL  = "";

            try
            {
                if (FormCode.StartsWith("frm"))
                {
                    sSQL = "delete dbo._FormBtnInfo where fchrFrmNameID = '" + FormCode + "'";
                    aList.Add(sSQL);
                }
                sSQL = "delete _Form where fchrFrmNameID = '" + FormCode + "' ";
                aList.Add(sSQL);

                if (sErr != "")
                {
                    throw new Exception(sErr);
                }
                if (aList.Count > 0)
                {
                    int iCou = clsSQLCommond.ExecSqlTran(aList);
                }
                return(sErr);
            }
            catch (Exception ee)
            {
                sErr = ee.Message;
            }
            return(sErr);
        }
Esempio n. 2
0
    public bool Insert(string iID, Int32 iType, string iText, string Remark, bool bClose, bool bSystem)
    {
        string    uid = Session["uID"].ToString();
        ArrayList arr = new ArrayList();
        Sql       sql = new Sql();

        sSQL = "select * from  " + tablename + " where iID='" + iID + "' and iType='" + iType + "'";
        DataTable dt = clsSQLCommond.ExecQuery(sSQL);

        if (dt.Rows.Count == 0)
        {
            sql.Get(tablename, "iID", iID, "iType", iType.ToString(), true);
        }
        else
        {
            sql.Get(tablename, "iID", iID, "iType", iType.ToString(), false);
        }
        sql.ToString("iText", iText);
        sql.ToString("Remark", Remark);
        sql.ToString("bClose", bClose);
        sql.ToString("bSystem", bSystem);
        arr.Add(sql.ReturnSql());
        bool b = clsSQLCommond.ExecSqlTran(arr);

        return(true);
    }
Esempio n. 3
0
        public bool Insert(string iID, string iText, string iText2, string iType, string Remark, string bClose, string bSystem)
        {
            string    uid = Session["uID"].ToString();
            ArrayList arr = new ArrayList();
            Sql       sql = new Sql();

            if (iID == "" || iID == null)
            {
                sSQL = "select isnull(max(iID),0)+1 from  " + tablename + "";
                iID  = clsSQLCommond.ExecString(sSQL);
                sql.Get(tablename, "iID", iID, true);
            }
            else
            {
                sql.Get(tablename, "iID", iID, false);
            }
            sql.ToString("iText", iText);
            sql.ToString("iText2", iText2);
            sql.ToString("iType", iType);
            sql.ToString("Remark", Remark);
            sql.ToString("bClose", bClose);
            sql.ToString("bSystem", bSystem);
            arr.Add(sql.ReturnSql());
            bool b = clsSQLCommond.ExecSqlTran(arr);

            return(b);
        }
Esempio n. 4
0
        public bool GetVisitorsLog(string id)
        {
            ArrayList arrlist = new ArrayList();

            sSQL = "select isnull(max(right(SS6,4)),0) as CardID from Visitors where left(SS6,8)='" + DateTime.Now.ToString("yyMMdd") + "'";
            string CardID = (clsSQLCommond.Int(sSQL) + 1).ToString();

            sSQL = "select * from Visitors where iiID=" + id;
            DataTable dt = clsSQLCommond.ExecQuery(sSQL);

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                if (dt.Rows[i]["SS6"].ToString() == "")
                {
                    string newid = CardID;
                    if (newid.Length == 1)
                    {
                        newid = "000" + newid;
                    }
                    else if (newid.Length == 2)
                    {
                        newid = "00" + newid;
                    }
                    else if (newid.Length == 3)
                    {
                        newid = "0" + newid;
                    }
                    newid = DateTime.Now.ToString("yyMMdd") + newid;
                    arrlist.Add("update Visitors set DDate1='" + DateTime.Now.ToString() + "',II2='2',SS6='" + newid + "' where AutoID=" + dt.Rows[i]["AutoID"].ToString());
                    CardID = CardID + 1;
                }
            }

            try
            {
                clsSQLCommond.ExecSqlTran(arrlist);
            }
            catch
            {
                return(false);
            }

            return(true);
        }
Esempio n. 5
0
    public bool Insert(string cInvCCode, decimal Per)
    {
        ArrayList arr = new ArrayList();

        sSQL = "select * from  " + tablename + " where cInvCCode='" + cInvCCode + "'";
        DataTable dt = clsSQLCommond.ExecQueryWithoutSession(sSQL);

        if (dt.Rows.Count > 0)
        {
            sSQL = "update " + tablename + " set Per='" + Per + "' where cInvCCode='" + cInvCCode + "'";
        }
        else
        {
            sSQL = "insert into " + tablename + "(cInvCCode,Per) values('" + cInvCCode + "','" + Per + "')";
        }
        arr.Add(sSQL);
        bool b = clsSQLCommond.ExecSqlTran(arr);

        return(true);
    }
Esempio n. 6
0
    public bool Insert(string vchrUid, string vchrName, string vchrPwd, string vchrRemark, DateTime dtmCreate, DateTime dtmClose)
    {
        string    uid = Session["uID"].ToString();
        ArrayList arr = new ArrayList();
        Sql       sql = new Sql();

        sSQL = "select * from  " + tablename + " where vchrUid='" + vchrUid + "'";
        DataTable dt = clsSQLCommond.ExecQuery(sSQL);

        if (dt.Rows.Count == 0)
        {
            sql.Get(tablename, "vchrUid", vchrUid, true);
        }
        else
        {
            sql.Get(tablename, "vchrUid", vchrUid, false);
        }
        sql.ToString("vchrName", vchrName);
        if (dtmCreate != null)
        {
            sql.ToString("dtmCreate", dtmCreate);
        }
        if (dtmClose != null)
        {
            sql.ToString("dtmClose", dtmClose);
        }
        if (vchrPwd != null && vchrPwd != "")
        {
            sql.ToString("vchrPwd", clsDES.Encrypt(vchrPwd));
        }
        else
        {
            //sql.ToString("vchrPwd", clsDES.Encrypt("123456"));
        }
        sql.ToString("vchrRemark", vchrRemark);
        arr.Add(sql.ReturnSql());
        bool b = clsSQLCommond.ExecSqlTran(arr);

        return(true);
    }
Esempio n. 7
0
    public bool Insert(string vchrRoleID, string vchrRoleText, string vchrRemark)
    {
        string    uid = Session["uID"].ToString();
        ArrayList arr = new ArrayList();
        Sql       sql = new Sql();

        sSQL = "select * from  " + tablename + " where vchrRoleID='" + vchrRoleID + "'";
        DataTable dt = clsSQLCommond.ExecQuery(sSQL);

        if (dt.Rows.Count == 0)
        {
            sql.Get(tablename, "vchrRoleID", vchrRoleID, true);
        }
        else
        {
            sql.Get(tablename, "vchrRoleID", vchrRoleID, false);
        }
        sql.ToString("vchrRoleText", vchrRoleText);
        sql.ToString("vchrRemark", vchrRemark);
        arr.Add(sql.ReturnSql());
        bool b = clsSQLCommond.ExecSqlTran(arr);

        return(true);
    }
Esempio n. 8
0
        public string save(DataTable dtGrid)
        {
            string    sErr  = "";
            ArrayList aList = new ArrayList();

            try
            {
                sSQL = "select * from " + tablename + " where 1=-1";
                DataTable dt = clsSQLCommond.ExecQuery(sSQL);
                sSQL = "select isnull(max(iID)+1,1) as iID from " + tablename;
                long iID = Convert.ToInt64(clsSQLCommond.ExecGetScalar(sSQL));

                for (int i = 0; i < dtGrid.Rows.Count; i++)
                {
                    if (dtGrid.Rows[i]["iSave"].ToString().Trim() == "update" || dtGrid.Rows[i]["iSave"].ToString().Trim() == "add")
                    {
                        #region 判断
                        if (dtGrid.Rows[i][Code].ToString().Trim() == "" &&
                            dtGrid.Rows[i][Name].ToString().Trim() == "")
                        {
                            continue;
                        }
                        if (dtGrid.Rows[i][Code].ToString().Trim() == "")
                        {
                            sErr = sErr + "行" + (i + 1) + CodeTitle + "不能为空\n";
                            continue;
                        }


                        if (dtGrid.Rows[i][Name].ToString().Trim() == "")
                        {
                            sErr = sErr + "行" + (i + 1) + NameTitle + "不能为空\n";
                            continue;
                        }
                        #endregion

                        #region 判断是否重复
                        for (int j = 0; j < i; j++)
                        {
                            if (dtGrid.Rows[i][Code].ToString().Trim() == dtGrid.Rows[j][Code].ToString().Trim())
                            {
                                sErr = sErr + "行" + (i + 1) + CodeTitle + "重复\n";
                                continue;
                            }
                        }

                        for (int j = 0; j < i; j++)
                        {
                            if (dtGrid.Rows[i][Name].ToString().Trim() == dtGrid.Rows[j][Name].ToString().Trim())
                            {
                                sErr = sErr + "行" + (i + 1) + NameTitle + "重复\n";
                                continue;
                            }
                        }
                        #endregion
                        #region 生成table
                        DataRow dr = dt.NewRow();
                        if (dtGrid.Rows[i]["iID"].ToString().Trim() != "")
                        {
                            dr["iID"] = dtGrid.Rows[i]["iID"];
                        }
                        else
                        {
                            dr["iID"] = iID;
                            iID       = iID + 1;
                        }
                        dr[Code] = dtGrid.Rows[i][Code].ToString().Trim();
                        dr[Name] = dtGrid.Rows[i][Name].ToString().Trim();
                        if (dtGrid.Rows[i]["bClosed"].ToString().Trim() == "")
                        {
                            dr["bClosed"] = 0;
                        }
                        else
                        {
                            dr["bClosed"] = dtGrid.Rows[i]["bClosed"].ToString().Trim();
                        }
                        dr["Remark"] = dtGrid.Rows[i]["Remark"].ToString().Trim();

                        dt.Rows.Add(dr);
                        #endregion

                        if (dtGrid.Rows[i]["iSave"].ToString().Trim() == "update")
                        {
                            sSQL = clsGetSQL.GetUpdateSQL(ClsBaseDataInfo.sDataBaseName, tablename, dt, dt.Rows.Count - 1);
                            aList.Add(sSQL);
                        }
                        if (dtGrid.Rows[i]["iSave"].ToString().Trim() == "add")
                        {
                            sSQL = clsGetSQL.GetInsertSQL(ClsBaseDataInfo.sDataBaseName, tablename, dt, dt.Rows.Count - 1);
                            aList.Add(sSQL);
                        }
                    }
                }
                if (sErr != "")
                {
                    throw new Exception(sErr);
                }
                if (aList.Count > 0)
                {
                    int iCou = clsSQLCommond.ExecSqlTran(aList);
                }
            }
            catch (Exception ee)
            {
                sErr = ee.Message;
            }
            if (sErr == "")
            {
                return("ok");
            }
            else
            {
                return(sErr);
            }
        }
Esempio n. 9
0
        public string save(string uid, DataTable dtHead, DataTable dtGrid, string del)
        {
            string    sErr  = "";
            ArrayList aList = new ArrayList();

            try
            {
                long iID;
                #region 生成表头
                sSQL = "select * from " + tablename + " where 1=-1";
                DataTable dt = clsSQLCommond.ExecQuery(sSQL);
                sSQL = "select isnull(count(*),0) from Project where cCode='" + dtHead.Rows[0]["PCode"].ToString() + "' ";
                long count = Convert.ToInt64(clsSQLCommond.ExecGetScalar(sSQL));
                if (count == 0)
                {
                    throw new Exception("未找到工程 " + dtHead.Rows[0]["PCode"].ToString());
                }

                DataRow dr = dtHead.NewRow();
                if (dtHead.Rows[0]["iID"].ToString().Trim() != "")
                {
                    dr["iID"]           = dtHead.Rows[0]["iID"];
                    iID                 = long.Parse(dtHead.Rows[0]["iID"].ToString());
                    dr["cRdCode"]       = dtHead.Rows[0]["cRdCode"].ToString().Trim();
                    dr["dModifyTime"]   = DateTime.Now.ToString();
                    dr["dModifyPerson"] = uid;
                    dr["dCreateTime"]   = dtHead.Rows[0]["dCreateTime"].ToString().Trim();
                    dr["dCreatePerson"] = dtHead.Rows[0]["dCreatePerson"].ToString().Trim();
                }
                else
                {
                    sSQL                = "select isnull(max(iID)+1,1) as iID from " + tablename;
                    iID                 = Convert.ToInt64(clsSQLCommond.ExecGetScalar(sSQL));
                    dr["cRdCode"]       = serialNumber.GetNewSerialNumberContinuous(tablename, "cRdCode");
                    dr["iID"]           = iID;
                    dr["dCreateTime"]   = DateTime.Now.ToString();
                    dr["dCreatePerson"] = uid;
                    string sState = dtHead.Rows[0]["sState"].ToString().Trim();
                    int    iRe    = CheState(iID.ToString());
                    if (iRe == -1)
                    {
                        throw new Exception("检查单据状态出错");
                    }
                    if (iRe == 0 && (sState == "edit" || sState == "alter"))
                    {
                        throw new Exception("单据不存在");
                    }
                    if (iRe == 1 && sState == "alter")
                    {
                        throw new Exception("单据未审核");
                    }
                    if (iRe == 2 && sState == "edit")
                    {
                        throw new Exception("单据已审核");
                    }
                    //if (iRe == 3)
                    //{
                    //    throw new Exception("单据已关闭");
                    //}
                }
                dr["cRSCode"] = dtHead.Rows[0]["cRSCode"];
                dr["PCode"]   = dtHead.Rows[0]["PCode"];
                dr["dDate"]   = dtHead.Rows[0]["dDate"];

                dr["Remark"] = dtHead.Rows[0]["Remark"].ToString().Trim();

                dtHead.Rows.Add(dr);
                if (dtHead.Rows[0]["iSave"].ToString().Trim() == "update")
                {
                    sSQL = clsGetSQL.GetUpdateSQL(ClsBaseDataInfo.sDataBaseName, tablename, dtHead, dtHead.Rows.Count - 1);
                    aList.Add(sSQL);
                }
                if (dtHead.Rows[0]["iSave"].ToString().Trim() == "add")
                {
                    sSQL = clsGetSQL.GetInsertSQL(ClsBaseDataInfo.sDataBaseName, tablename, dtHead, dtHead.Rows.Count - 1);
                    aList.Add(sSQL);
                }
                #endregion

                #region dtGrid
                string[] strdel = del.Trim().Split(',');
                for (int i = 0; i < strdel.Length; i++)
                {
                    if (strdel[i].Trim() != "")
                    {
                        sSQL = "delete  from " + tablenames + " where " + tableids + " ='" + strdel[i] + "'";
                        aList.Add(sSQL);
                    }
                }
                sSQL = "select * from " + tablenames + " where 1=-1";
                DataTable dts = clsSQLCommond.ExecQuery(sSQL);
                sSQL = "select isnull(max(" + tableids + ")+1,1) as AutoID from " + tablenames;
                long   AutoID  = Convert.ToInt64(clsSQLCommond.ExecGetScalar(sSQL));
                long   iCount  = 0;
                string cRSCode = dtHead.Rows[0]["cRSCode"].ToString().Trim();
                for (int i = 0; i < dtGrid.Rows.Count; i++)
                {
                    if (dtGrid.Rows[i].RowState != DataRowState.Deleted)
                    {
                        iCount = iCount + 1;
                    }
                    if (dtGrid.Rows[i].RowState != DataRowState.Deleted && (dtGrid.Rows[i]["iSave"].ToString().Trim() == "update" || dtGrid.Rows[i]["iSave"].ToString().Trim() == "add"))
                    {
                        #region 判断
                        if (dtGrid.Rows[i]["cInvCode"].ToString().Trim() == "")
                        {
                            continue;
                        }
                        if (dtGrid.Rows[i]["cInvCode"].ToString().Trim() == "")
                        {
                            sErr = sErr + dtGrid.TableName + "行" + (i + 1) + "存货编码不能为空\n";
                            continue;
                        }
                        if (dtGrid.Rows[i]["iQuantity"].ToString().Trim() == "")
                        {
                            if (cRSCode == "01")
                            {
                                sErr = sErr + dtGrid.TableName + "行" + (i + 1) + "实盘数量不能为空\n";
                            }
                            else if (dtHead.Rows[0]["cRSCode"].ToString().Trim() == "02")
                            {
                                sErr = sErr + dtGrid.TableName + "行" + (i + 1) + "退料数量不能为空\n";
                            }
                            else if (dtHead.Rows[0]["cRSCode"].ToString().Trim() == "03")
                            {
                                sErr = sErr + dtGrid.TableName + "行" + (i + 1) + "出库数量不能为空\n";
                            }
                            else
                            {
                                sErr = sErr + dtGrid.TableName + "行" + (i + 1) + "数量不能为空\n";
                            }
                            continue;
                        }
                        #endregion

                        #region 生成table
                        DataRow dw = dts.NewRow();
                        if (dtGrid.Rows[i]["iID"].ToString().Trim() != "")
                        {
                            dw["iID"]    = dtGrid.Rows[i]["iID"].ToString().Trim();
                            dw["AutoID"] = dtGrid.Rows[i]["AutoID"].ToString().Trim();
                        }
                        else
                        {
                            dw["iID"]    = iID;
                            dw["AutoID"] = AutoID;
                            AutoID       = AutoID + 1;
                        }
                        dw["cInvCode"]  = dtGrid.Rows[i]["cInvCode"];
                        dw["SQty"]      = dtGrid.Rows[i]["SQty"];
                        dw["iQuantity"] = dtGrid.Rows[i]["iQuantity"];

                        dw["Remark"] = dtGrid.Rows[i]["Remark"];

                        dts.Rows.Add(dw);


                        #endregion

                        if (dtGrid.Rows[i]["iSave"].ToString().Trim() == "update")
                        {
                            sSQL = clsGetSQL.GetUpdateSQL(ClsBaseDataInfo.sDataBaseName, tablenames, dts, dts.Rows.Count - 1);
                            aList.Add(sSQL);
                        }
                        if (dtGrid.Rows[i]["iSave"].ToString().Trim() == "add")
                        {
                            sSQL = clsGetSQL.GetInsertSQL(ClsBaseDataInfo.sDataBaseName, tablenames, dts, dts.Rows.Count - 1);
                            aList.Add(sSQL);
                        }
                    }
                }
                #endregion
                if (iCount == 0)
                {
                    sErr = sErr + "表体不能为空\n";
                }
                if (sErr != "")
                {
                    throw new Exception(sErr);
                }
                if (aList.Count > 0)
                {
                    int iCou = clsSQLCommond.ExecSqlTran(aList);
                }
            }
            catch (Exception ee)
            {
                sErr = ee.Message;
            }
            if (sErr == "")
            {
                return("ok");
            }
            else
            {
                return(sErr);
            }
        }
Esempio n. 10
0
        public bool Insert(string iID, string S1, string S2, string S3, string S4, string S5, string S6, string S7, string S8, string S9, string S10, string S11, string S12, string S13, string S14, string S15,
                           string Date1, string Date2, string Date3, string Date4, string Date5,
                           string D1, string D2, string D3, string D4, string D5, string D6, string D7, string D8, string D9, string D10)
        {
            string    uid = Session["uID"].ToString();
            ArrayList arr = new ArrayList();
            Sql       sql = new Sql();

            if (iID == "" || iID == null)
            {
                sSQL = "select isnull(max(iID),0)+1 from  " + tablename + "";
                iID  = clsSQLCommond.ExecString(sSQL);
                sql.Get(tablename, "iID", iID, true);
                sql.ToString("dCreatesysTime", DateTime.Now);
                sql.ToString("dCreatesysPerson", uid);
            }
            else
            {
                sql.Get(tablename, "iID", iID, false);
                sql.ToString("dChangeVerifyTime", DateTime.Now);
                sql.ToString("dChangeVerifyPerson", uid);
            }
            sql.ToString("S1", S1);
            sql.ToString("S2", S2);
            sql.ToString("S3", S3);
            sql.ToString("S4", S4);
            sql.ToString("S5", S5);
            sql.ToString("S6", S6);
            sql.ToString("S7", S7);
            sql.ToString("S8", S8);
            sql.ToString("S9", S9);
            sql.ToString("S10", S10);
            sql.ToString("S11", S11);
            sql.ToString("S12", S12);
            sql.ToString("S13", S13);
            sql.ToString("S14", S14);
            sql.ToString("S15", S15);
            if (Date1 != "")
            {
                sql.ToString("Date1", DateTime.Parse(Date1));
            }
            else
            {
                sql.ToString("Date1", Date1);
            }
            if (Date2 != "")
            {
                sql.ToString("Date2", DateTime.Parse(Date2));
            }
            else
            {
                sql.ToString("Date2", Date2);
            }
            if (Date3 != "")
            {
                sql.ToString("Date3", DateTime.Parse(Date3));
            }
            else
            {
                sql.ToString("Date3", Date3);
            }
            if (Date4 != "")
            {
                sql.ToString("Date4", DateTime.Parse(Date4));
            }
            else
            {
                sql.ToString("Date4", Date4);
            }
            if (Date5 != "")
            {
                sql.ToString("Date5", DateTime.Parse(Date5));
            }
            else
            {
                sql.ToString("Date5", Date5);
            }
            if (D1 != "")
            {
                sql.ToString("D1", decimal.Parse(D1));
            }
            else
            {
                sql.ToString("D1", null);
            }
            if (D2 != "")
            {
                sql.ToString("D2", decimal.Parse(D2));
            }
            else
            {
                sql.ToString("D2", null);
            }
            if (D3 != "")
            {
                sql.ToString("D3", decimal.Parse(D3));
            }
            else
            {
                sql.ToString("D3", null);
            } if (D4 != "")
            {
                sql.ToString("D4", decimal.Parse(D4));
            }
            else
            {
                sql.ToString("D4", null);
            }
            if (D5 != "")
            {
                sql.ToString("D5", decimal.Parse(D5));
            }
            else
            {
                sql.ToString("D5", null);
            }
            if (D6 != "")
            {
                sql.ToString("D6", decimal.Parse(D6));
            }
            else
            {
                sql.ToString("D6", null);
            }
            if (D7 != "")
            {
                sql.ToString("D7", decimal.Parse(D7));
            }
            else
            {
                sql.ToString("D7", null);
            }
            if (D8 != "")
            {
                sql.ToString("D8", decimal.Parse(D8));
            }
            else
            {
                sql.ToString("D8", null);
            }
            if (D9 != "")
            {
                sql.ToString("D9", decimal.Parse(D9));
            }
            else
            {
                sql.ToString("D9", null);
            }
            if (D10 != "")
            {
                sql.ToString("D10", decimal.Parse(D10));
            }
            else
            {
                sql.ToString("D10", null);
            }
            arr.Add(sql.ReturnSql());
            bool b = clsSQLCommond.ExecSqlTran(arr);

            return(b);
        }
Esempio n. 11
0
        public string save(DataTable dtGrid)
        {
            string    sErr  = "";
            ArrayList aList = new ArrayList();

            try
            {
                sSQL = "select * from " + tablename + " where 1=-1";
                DataTable dt = clsSQLCommond.ExecQuery(sSQL);
                sSQL = "select isnull(max(iID)+1,1) as iID from " + tablename;
                long iID = Convert.ToInt64(clsSQLCommond.ExecGetScalar(sSQL));

                for (int i = 0; i < dtGrid.Rows.Count; i++)
                {
                    if (dtGrid.Rows[i]["iSave"].ToString().Trim() == "update" || dtGrid.Rows[i]["iSave"].ToString().Trim() == "add")
                    {
                        #region 判断
                        if (dtGrid.Rows[i][Code].ToString().Trim() == "" &&
                            dtGrid.Rows[i][Name].ToString().Trim() == "")
                        {
                            continue;
                        }
                        if (dtGrid.Rows[i][Code].ToString().Trim() == "")
                        {
                            sErr = sErr + "行" + (i + 1) + CodeTitle + "不能为空\n";
                            continue;
                        }


                        if (dtGrid.Rows[i][Name].ToString().Trim() == "")
                        {
                            sErr = sErr + "行" + (i + 1) + NameTitle + "不能为空\n";
                            continue;
                        }

                        //if (dtGrid.Rows[i]["cDepCode"].ToString().Trim() == "")
                        //{
                        //    sErr = sErr + "行" + (i + 1) +"部门不能为空\n";
                        //    continue;
                        //}
                        #endregion

                        #region 判断是否重复
                        for (int j = 0; j < i; j++)
                        {
                            if (dtGrid.Rows[i][Code].ToString().Trim() == dtGrid.Rows[j][Code].ToString().Trim())
                            {
                                sErr = sErr + "行" + (i + 1) + CodeTitle + "重复\n";
                                continue;
                            }
                        }

                        for (int j = 0; j < i; j++)
                        {
                            if (dtGrid.Rows[i][Name].ToString().Trim() == dtGrid.Rows[j][Name].ToString().Trim())
                            {
                                sErr = sErr + "行" + (i + 1) + NameTitle + "重复\n";
                                continue;
                            }
                        }
                        #endregion
                        #region 生成table
                        DataRow dr = dt.NewRow();
                        if (dtGrid.Rows[i]["iID"].ToString().Trim() != "")
                        {
                            dr["iID"] = dtGrid.Rows[i]["iID"];
                        }
                        else
                        {
                            dr["iID"] = iID;
                            iID       = iID + 1;
                        }
                        dr[Code] = dtGrid.Rows[i][Code].ToString().Trim();
                        dr[Name] = dtGrid.Rows[i][Name].ToString().Trim();

                        dr["cDepCode"]  = dtGrid.Rows[i]["cDepCode"].ToString().Trim();
                        dr["SexID"]     = dtGrid.Rows[i]["SexID"].ToString().Trim();
                        dr["cDCCode"]   = dtGrid.Rows[i]["cDCCode"].ToString().Trim();
                        dr["BeginDate"] = dtGrid.Rows[i]["BeginDate"];
                        dr["EndDate"]   = dtGrid.Rows[i]["EndDate"];
                        dt.Rows.Add(dr);

                        if (dtGrid.Rows[i]["isUserInfo"].ToString().Trim() == "")
                        {
                            dr["isUserInfo"] = 0;
                        }
                        else
                        {
                            dr["isUserInfo"] = dtGrid.Rows[i]["isUserInfo"].ToString().Trim();
                        }

                        #endregion

                        if (dtGrid.Rows[i]["iSave"].ToString().Trim() == "update")
                        {
                            sSQL = clsGetSQL.GetUpdateSQL(ClsBaseDataInfo.sDataBaseName, tablename, dt, dt.Rows.Count - 1);
                            aList.Add(sSQL);
                        }
                        if (dtGrid.Rows[i]["iSave"].ToString().Trim() == "add")
                        {
                            sSQL = clsGetSQL.GetInsertSQL(ClsBaseDataInfo.sDataBaseName, tablename, dt, dt.Rows.Count - 1);
                            aList.Add(sSQL);
                        }
                        if (dtGrid.Rows[i]["isUserInfo"].ToString().Trim() == "True")
                        {
                            sSQL = @"IF EXISTS(select vchrUid From _UserInfo  with (XLOCK) Where  vchrUid='" + dtGrid.Rows[i][Code].ToString().Trim() + "') " +
                                   " update _UserInfo set vchrName='" + dtGrid.Rows[i][Name].ToString().Trim() + "' Where  vchrUid='" + dtGrid.Rows[i][Code].ToString().Trim() + "'" +
                                   " else insert into _UserInfo(vchrUid,vchrName,vchrPwd) values('" + dtGrid.Rows[i][Code].ToString().Trim() + "','" + dtGrid.Rows[i][Name].ToString().Trim() + "','ADBF8135A642B58A')";
                            aList.Add(sSQL);
                        }
                    }
                }
                if (sErr != "")
                {
                    throw new Exception(sErr);
                }
                if (aList.Count > 0)
                {
                    int iCou = clsSQLCommond.ExecSqlTran(aList);
                }
            }
            catch (Exception ee)
            {
                sErr = ee.Message;
            }
            if (sErr == "")
            {
                return("ok");
            }
            else
            {
                return(sErr);
            }
        }
Esempio n. 12
0
        public string save(DataTable dtGrid)
        {
            string    sErr  = "";
            ArrayList aList = new ArrayList();

            try
            {
                sSQL = "select * from " + tablename + " where 1=-1";
                DataTable dt = clsSQLCommond.ExecQuery(sSQL);

                for (int i = 0; i < dtGrid.Rows.Count; i++)
                {
                    if (dtGrid.Rows[i]["iSave"].ToString().Trim() == "update" || dtGrid.Rows[i]["iSave"].ToString().Trim() == "add")
                    {
                        #region 判断
                        if (dtGrid.Rows[i][Code].ToString().Trim() == "")
                        {
                            continue;
                        }
                        if (dtGrid.Rows[i][Code].ToString().Trim() == "")
                        {
                            sErr = sErr + "行" + (i + 1) + CodeTitle + "不能为空\n";
                            continue;
                        }
                        #endregion

                        #region 判断是否重复
                        for (int j = 0; j < i; j++)
                        {
                            if (dtGrid.Rows[i][Code].ToString().Trim() == dtGrid.Rows[j][Code].ToString().Trim())
                            {
                                sErr = sErr + "行" + (i + 1) + CodeTitle + "重复\n";
                                continue;
                            }
                        }
                        #endregion
                        #region 生成table
                        DataRow dr = dt.NewRow();
                        dr[Code] = dtGrid.Rows[i][Code].ToString().Trim();
                        dr["B2"] = dtGrid.Rows[i]["B2"].ToString().Trim();
                        dr["B1"] = dtGrid.Rows[i]["B1"].ToString().Trim();
                        dr["S1"] = dtGrid.Rows[i]["S1"].ToString().Trim();
                        dr["S2"] = dtGrid.Rows[i]["S2"].ToString().Trim();
                        dr["S3"] = dtGrid.Rows[i]["S3"].ToString().Trim();
                        dr["S4"] = dtGrid.Rows[i]["S4"].ToString().Trim();
                        dr["S5"] = dtGrid.Rows[i]["S5"].ToString().Trim();
                        dr["S6"] = dtGrid.Rows[i]["S6"].ToString().Trim();
                        dr["S7"] = dtGrid.Rows[i]["S7"].ToString().Trim();
                        dr["S8"] = dtGrid.Rows[i]["S8"].ToString().Trim();
                        dr["S9"] = dtGrid.Rows[i]["S9"].ToString().Trim();
                        dt.Rows.Add(dr);
                        #endregion

                        if (dtGrid.Rows[i]["iSave"].ToString().Trim() == "update")
                        {
                            sSQL = clsGetSQL.GetUpdateSQL(ClsBaseDataInfo.sDataBaseName, tablename, dt, dt.Rows.Count - 1);
                            aList.Add(sSQL);
                        }
                        if (dtGrid.Rows[i]["iSave"].ToString().Trim() == "add")
                        {
                            sSQL = clsGetSQL.GetInsertSQL(ClsBaseDataInfo.sDataBaseName, tablename, dt, dt.Rows.Count - 1);
                            aList.Add(sSQL);
                        }
                    }
                }
                if (sErr != "")
                {
                    throw new Exception(sErr);
                }
                if (aList.Count > 0)
                {
                    int iCou = clsSQLCommond.ExecSqlTran(aList);
                }
            }
            catch (Exception ee)
            {
                sErr = ee.Message;
            }
            if (sErr == "")
            {
                return("ok");
            }
            else
            {
                return(sErr);
            }
        }