示例#1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        Controler myControler = new Controler();

        myControler.setStartControl();
        string[] _UnitList = new string[] { "", "基金會", "台北至德", "台中至德", "", "高雄至德" };

        loginInfo.InnerHtml = myControler._Header_Info_innerString;
        string Unit = "";

        if (!string.IsNullOrEmpty(Context.Request.QueryString["id"]))
        {
            AspAjax Ajax = new AspAjax();
            CreatePropertyRecord myRecord = Ajax.getPropertyRecordDataBase(Context.Request.QueryString["id"].ToString());
            Unit            = myRecord.Unit;
            sUnit.InnerHtml = _UnitList[int.Parse(Unit)];
        }
        else
        {
            Unit            = "0";
            sUnit.InnerHtml = myControler._Staff_UnitName;
        }
        List <string[]> Location = myControler.PropertyLocation(Unit);

        propertyLocation.Items.Add(new ListItem("請選擇", "0"));
        foreach (string[] atom in Location)
        {
            //inner += "<option value='" + atom[0] + "'>" + atom[1] + "</option>";
            propertyLocation.Items.Add(new ListItem(atom[1], atom[0]));
            gosrhLocation.Items.Add(new ListItem(atom[1], atom[0]));
        }

        List <string[]> CustodyData = myControler.getPropertyCustodyData(Unit);

        propertyCustody.Items.Add(new ListItem("請選擇", "0"));
        foreach (string[] atom in CustodyData)
        {
            //inner += "<option value='" + atom[0] + "'>" + atom[1] + "</option>";
            propertyCustody.Items.Add(new ListItem(atom[1], atom[0]));
            gosrhCustody.Items.Add(new ListItem(atom[1], atom[0]));
        }

        //
        // _uId = result[0];
        // _uName = result[1];
        // _uUnit = parseInt(result[2], 10);

        /*
         * $("#Unit").html(_UnitList[_uUnit]);
         * isLogin = true;
         * var today = new Date();
         * var weekArray = new Array("星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六");
         * $("#loginInfo").html("今天是" + (today.getFullYear() - 1911) + "年" + (today.getMonth() + 1) + "月" + today.getDate() + "日 " + weekArray[today.getDay()] + " 歡迎 " + _uName + " 使用本系統  <a href='#' id='logout'>登出</a>");
         * $("#logout").click(function() {
         *  AspAjax.Logout(SucceededCallbackAll);
         * });
         *
         * AspAjax.getStaffRoles(result[0],SucceededCallbackAll);
         * */
    }
 public CreatePropertyRecord getPropertyRecordDataBase(string ID)
 {
     CreatePropertyRecord returnValue = new CreatePropertyRecord();
     DataBase Base = new DataBase();
     using (SqlConnection Sqlconn = new SqlConnection(Base.GetConnString()))
     {
         try
         {
             Sqlconn.Open();
             string sql = "SELECT PropertyRecord.*, StaffDatabase.StaffName FROM PropertyRecord " +
              "LEFT JOIN StaffDatabase ON PropertyRecord.Procurement=StaffDatabase.StaffID " +
              "WHERE PropertyRecord.isDeleted=0 AND PropertyRecord.RecordID=@RecordID";
             SqlCommand cmd = new SqlCommand(sql, Sqlconn);
             cmd.Parameters.Add("@RecordID", SqlDbType.BigInt).Value = Chk.CheckStringtoInt64Function(ID);
             SqlDataReader dr = cmd.ExecuteReader();
             while (dr.Read())
             {
                 returnValue.repairID = dr["RecordID"].ToString();
                 returnValue.Unit = dr["Unit"].ToString();
                 returnValue.fillInDate = DateTime.Parse(dr["WriteDate"].ToString()).ToString("yyyy-MM-dd");
                 returnValue.propertyStatus = dr["PropertyState"].ToString();
                 returnValue.propertyChange = dr["PropertyAddImpairment"].ToString();
                 returnValue.changeStatus = dr["PropertyChangeState"].ToString();
                 returnValue.propertyID = dr["PropertyID"].ToString();
                 returnValue.propertyCode = dr["Code"].ToString();
                 returnValue.applyID = dr["ApplyID"].ToString();
                 returnValue.propertyCategory = dr["Category"].ToString();
                 returnValue.propertyName = dr["PropertyName"].ToString();
                 returnValue.propertyLabel = dr["Label"].ToString();
                 returnValue.propertyUnit = dr["ItemUnit"].ToString();
                 returnValue.propertyQuantity = dr["Quantity"].ToString();
                 returnValue.propertyFitting = dr["Fitting"].ToString();
                 returnValue.propertyLocation = dr["Location"].ToString();
                 returnValue.propertyCustody = dr["Custody"].ToString();
                 returnValue.stopDate = DateTime.Parse(dr["ScrapDate"].ToString()).ToString("yyyy-MM-dd");
                 returnValue.propertySummons = dr["Summons"].ToString();
                 returnValue.propertyReceipt = dr["Receipt"].ToString();
                 returnValue.propertyAccounting = dr["Accounting"].ToString();
                 returnValue.inputDate = DateTime.Parse(dr["RecordedDate"].ToString()).ToString("yyyy-MM-dd");
                 returnValue.outputDate = DateTime.Parse(dr["OutDate"].ToString()).ToString("yyyy-MM-dd");
                 returnValue.fundSource = dr["FundSource"].ToString();
                 returnValue.fundAssist = dr["FundSourceAssist"].ToString();
                 returnValue.fundDonate = dr["FundSourceDonate"].ToString();
                 returnValue.buyDate = DateTime.Parse(dr["PurchaseDate"].ToString()).ToString("yyyy-MM-dd");
                 returnValue.Remnants = dr["Residual"].ToString();
                 returnValue.buySource = dr["PurchaseSource"].ToString();
                 returnValue.userYear = dr["ExpirationDate"].ToString();
                 returnValue.propertyPrice = dr["Price"].ToString();
                 returnValue.Depreciation = dr["Depreciation"].ToString();
                 returnValue.selfFunds = dr["SinceFundraising"].ToString();
                 returnValue.Purchaser = dr["Procurement"].ToString();
                 returnValue.PurchaserName = dr["StaffName"].ToString();
                 returnValue.Grant = dr["Grants"].ToString();
                 returnValue.Remark = dr["Remark"].ToString();
                 returnValue.attachment1 = dr["Annex1"].ToString();
                 returnValue.attachment2 = dr["Annex2"].ToString();
                 returnValue.attachment3 = dr["Annex3"].ToString();
                 returnValue.attachment4 = dr["Annex4"].ToString();
                 returnValue.attachment5 = dr["Annex5"].ToString();
                 returnValue.attachment6 = dr["Annex6"].ToString();
                 returnValue.attachment7 = dr["Annex7"].ToString();
                 returnValue.attachment8 = dr["Annex8"].ToString();
                 returnValue.ChangesArray = new List<PropertyChangesExplainData>();
                 //returnValue.checkNo = "1";
             }
             dr.Close();
             sql = "SELECT PropertyChangesExplain.*, StaffDatabase.StaffName FROM PropertyChangesExplain " +
             "INNER JOIN StaffDatabase ON PropertyChangesExplain.RelatedPersonnel=StaffDatabase.StaffID " +
             "WHERE PropertyChangesExplain.isDeleted=0 AND PropertyChangesExplain.RecordID=@RecordID";
             cmd = new SqlCommand(sql, Sqlconn);
             cmd.Parameters.Add("@RecordID", SqlDbType.BigInt).Value = Chk.CheckStringtoInt64Function(ID);
             dr = cmd.ExecuteReader();
             while (dr.Read())
             {
                 PropertyChangesExplainData addValue = new PropertyChangesExplainData();
                 addValue.cID = dr["ID"].ToString();
                 addValue.recordID = dr["RecordID"].ToString();
                 addValue.moveDate = DateTime.Parse(dr["ChangeDate"].ToString()).ToString("yyyy-MM-dd");
                 addValue.moveAbstract = dr["Summary"].ToString();
                 addValue.relatedByID = dr["RelatedPersonnel"].ToString();
                 addValue.relatedBy = dr["StaffName"].ToString();
                 returnValue.ChangesArray.Add(addValue);
             }
             dr.Close();
             Sqlconn.Close();
         }
         catch (Exception e)
         {
             returnValue.checkNo = "-1";
             returnValue.errorMsg = e.Message.ToString();
         }
     }
     return returnValue;
 }
    public string[] createPropertyRecordData(CreatePropertyRecord propertyRecordData)
    {
        string[] returnValue = new string[2];
        returnValue[0] = "0";
        returnValue[1] = "0";
        DataBase Base = new DataBase();
        using (SqlConnection Sqlconn = new SqlConnection(Base.GetConnString()))
        {
            try
            {
                StaffDataBase sDB = new StaffDataBase();
                List<string> CreateFileName = sDB.getStaffDataName(HttpContext.Current.User.Identity.Name);
                Sqlconn.Open();
                string sql = "INSERT INTO PropertyRecord (WriteDate, Unit, PropertyState, PropertyAddImpairment, PropertyChangeState, PropertyID, " +
                    "Code, ApplyID, Category, PropertyName, Label, ItemUnit, Quantity, Fitting, Location, Custody, ScrapDate, " +
                    "Summons, Receipt, Accounting, RecordedDate, OutDate, FundSource, FundSourceAssist, FundSourceDonate, PurchaseDate, " +
                    "Residual, PurchaseSource, ExpirationDate, Price, Depreciation, SinceFundraising, Procurement, Grants, Remark, " +
                    "CreateFileBy, CreateFileDate, UpFileBy, UpFileDate, isDeleted) VALUES " +
                    "(@WriteDate, @Unit, @PropertyState, @PropertyAddImpairment, @PropertyChangeState, @PropertyID, " +
                    "@Code, @ApplyID, @Category, @PropertyName, @Label, @ItemUnit, @Quantity, @Fitting, @Location, @Custody, @ScrapDate, " +
                    "@Summons, @Receipt, @Accounting, @RecordedDate, @OutDate, @FundSource, @FundSourceAssist, @FundSourceDonate, @PurchaseDate, " +
                    "@Residual, @PurchaseSource, @ExpirationDate, @Price, @Depreciation, @SinceFundraising, @Procurement, @Grants, @Remark, " +
                    "@CreateFileBy, (getDate()), @UpFileBy, (getDate()), 0)";
                SqlCommand cmd = new SqlCommand(sql, Sqlconn);
                cmd.Parameters.Add("@WriteDate", SqlDbType.Date).Value = Chk.CheckStringtoDateFunction(propertyRecordData.fillInDate);
                cmd.Parameters.Add("@Unit", SqlDbType.TinyInt).Value = Chk.CheckStringtoIntFunction(CreateFileName[2]);
                cmd.Parameters.Add("@PropertyState", SqlDbType.TinyInt).Value = Chk.CheckStringtoIntFunction(propertyRecordData.propertyStatus);
                cmd.Parameters.Add("@PropertyAddImpairment", SqlDbType.TinyInt).Value = Chk.CheckStringtoIntFunction(propertyRecordData.propertyChange);
                cmd.Parameters.Add("@PropertyChangeState", SqlDbType.TinyInt).Value = Chk.CheckStringtoIntFunction(propertyRecordData.changeStatus);
                cmd.Parameters.Add("@PropertyID", SqlDbType.NVarChar).Value = Chk.CheckStringFunction(propertyRecordData.propertyID);
                cmd.Parameters.Add("@Code", SqlDbType.Int).Value = Chk.CheckStringtoIntFunction(propertyRecordData.propertyCode);
                cmd.Parameters.Add("@ApplyID", SqlDbType.Int).Value = Chk.CheckStringtoIntFunction(propertyRecordData.applyID);
                cmd.Parameters.Add("@Category", SqlDbType.Int).Value = Chk.CheckStringtoIntFunction(propertyRecordData.propertyCategory);
                cmd.Parameters.Add("@PropertyName", SqlDbType.NVarChar).Value = Chk.CheckStringFunction(propertyRecordData.propertyName);
                cmd.Parameters.Add("@Label", SqlDbType.NVarChar).Value = Chk.CheckStringFunction(propertyRecordData.propertyLabel);
                cmd.Parameters.Add("@ItemUnit", SqlDbType.NVarChar).Value = Chk.CheckStringFunction(propertyRecordData.propertyUnit);
                cmd.Parameters.Add("@Quantity", SqlDbType.Int).Value = Chk.CheckStringtoIntFunction(propertyRecordData.propertyQuantity);
                cmd.Parameters.Add("@Fitting", SqlDbType.TinyInt).Value = Chk.CheckStringtoIntFunction(propertyRecordData.propertyFitting);
                cmd.Parameters.Add("@Location", SqlDbType.Int).Value = Chk.CheckStringtoIntFunction(propertyRecordData.propertyLocation);
                cmd.Parameters.Add("@Custody", SqlDbType.Int).Value = Chk.CheckStringtoIntFunction(propertyRecordData.propertyCustody);
                cmd.Parameters.Add("@ScrapDate", SqlDbType.Date).Value = Chk.CheckStringtoDateFunction(propertyRecordData.stopDate);
                cmd.Parameters.Add("@Summons", SqlDbType.NVarChar).Value = Chk.CheckStringFunction(propertyRecordData.propertySummons);
                cmd.Parameters.Add("@Receipt", SqlDbType.NVarChar).Value = Chk.CheckStringFunction(propertyRecordData.propertyReceipt);
                cmd.Parameters.Add("@Accounting", SqlDbType.NVarChar).Value = Chk.CheckStringFunction(propertyRecordData.propertyAccounting);
                cmd.Parameters.Add("@RecordedDate", SqlDbType.Date).Value = Chk.CheckStringtoDateFunction(propertyRecordData.inputDate);
                cmd.Parameters.Add("@OutDate", SqlDbType.Date).Value = Chk.CheckStringtoDateFunction(propertyRecordData.outputDate);
                cmd.Parameters.Add("@FundSource", SqlDbType.TinyInt).Value = Chk.CheckStringtoIntFunction(propertyRecordData.fundSource);
                cmd.Parameters.Add("@FundSourceAssist", SqlDbType.NVarChar).Value = Chk.CheckStringFunction(propertyRecordData.fundAssist);
                cmd.Parameters.Add("@FundSourceDonate", SqlDbType.NVarChar).Value = Chk.CheckStringFunction(propertyRecordData.fundDonate);
                cmd.Parameters.Add("@PurchaseDate", SqlDbType.Date).Value = Chk.CheckStringtoDateFunction(propertyRecordData.buyDate);
                cmd.Parameters.Add("@Residual", SqlDbType.NVarChar).Value = Chk.CheckStringFunction(propertyRecordData.Remnants);
                cmd.Parameters.Add("@PurchaseSource", SqlDbType.NVarChar).Value = Chk.CheckStringFunction(propertyRecordData.buySource);
                cmd.Parameters.Add("@ExpirationDate", SqlDbType.NVarChar).Value = Chk.CheckStringFunction(propertyRecordData.userYear);
                cmd.Parameters.Add("@Price", SqlDbType.Int).Value = Chk.CheckStringtoIntFunction(propertyRecordData.propertyPrice);
                cmd.Parameters.Add("@Depreciation", SqlDbType.NVarChar).Value = Chk.CheckStringFunction(propertyRecordData.Depreciation);
                cmd.Parameters.Add("@SinceFundraising", SqlDbType.Int).Value = Chk.CheckStringtoIntFunction(propertyRecordData.selfFunds);
                cmd.Parameters.Add("@Procurement", SqlDbType.Int).Value = Chk.CheckStringtoIntFunction(propertyRecordData.Purchaser);
                cmd.Parameters.Add("@Grants", SqlDbType.Int).Value = Chk.CheckStringtoIntFunction(propertyRecordData.Grant);
                cmd.Parameters.Add("@Remark", SqlDbType.NVarChar).Value = Chk.CheckStringFunction(propertyRecordData.Remark);
                cmd.Parameters.Add("@CreateFileBy", SqlDbType.Int).Value = Chk.CheckStringtoIntFunction(CreateFileName[0]);
                cmd.Parameters.Add("@UpFileBy", SqlDbType.Int).Value = Chk.CheckStringtoIntFunction(CreateFileName[0]);

                returnValue[0] = cmd.ExecuteNonQuery().ToString();
                if (returnValue[0] != "0")
                {
                    string FieldName = "PropertDB_" + CreateFileName[2];
                    sql = "SELECT IDENT_CURRENT('PropertyRecord') AS pID " +
                          "UPDATE AutomaticNumberTable SET " + FieldName + "=" + FieldName + "+1 WHERE ID=1 ";
                    cmd = new SqlCommand(sql, Sqlconn);
                    SqlDataReader dr = cmd.ExecuteReader();
                    while (dr.Read())
                    {
                        returnValue[1] = dr["pID"].ToString();
                    }
                    dr.Close();

                    /*sql = "SELECT Count(*) AS QCOUNT FROM PropertyRecord WHERE isDeleted=0";
                    cmd = new SqlCommand(sql, Sqlconn);
                    string stuNumber = cmd.ExecuteScalar().ToString();
                    string stuIDName = CreateFileName[2] + stuNumber.PadLeft(4, '0');*/
                    CaseDataBase SDB = new CaseDataBase();
                    string stuNumber = SDB.getUnitAutoNumber(FieldName);
                    string stuIDName = CreateFileName[2] + stuNumber.PadLeft(4, '0');

                    sql = "UPDATE PropertyRecord SET Code=(@Code), UpFileBy=@UpFileBy, UpFileDate=(getDate()) WHERE RecordID=(@RecordID) AND isDeleted=0";
                    cmd = new SqlCommand(sql, Sqlconn);
                    cmd.Parameters.Add("@RecordID", SqlDbType.BigInt).Value = Chk.CheckStringtoInt64Function(returnValue[1]);
                    cmd.Parameters.Add("@Code", SqlDbType.Int).Value = Chk.CheckStringtoIntFunction(stuIDName);
                    cmd.Parameters.Add("@UpFileBy", SqlDbType.Int).Value = Chk.CheckStringtoIntFunction(CreateFileName[0]);
                    returnValue[0] = cmd.ExecuteNonQuery().ToString();
                }
                Sqlconn.Close();
            }
            catch (Exception e)
            {
                returnValue[0] = "-1";
                returnValue[1] = e.Message.ToString();
            }
        }
        return returnValue;
    }
 public string[] setPropertyRecordDataBase(CreatePropertyRecord propertyRecordData)
 {
     string[] returnValue = new string[2];
     returnValue[0] = "0";
     returnValue[1] = "0";
     DataBase Base = new DataBase();
     SqlConnection Sqlconn = new SqlConnection(Base.GetConnString());
     using (Sqlconn)
     {
         try
         {
             StaffDataBase sDB = new StaffDataBase();
             List<string> CreateFileName = sDB.getStaffDataName(HttpContext.Current.User.Identity.Name);
             Sqlconn.Open();
             string sql = "UPDATE PropertyRecord SET WriteDate=@WriteDate, PropertyState=@PropertyState, PropertyAddImpairment=@PropertyAddImpairment, " +
                 "PropertyChangeState=@PropertyChangeState, PropertyID=@PropertyID, Code=@Code, ApplyID=@ApplyID, Category=@Category, " +
                 "PropertyName=@PropertyName, Label=@Label, ItemUnit=@ItemUnit, Quantity=@Quantity, Fitting=@Fitting, Location=@Location, " +
                 "Custody=@Custody, ScrapDate=@ScrapDate, Summons=@Summons, Receipt=@Receipt, Accounting=@Accounting, RecordedDate=@RecordedDate, " +
                 "OutDate=@OutDate, FundSource=@FundSource, FundSourceAssist=@FundSourceAssist, FundSourceDonate=@FundSourceDonate, PurchaseDate=@PurchaseDate, " +
                 "Residual=@Residual, PurchaseSource=@PurchaseSource, ExpirationDate=@ExpirationDate, Price=@Price, Depreciation=@Depreciation, " +
                 "SinceFundraising=@SinceFundraising, Procurement=@Procurement, Grants=@Grants, Remark=@Remark, UpFileBy=@UpFileBy, UpFileDate=(getDate()) " +
                 "WHERE RecordID=@RecordID AND isDeleted=0";
             SqlCommand cmd = new SqlCommand(sql, Sqlconn);
             cmd.Parameters.Add("@RecordID", SqlDbType.BigInt).Value = Chk.CheckStringtoIntFunction(propertyRecordData.repairID);
             cmd.Parameters.Add("@WriteDate", SqlDbType.Date).Value = Chk.CheckStringtoDateFunction(propertyRecordData.fillInDate);
             cmd.Parameters.Add("@PropertyState", SqlDbType.TinyInt).Value = Chk.CheckStringtoIntFunction(propertyRecordData.propertyStatus);
             cmd.Parameters.Add("@PropertyAddImpairment", SqlDbType.TinyInt).Value = Chk.CheckStringtoIntFunction(propertyRecordData.propertyChange);
             cmd.Parameters.Add("@PropertyChangeState", SqlDbType.TinyInt).Value = Chk.CheckStringtoIntFunction(propertyRecordData.changeStatus);
             cmd.Parameters.Add("@PropertyID", SqlDbType.NVarChar).Value = Chk.CheckStringFunction(propertyRecordData.propertyID);
             cmd.Parameters.Add("@Code", SqlDbType.Int).Value = Chk.CheckStringtoIntFunction(propertyRecordData.propertyCode);
             cmd.Parameters.Add("@ApplyID", SqlDbType.Int).Value = Chk.CheckStringtoIntFunction(propertyRecordData.applyID);
             cmd.Parameters.Add("@Category", SqlDbType.Int).Value = Chk.CheckStringtoIntFunction(propertyRecordData.propertyCategory);
             cmd.Parameters.Add("@PropertyName", SqlDbType.NVarChar).Value = Chk.CheckStringFunction(propertyRecordData.propertyName);
             cmd.Parameters.Add("@Label", SqlDbType.NVarChar).Value = Chk.CheckStringFunction(propertyRecordData.propertyLabel);
             cmd.Parameters.Add("@ItemUnit", SqlDbType.NVarChar).Value = Chk.CheckStringFunction(propertyRecordData.propertyUnit);
             cmd.Parameters.Add("@Quantity", SqlDbType.Int).Value = Chk.CheckStringtoIntFunction(propertyRecordData.propertyQuantity);
             cmd.Parameters.Add("@Fitting", SqlDbType.TinyInt).Value = Chk.CheckStringtoIntFunction(propertyRecordData.propertyFitting);
             cmd.Parameters.Add("@Location", SqlDbType.Int).Value = Chk.CheckStringtoIntFunction(propertyRecordData.propertyLocation);
             cmd.Parameters.Add("@Custody", SqlDbType.Int).Value = Chk.CheckStringtoIntFunction(propertyRecordData.propertyCustody);
             cmd.Parameters.Add("@ScrapDate", SqlDbType.Date).Value = Chk.CheckStringtoDateFunction(propertyRecordData.stopDate);
             cmd.Parameters.Add("@Summons", SqlDbType.NVarChar).Value = Chk.CheckStringFunction(propertyRecordData.propertySummons);
             cmd.Parameters.Add("@Receipt", SqlDbType.NVarChar).Value = Chk.CheckStringFunction(propertyRecordData.propertyReceipt);
             cmd.Parameters.Add("@Accounting", SqlDbType.NVarChar).Value = Chk.CheckStringFunction(propertyRecordData.propertyAccounting);
             cmd.Parameters.Add("@RecordedDate", SqlDbType.Date).Value = Chk.CheckStringtoDateFunction(propertyRecordData.inputDate);
             cmd.Parameters.Add("@OutDate", SqlDbType.Date).Value = Chk.CheckStringtoDateFunction(propertyRecordData.outputDate);
             cmd.Parameters.Add("@FundSource", SqlDbType.TinyInt).Value = Chk.CheckStringtoIntFunction(propertyRecordData.fundSource);
             cmd.Parameters.Add("@FundSourceAssist", SqlDbType.NVarChar).Value = Chk.CheckStringFunction(propertyRecordData.fundAssist);
             cmd.Parameters.Add("@FundSourceDonate", SqlDbType.NVarChar).Value = Chk.CheckStringFunction(propertyRecordData.fundDonate);
             cmd.Parameters.Add("@PurchaseDate", SqlDbType.Date).Value = Chk.CheckStringtoDateFunction(propertyRecordData.buyDate);
             cmd.Parameters.Add("@Residual", SqlDbType.NVarChar).Value = Chk.CheckStringFunction(propertyRecordData.Remnants);
             cmd.Parameters.Add("@PurchaseSource", SqlDbType.NVarChar).Value = Chk.CheckStringFunction(propertyRecordData.buySource);
             cmd.Parameters.Add("@ExpirationDate", SqlDbType.NVarChar).Value = Chk.CheckStringFunction(propertyRecordData.userYear);
             cmd.Parameters.Add("@Price", SqlDbType.Int).Value = Chk.CheckStringtoIntFunction(propertyRecordData.propertyPrice);
             cmd.Parameters.Add("@Depreciation", SqlDbType.NVarChar).Value = Chk.CheckStringFunction(propertyRecordData.Depreciation);
             cmd.Parameters.Add("@SinceFundraising", SqlDbType.Int).Value = Chk.CheckStringtoIntFunction(propertyRecordData.selfFunds);
             cmd.Parameters.Add("@Procurement", SqlDbType.Int).Value = Chk.CheckStringtoIntFunction(propertyRecordData.Purchaser);
             cmd.Parameters.Add("@Grants", SqlDbType.Int).Value = Chk.CheckStringtoIntFunction(propertyRecordData.Grant);
             cmd.Parameters.Add("@Remark", SqlDbType.NVarChar).Value = Chk.CheckStringFunction(propertyRecordData.Remark);
             cmd.Parameters.Add("@UpFileBy", SqlDbType.Int).Value = Chk.CheckStringtoIntFunction(CreateFileName[0]);
             returnValue[0] = cmd.ExecuteNonQuery().ToString();
             returnValue[1] = propertyRecordData.repairID;
             Sqlconn.Close();
         }
         catch (Exception e)
         {
             returnValue[0] = "-1";
             returnValue[1] = e.Message;
         }
     }
     return returnValue;
 }
    public string[] setPropertyAnnexDataBase(CreatePropertyRecord propertyRecordData)
    {
        string[] returnValue = new string[2];
        returnValue[0] = "0";
        returnValue[1] = "0";
        string PicUpdatestring = "";
        if (propertyRecordData.attachment1 != null)
        {
            PicUpdatestring += "Annex1=@Annex1, ";
        }
        if (propertyRecordData.attachment2 != null)
        {
            PicUpdatestring += "Annex2=@Annex2, ";
        }
        if (propertyRecordData.attachment3 != null)
        {
            PicUpdatestring += "Annex3=@Annex3, ";
        }
        if (propertyRecordData.attachment4 != null)
        {
            PicUpdatestring += "Annex4=@Annex4, ";
        }
        if (propertyRecordData.attachment5 != null)
        {
            PicUpdatestring += "Annex5=@Annex5, ";
        }
        if (propertyRecordData.attachment6 != null)
        {
            PicUpdatestring += "Annex6=@Annex6, ";
        }
        if (propertyRecordData.attachment7 != null)
        {
            PicUpdatestring += "Annex7=@Annex7, ";
        }
        if (propertyRecordData.attachment8 != null)
        {
            PicUpdatestring += "Annex8=@Annex8, ";
        }

        DataBase Base = new DataBase();
        SqlConnection Sqlconn = new SqlConnection(Base.GetConnString());
        using (Sqlconn)
        {
            try
            {
                StaffDataBase sDB = new StaffDataBase();
                List<string> CreateFileName = sDB.getStaffDataName(HttpContext.Current.User.Identity.Name);
                Sqlconn.Open();
                string sql = "UPDATE PropertyRecord SET " + PicUpdatestring + "UpFileBy=@UpFileBy, UpFileDate=(getDate()) " +
                            "WHERE RecordID=@RecordID AND isDeleted=0";
                SqlCommand cmd = new SqlCommand(sql, Sqlconn);
                cmd.Parameters.Add("@RecordID", SqlDbType.BigInt).Value = Chk.CheckStringtoInt64Function(propertyRecordData.repairID);
                cmd.Parameters.Add("@Annex1", SqlDbType.NVarChar).Value = Chk.CheckStringFunction(propertyRecordData.attachment1);
                cmd.Parameters.Add("@Annex2", SqlDbType.NVarChar).Value = Chk.CheckStringFunction(propertyRecordData.attachment2);
                cmd.Parameters.Add("@Annex3", SqlDbType.NVarChar).Value = Chk.CheckStringFunction(propertyRecordData.attachment3);
                cmd.Parameters.Add("@Annex4", SqlDbType.NVarChar).Value = Chk.CheckStringFunction(propertyRecordData.attachment4);
                cmd.Parameters.Add("@Annex5", SqlDbType.NVarChar).Value = Chk.CheckStringFunction(propertyRecordData.attachment5);
                cmd.Parameters.Add("@Annex6", SqlDbType.NVarChar).Value = Chk.CheckStringFunction(propertyRecordData.attachment6);
                cmd.Parameters.Add("@Annex7", SqlDbType.NVarChar).Value = Chk.CheckStringFunction(propertyRecordData.attachment7);
                cmd.Parameters.Add("@Annex8", SqlDbType.NVarChar).Value = Chk.CheckStringFunction(propertyRecordData.attachment8);
                cmd.Parameters.Add("@UpFileBy", SqlDbType.Int).Value = Chk.CheckStringtoIntFunction(CreateFileName[0]);
                returnValue[0] = cmd.ExecuteNonQuery().ToString();
                returnValue[1] = propertyRecordData.repairID;
                Sqlconn.Close();
            }
            catch (Exception e)
            {
                returnValue[0] = "-1";
                returnValue[1] = e.Message;
            }
        }
        return returnValue;
    }
