예제 #1
0
        public static DDesign SelectByIDAndRequestType(int ID, int RequestType)
        {
            SqlConnection Connection = new SqlConnection(Atend.Control.ConnectionString.ServercnString);
            SqlCommand    sqlCommand = new SqlCommand("D_Design_SelectByIDAndRequestType", Connection);

            sqlCommand.CommandType = CommandType.StoredProcedure;
            sqlCommand.Parameters.Add(new SqlParameter("iId", ID));
            sqlCommand.Parameters.Add(new SqlParameter("iRequestType", RequestType));
            Connection.Open();
            SqlDataReader reader = sqlCommand.ExecuteReader();
            DDesign       design = new DDesign();

            if (reader.Read())
            {
                design.Code           = Convert.ToInt32(reader["Code"].ToString());
                design.Title          = reader["Title"].ToString();
                design.ArchiveNo      = reader["ArchiveNo"].ToString();
                design.PRGCode        = Convert.ToInt64(reader["PRGCode"].ToString());
                design.WorkOrder      = Convert.ToInt64(reader["WorkOrder"].ToString());
                design.RequestType    = Convert.ToInt32(reader["RequestType"].ToString());
                design.Id             = Convert.ToInt32(reader["Id"]);
                design.AdditionalCode = Convert.ToInt32(reader["AdditionalCode"].ToString());
            }
            else
            {
                design.Id = -1;
            }
            reader.Close();
            Connection.Close();
            return(design);
        }
예제 #2
0
        //frmSaveDesignServer
        public static DDesign SelectByID(SqlTransaction _transaction, SqlConnection _connection, int ID)
        {
            SqlConnection Connection = _connection;
            SqlCommand    sqlCommand = new SqlCommand("D_Design_SelectById", Connection);

            sqlCommand.CommandType = CommandType.StoredProcedure;
            sqlCommand.Transaction = _transaction;

            sqlCommand.Parameters.Add(new SqlParameter("iId", ID));
            SqlDataReader reader = sqlCommand.ExecuteReader();
            DDesign       design = new DDesign();

            if (reader.Read())
            {
                //design.Code = Convert.ToInt32(reader["Code"].ToString());
                design.Title     = reader["Title"].ToString();
                design.ArchiveNo = reader["ArchiveNo"].ToString();
                design.PRGCode   = Convert.ToInt64(reader["PRGCode"].ToString());
                //design.WorkOrder = Convert.ToInt64(reader["WorkOrder"].ToString());
                design.RequestType = Convert.ToInt32(reader["RequestType"].ToString());
                design.Id          = Convert.ToInt32(reader["Id"]);
                //design.AdditionalCode = Convert.ToInt32(reader["AdditionalCode"].ToString());
                design.IsAtend = Convert.ToBoolean(reader["IsAtend"]);
                design.Address = reader["Address"].ToString();
                design.Region  = Convert.ToByte(reader["Region"].ToString());
            }
            else
            {
                design.Id = -1;
            }
            reader.Close();
            return(design);
        }
예제 #3
0
        public static DDesign SelectByProjectCode(int ProjectCode)
        {
            SqlConnection connection = new SqlConnection(Atend.Control.ConnectionString.ServercnString);
            SqlCommand    command    = new SqlCommand("D_Design_SelectByProjectcode", connection);

            command.CommandType = CommandType.StoredProcedure;

            connection.Open();
            command.Parameters.Add(new SqlParameter("iprojectCode", ProjectCode));
            SqlDataReader reader = command.ExecuteReader();
            DDesign       design = new DDesign();

            if (reader.Read())
            {
                design.Address     = reader["Address"].ToString();
                design.ArchiveNo   = reader["ArchiveNo"].ToString();
                design.Id          = Convert.ToInt32(reader["ID"].ToString());
                design.IsAtend     = Convert.ToBoolean(reader["IsAtend"]);
                design.PRGCode     = Convert.ToInt64(reader["PRGcode"].ToString());
                design.Region      = Convert.ToByte(reader["Region"].ToString());
                design.RequestType = Convert.ToInt32(reader["RequestType"].ToString());
                design.Title       = reader["Title"].ToString();
                //design.WorkOrder = Convert.ToInt64(reader["WorkOrder"].ToString());
            }
            else
            {
                design.Id = -1;
            }
            reader.Close();
            connection.Close();
            return(design);
        }
예제 #4
0
        public static bool GetFromPoshtiban()
        {
            Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
            //ed.WriteMessage("GoTo SelectServer\n");
            DataTable dtAllServer = SelectAllServer();
            //ed.WriteMessage("Go Select Poshtiban\n");
            DataTable dtAllPoshtiban = SelectAllPoshtiban();

            //ed.WriteMessage("Count={0}\n", dtAllServer.Rows.Count);
            //ed.WriteMessage("1\n");
            foreach (DataRow dr in dtAllPoshtiban.Rows)
            {
                DDesign design = SelectByProjectCode(Convert.ToInt32(dr["PRGCode"].ToString()));
                design.Address   = "";
                design.ArchiveNo = dr["ArchiveNo"].ToString();
                design.IsAtend   = false;
                design.PRGCode   = Convert.ToInt64(dr["PRGCode"].ToString());
                design.Region    = Convert.ToByte(dr["Region"].ToString());
                design.Title     = dr["Title"].ToString();
                DataRow[] drRequestType = SelectAllCompliment().Select(string.Format("PRGCode={0}", dr["PRGCode"].ToString()));

                if (drRequestType.Length != 0)
                {
                    design.RequestType = Convert.ToInt32(drRequestType[0]["RequestType"].ToString());
                }
                else
                {
                    design.RequestType = 0;
                }
                DataRow[] drWorkOrderPoshtiban = SelectAllWorkOrder().Select(string.Format("PRGCode={0}", dr["PRGCode"].ToString()));
                //ed.WriteMessage("Design.Id={0}\n",design.Id);
                if (design.Id != -1)
                {
                    //ed.WriteMessage("GOTO Upadte Design\n");
                    if (!design.Update())
                    {
                        //ed.WriteMessage("Up\n");
                        return(false);
                    }
                    else
                    {
                        //ed.WriteMessage("Update\n");
                        if (Atend.Base.Design.DWorkOrder.Delete(design.Id))
                        {
                            foreach (DataRow drWorkOrder in drWorkOrderPoshtiban)
                            {
                                Atend.Base.Design.DWorkOrder dWorkOrder = new DWorkOrder();
                                dWorkOrder.DesignID = design.Id;
                                //ed.WriteMessage("WORKORDERCODE={0}\n", drWorkOrder["WorkOrderCode"].ToString());
                                dWorkOrder.WorkOrder = Convert.ToInt32(drWorkOrder["WorkOrderCode"].ToString());
                                if (!dWorkOrder.Insert())
                                {
                                    return(false);
                                }
                            }
                        }
                    }
                }
                else
                {
                    design.PRGCode = Convert.ToInt32(dr["PRGCode"].ToString());
                    if (!design.Insert())
                    {
                        //ed.WriteMessage("Insert\n");
                        return(false);
                    }
                    else
                    {
                        foreach (DataRow drWorkOrder in drWorkOrderPoshtiban)
                        {
                            Atend.Base.Design.DWorkOrder dWorkOrder = new DWorkOrder();
                            dWorkOrder.DesignID  = design.Id;
                            dWorkOrder.WorkOrder = Convert.ToInt32(drWorkOrder["WorkOrderCode"].ToString());
                            if (!dWorkOrder.Insert())
                            {
                                return(false);
                            }
                        }
                    }
                }

                //ed.WriteMessage("6\n");
                //}
            }
            return(true);
        }