private void saveBtn_Click(object sender, EventArgs e)
        {
            CheckBeforeSave();

            object CoorTranName = tranNameTxtEdit.Text,
                   Accuracy     = AccurCalcEdit.EditValue,
                   WKID         = WKIDCalcEdit.EditValue,
                   AreaofUse    = useAreaTxtEdit.Text,
            //Method = tranMethodTxtEdit.Text,

                   MaximumLatitude  = maxLatCalcEdit.EditValue,
                   MinimumLatitude  = minLatCalcEdit.EditValue,
                   MaximumLongitude = maxLonCalcEdit.EditValue,
                   MinimumLongitude = minLonCalcEdit.EditValue,

                   dx          = dxCalcEdit.EditValue,
                   dy          = dyCalcEdit.EditValue,
                   dz          = dzCalcEdit.EditValue,
                   rx          = rxCalcEdit.EditValue = rxCalcEdit.Enabled ? rxCalcEdit.EditValue : "null",
                   ry          = ryCalcEdit.EditValue = ryCalcEdit.Enabled ? ryCalcEdit.EditValue : "null",
                   rz          = rzCalcEdit.EditValue = rzCalcEdit.Enabled ? rzCalcEdit.EditValue : "null",
                   ds          = dsCalcEdit.EditValue = dsCalcEdit.Enabled ? dsCalcEdit.EditValue : "null",
                   X0          = X0CalcEdit.EditValue = X0CalcEdit.Enabled ? X0CalcEdit.EditValue : "null",
                   Y0          = Y0CalcEdit.EditValue = Y0CalcEdit.Enabled ? Y0CalcEdit.EditValue : "null",
                   Z0          = Z0CalcEdit.EditValue = Z0CalcEdit.Enabled ? Z0CalcEdit.EditValue : "null";
            string countryName = string.Empty,
                   sou_prj     = string.Empty,
                   tar_prj     = string.Empty;
            int sou_wkid       = 0,
                tar_wkid       = 0;

            if (this.btnEditCountry.EditValue != null && (CountryClass)this.btnEditCountry.EditValue != null)
            {
                countryName = ((CountryClass)this.btnEditCountry.EditValue).NAME;
            }
            if (this.btnEditSou.EditValue != null && (CoordProjClass)this.btnEditSou.EditValue != null)
            {
                sou_prj  = ((CoordProjClass)this.btnEditSou.EditValue).NAME;
                sou_wkid = ((CoordProjClass)this.btnEditSou.EditValue).WKID;
            }
            if (this.btnEditTar.EditValue != null && (CoordProjClass)this.btnEditTar.EditValue != null)
            {
                tar_prj  = ((CoordProjClass)this.btnEditTar.EditValue).NAME;
                tar_wkid = ((CoordProjClass)this.btnEditTar.EditValue).WKID;
            }

            string Method = string.Empty;

            switch (paraTypeCmb.EditValue.ToString())
            {
            case "三参":
                Method = "3";
                break;

            case "七参":
                Method = "7";
                break;

            case "十参":
                Method = "10";
                break;
            }
            try
            {
                string sqlStr = "";
                if (iParamId <= 0)
                {
                    object maxId = AccessHelper.ExecuteScalar("select max(id) + 1 from CoordinatePara", null);
                    iParamId = (int)maxId;
                    sqlStr   = string.Format("INSERT INTO CoordinatePara (CoorTranName,Accuracy,WKID,AreaofUse,Method,MaximumLatitude,MinimumLatitude,MaximumLongitude,MinimumLongitude,dx,dy,dz,rx,ry,rz,ds,X0,Y0,Z0,Defined,ID , PARAM_TYPE,SOU_PRJ,SOU_WKID,TAR_PRJ,TAR_WKID,COUNTRYNAME)"
                                             + "VALUES('{0}',{1},{2},'{3}','{4}',{5},{6},{7},{8},{9},{10},{11},{12},{13},{14},{15},{16},{17},{18},{19},{20},'{21}','{22}',{23},'{24}',{25},'{26}')",
                                             CoorTranName, Accuracy, WKID, AreaofUse, Method, MaximumLatitude, MinimumLatitude, MaximumLongitude, MinimumLongitude, dx, dy, dz, rx, ry, rz, ds, X0, Y0, Z0, true, Convert.ToInt32(maxId), Method, sou_prj, sou_wkid, tar_prj, tar_wkid, countryName);
                }
                else
                {
                    sqlStr = string.Format("UPDATE CoordinatePara SET CoorTranName = '{0}'," +
                                           "Accuracy = {1}," +
                                           "WKID = {2}," +
                                           "AreaofUse =  = '{3}'," +
                                           "method =  = '{4}'," +
                                           "MaximumLatitude = {5}," +
                                           "MinimumLatitude = {6}," +
                                           "MaximumLongitude = {7}," +
                                           "MinimumLongitude = {8}," +
                                           "dx = {9}," +
                                           "dy = {10}," +
                                           "dz = {11}," +
                                           "rx = {12}," +
                                           "ry = {13}," +
                                           "rz = {14}," +
                                           "ds = {15}," +
                                           "X0 = {16}," +
                                           "Y0 = {17}," +
                                           "Z0 = {18}, " +
                                           "PARAM_TYPE = '{20}', " +
                                           "SOU_PRJ = '{21}', " +
                                           "SOU_WKID = {22}, " +
                                           "TAR_PRJ = '{23}', " +
                                           "TAR_WKID = {24}, " +
                                           "COUNTRYNAME = '{25}' " +
                                           "WHERE ID={19}",
                                           CoorTranName, Accuracy, WKID, AreaofUse, Method, MaximumLatitude, MinimumLatitude, MaximumLongitude, MinimumLongitude, dx, dy, dz, rx, ry, rz, ds, X0, Y0, Z0, iParamId, Method, sou_prj, sou_wkid, tar_prj, tar_wkid, countryName);
                }
                if (AccessHelper.ExecuteNonQuery(sqlStr, null) == 1)
                {
                    this.Text = "编辑 转换参数";
                    if (this.OnTransParamSaved != null)
                    {
                        CoordTrancParamClass trancparam = new CoordTrancParamClass();
                        trancparam.WKID = Convert.ToInt32(WKID);
                        trancparam.ID   = iParamId;
                        this.OnTransParamSaved(trancparam);
                    }
                    MessageBox.Show("保存成功!", "提示");
                }
                else
                {
                    MessageBox.Show("保存失败!", "提示");
                    if (this.Text.Contains("新增"))
                    {
                        iParamId = 0;
                    }
                }
            }
            catch (Exception err)
            {
                MessageBox.Show("保存失败!\t\n" + err.Message, "提示");
                if (this.Text.Contains("新增"))
                {
                    iParamId = 0;
                }
            }
        }