示例#6
0
 public string[] setPropertyRecordDataBase(CreatePropertyRecord propertyRecordData)
 {
     PropertyDataBase pDB = new PropertyDataBase();
     pDB.propertyFunction();
     if (int.Parse(pDB._StaffhaveRoles[1]) == 1)
     {
         return pDB.setPropertyRecordDataBase(propertyRecordData);
     }
     else
     {
         return new string[2] { _noRole, _errorMsg };
     }
 }
示例#7
0
 public CreatePropertyRecord getPropertyRecordDataBase(string ID)
 {
     PropertyDataBase pDB = new PropertyDataBase();
     CreatePropertyRecord returnValue = new CreatePropertyRecord();
     pDB.propertyFunction();
     if (int.Parse(pDB._StaffhaveRoles[3]) == 1)
     {
         returnValue= pDB.getPropertyRecordDataBase(ID);
     }
     else
     {
         returnValue.checkNo = _noRole;
         returnValue.errorMsg = _errorMsg;
     }
     StaffDataBase sDB = new StaffDataBase();
     List<string> UserFile = sDB.getStaffDataName(HttpContext.Current.User.Identity.Name);
     if (returnValue.Unit != UserFile[2] && int.Parse(pDB._StaffhaveRoles[4]) == 0 && UserFile[1].Length > 0)
     {
         returnValue.checkNo = _getcheckNo;
         returnValue.errorMsg = _errorMsg;
     }
     return returnValue;
 }