Exemple #2
0
        private void saveBtn_Click(object sender, EventArgs e)
        {
            CheckBeforeSave();

            object CoorTranName = tranNameTxtEdit.Text,
                   Accuracy     = AccurCalcEdit.EditValue,
                   WKID         = WKIDCalcEdit.EditValue,
                   AreaofUse    = useAreaTxtEdit.Text,
                   Method       = tranMethodTxtEdit.Text,

                   MaximumLatitude  = maxLatCalcEdit.EditValue,
                   MinimumLatitude  = minLatCalcEdit.EditValue,
                   MaximumLongitude = maxLonCalcEdit.EditValue,
                   MinimumLongitude = minLonCalcEdit.EditValue,

                   dx = dxCalcEdit.EditValue,
                   dy = dyCalcEdit.EditValue,
                   dz = dzCalcEdit.EditValue,
                   rx = rxCalcEdit.EditValue = rxCalcEdit.Enabled ? rxCalcEdit.EditValue : "null",
                   ry = ryCalcEdit.EditValue = ryCalcEdit.Enabled ? ryCalcEdit.EditValue : "null",
                   rz = rzCalcEdit.EditValue = rzCalcEdit.Enabled ? rzCalcEdit.EditValue : "null",
                   ds = dsCalcEdit.EditValue = dsCalcEdit.Enabled ? dsCalcEdit.EditValue : "null",
                   X0 = X0CalcEdit.EditValue = X0CalcEdit.Enabled ? X0CalcEdit.EditValue : "null",
                   Y0 = Y0CalcEdit.EditValue = Y0CalcEdit.Enabled ? Y0CalcEdit.EditValue : "null",
                   Z0 = Z0CalcEdit.EditValue = Z0CalcEdit.Enabled ? Z0CalcEdit.EditValue : "null";

            try
            {
                string sqlStr = "";
                if (this.Text.Contains("新增"))
                {
                    object maxId = AccessHelper.ExecuteScalar("select max(id) from CoordinatePara", null);

                    sqlStr = string.Format("INSERT INTO CoordinatePara (CoorTranName,Accuracy,WKID,AreaofUse,Method,MaximumLatitude,MinimumLatitude,MaximumLongitude,MinimumLongitude,dx,dy,dz,rx,ry,rz,ds,X0,Y0,Z0,Defined,ID)"
                                           + "VALUES('{0}',{1},{2},'{3}','{4}',{5},{6},{7},{8},{9},{10},{11},{12},{13},{14},{15},{16},{17},{18},{19},{20})",
                                           CoorTranName, Accuracy, WKID, AreaofUse, Method, MaximumLatitude, MinimumLatitude, MaximumLongitude, MinimumLongitude, dx, dy, dz, rx, ry, rz, ds, X0, Y0, Z0, true, Convert.ToInt32(maxId) + 1);
                }
                if (this.Text.Contains("编辑"))
                {
                    sqlStr = string.Format("UPDATE CoordinatePara SET CoorTranName = '{0}'," +
                                           "Accuracy = {1}," +
                                           "WKID = {2}," +
                                           "AreaofUse =  = '{3}'," +
                                           "Method =  = '{4}'," +
                                           "MaximumLatitude = {5}," +
                                           "MinimumLatitude = {6}," +
                                           "MaximumLongitude = {7}," +
                                           "MinimumLongitude = {8}," +
                                           "dx = {9}," +
                                           "dy = {10}," +
                                           "dz = {11}," +
                                           "rx = {12}," +
                                           "ry = {13}," +
                                           "rz = {14}," +
                                           "ds = {15}," +
                                           "X0 = {16}," +
                                           "Y0 = {17}," +
                                           "Z0 = {18} " +
                                           "WHERE ID={19}",
                                           CoorTranName, Accuracy, WKID, AreaofUse, Method, MaximumLatitude, MinimumLatitude, MaximumLongitude, MinimumLongitude, dx, dy, dz, rx, ry, rz, ds, X0, Y0, Z0, focusRow["ID"]);
                }
                if (AccessHelper.ExecuteNonQuery(sqlStr, null) == 1)
                {
                    MessageBox.Show("保存成功!", "提示");
                }
                else
                {
                    MessageBox.Show("保存失败!", "提示");
                }
            }
            catch (Exception err)
            {
                MessageBox.Show("保存失败!\t\n" + err.Message, "提示");
            }
        }